-
-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Proposal: Introduce global and per-image-request policy control about whether to use UIKit animated image or SDAnimatedImage, based on frame count and bytes size #3669
Comments
Any idea ? Can this solve your problem from the scratch ? |
@dreampiggy Yes this would be great. In my case, I don't know ahead of time whether urls will be animated or not. So i'm just using SDAnimatedImageView everywhere I want them to be able to animate. Having a global setting to say use SDAnimatedImage everywhere would be ideal |
This feature doesn't solve my problem. What I actually need is for both UIImageView and SDAnimatedImageView to be able to play the same animated image URL. However, it's still a good solution for #3668. |
@pepsikirk Seems not really easy. Possible but need more way to do so. Note: If you want this, you'll facing more RAM occpuy. As a example, a 1024 x 1024, 100 frame GIF, will occupy So this cause Anyway, this sounds another feature request, but I don't have a clever and clear implementation for now. Store multiple |
The situations where we encounter this are primarily with relatively small animated images, so the memory consumption is still acceptable. |
Having this very configurable class seems nice. But @simonmcl, I also have a very similar use case as you. We don't know if the image is animated or not before hand, so we use the animated image class everywhere. What I am currently doing is set a custom processor: |
Proposa,
Some people in #3668 #3667 seems talk about this old issue. When:
A large Application which contains both
UIImageView
andSDAnimatedImageView
, but wants onlySDAnimatedImageView
shows animation, ignore_UIAnimatedImage
at all.Here I have an idea:
Provide custom control
SDAnimatedImageDecodingPolicy
classIt can setted into global one
SDImageCoderHelper.DefaultAnimatedImageDecodingPolicy
, or can be passed as context value, per image-requestThe policy can be controlled like:
SDAnimatedImage
class and supports animating.SDAnimatedImage
(UIImageView will not show animating)_UIAnimatedImage
, note this cause all frames loaded into RAM (likepreloadAllFrames
), which may cause OOM (for example, a 1024x1024 100 frame GIF occupy 381MB)image.sd_memoryCost
, can be overrided by setter) > M, useSDAnimatedImage
, else use_UIAnimatedImage
Then, this can be customized and solve many App's issue.
For example, if you always load small GIF for icons, you can use
frame count > 10
as a policy, this means it's suitable for this case.For example, if you have a high ratio of OOM, you can use
bytes > 1MB
to avoid huge GIF accidentlly passed into_UIAnimatedImage
For example, if you don't want
UIImageView
to play animation at all, you just useAll use SDAnimatedImage
This can be really flexible for customization
The text was updated successfully, but these errors were encountered: