-
Notifications
You must be signed in to change notification settings - Fork 87
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Memory leaks in webp render process #46
Comments
@dreampiggy hi. Have you found a time to take a look on that? |
Does this issue still exist ? I doubt
So, if there is one image with 2000x2000 pixels, it must allocate 15.2587890625 MB. |
yes for iOS 12 & 13. in my case all images have a size 1080x835. So the expected memory usage should be ((10808354)/1024)/1024=3.44009399414 per image. In my mind the image should not be rendered in case when it is not visible. for now I can't use webp for ios because of lelaks for old OS versions. So, I use the same set of images but jpeg, and app memory usage about 70-80mb. |
it can decode even animated images (webp). |
Apple's JPEG/GIF codec use some trick to avoid peak memory usage. It's tied Image/IO codec and UIKit render engine. However, libwebp is outside of ImageIO, so once the image is not visible, UIImageView (iOS's rendering component) can not get the context to release the frame buffer. If you use Static WebP mostlly. Using iOS 14's built-in support for WebP is better. This WebPCoder is mostlly used for Animated WebP. Which is still not supported by Apple. |
Some trick for optimization about rendering RAM usage: The most important one is that Actually, for JPEG/PNG, the hardware-accelerated decoding speed is fast enough so Apple decide to However, for WebP, the decoding speed is slow, so if we |
Thanks. Will try this solution. |
doesn't seem a possible solution if I need to convert an animated UIimage to webp Data. But the conversion is very slow and takes up a lot of RAM, many times it fails for memory leak. |
If you can not get the suitable desired file size for WebP encoding, you'd better use And, this issue and topic is talked about WebP Decoding, not Encoding...If there are something issue in encoding, we'd better open a new issue instead. |
And, for WebP Encoding, libwebp provide one config:
What about use this to have a try ? SDWebImageWebPCoder can map the options from Objective-C code to C-level API, see: |
Hello, thank you for the reply. I did try that option enabling low memory usage but it's very slow. And yes, the encodeMaxFileSize was an issue. I am using compressionQuality for the moment. I would like to do a faster encoding of an animated [SDImageFrame]. It takes about 10 seconds for a 60 frames animated image. (500x500px) This is what I am doing at the moment:
Where |
For
More: https://developers.google.com/speed/webp/docs/cwebp, many lossy options may effect the encoding time and quality. Actually I'm not expect at webp encoding. I focus on integrate the webp to iOS platform with easy-to-use interface... |
You can also use |
I understand that there is not good solution for keeping an animated WebP under 500KB with a 500x500px with a fast encoding. |
Just move to new issue from this issue
Looks like the issue still exists for ios < 14.0
Can reproduce on devices with ios 12 and ios 13 while trying to render static WebP images (I see huge memory usage which cause app crash due to memory).
On ios14 works fine because SDWebImage v5.9.0 started to use native coder implementation.
In my pod manifest SDWebImageWebPCoder = 0.6.1.
On that image shown memory usage when 28 images were rendered. Size of each image about 40-80 kb.
About code usage.
I render images using ImageBackground (which uses Image component. Native code is here) component.
Also to add support of webp I've used react-native-webp-format (native code is here).
Also a little bit more info about images:
I've generated them using imagick with the following options.
Also image sample attached (i had put it into zip because github does not allow to attach webp).
thumb_dcee16ff-ac19-4452-8784-605ff9e39848_photos_medium.webp.zip
The text was updated successfully, but these errors were encountered: