-
-
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
5.18.4+ SDAnimatedImage static image support performance issue #3706
Comments
The issue may because the default behavior of "Force Decoding" is OFF, for SDAnimatedImage The comment is showing in the "SDImageForceDecodePolicy" and "SDImageDecodeUseLazyDecoding"
Maybe we need to fix this by check for "frame == 1" instead of "isKindOfClass" |
@dreampiggy Of course checking frame == 1 is an alternative, but this might have a lot more impact to existing code? Since any place that used to check if the image is animated, now needs to double check the frame count as well. But you know better than me XD, so this is just a suggestion. |
The But things changed during these years:
I think, the better way is to rename this class into For current quick hack, the old check for |
Can #3708 fix your issue ? If not, actually, it's OK to totally revert the #3625 These are just two choice:
|
I see, thanks for educating me on the details of animated images. I think then it is very reasonable to use a single image class and rename to "SDImage". It does feel more intuitive from a user's perspective to not have to worry too much about animated or not and just form a single image for all use cases. As long as |
I checked, #3708, looks good to me. Thanks a lot! Here are a couple questions & suggestions I have:
|
Static Image (
|
Is enough at least for most cases. Because These two case is hard compared to static image (like transformer) or re-encoding. If you really want to distinguish the |
@dreampiggy Ok thanks, I see. I think once the new version comes out, and the performance issue is taken care of, then we can close this issue. |
Can you just test using that branch dependency to see whether the performance regression is solved ? I'll wait for your tesing result and then merge that |
I left a comment on the PR. I verified with that branch and the scrolling performance is smooth. I think you can go ahead 👍 Things look good and thanks for the fast response and help! |
New Issue Checklist
Issue Info
Issue Description and Steps
Hi, I have particularly strange issue encountered which I narrowed down to this particular change of SDAnimatedImage:
5.18.4 - 5.18 Fix, on Oct 27th, 2023
SDAnimatedImage now supports static image like JPEG data #3626 #3625
Previous version the initializer will return nil and has to use UIImage/NSImage instead
When downloading images from the web, we sometimes don't know for sure beforehand if this image is animated or not. Although we can guess from the url extension, we'd prefer the process to be more automatic. So in some occasions, we would pass
context[.animatedImageClass] = SDAnimatedImage.self
to ask SDWebImage to try use animated image if possible. In previous versions, if this image is not an animated image, it would fallback to a regular UIImage, which we have no issue with.
After upgrading to the 5.18.4+ however, the newly added mechanism would create a SDAnimatedImage instead of returning nil, this seems to bring noticeable performance overhead when scrolling in a UICollectionView. We use a subclass of SDAnimatedImageView as a general purpose image view that can show either regular or animated images. Scrolling in this case becomes quite choppy, I tried to look into the source code but was unable to understand the full picture. And sorry I do not have any reliable way to benchmark this except from purely observations. I tried 5.18.3 or try not pass
context[.animatedImageClass] = SDAnimatedImage.self
, the scrolling becomes very smooth again.I am wondering if it is possible to add an additional SDImageCoderOptions to configure this behavior? Namely, could we add an option so that SDAnimatedImage would fail to create like in the past and we would fallback to a simple UIImage?
The text was updated successfully, but these errors were encountered: