Fix the logic for Animated WebP images which contains a subsequence blend from the first frame, impact the SDAnimatedImage
#14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
PR description
There are a critical bug in the
SDAnimatedImageCoderprotocol implementation foranimatedImageFrameAtIndex:.The implementation which use the optimization to avoid random access for webp frame, have a bug to detect which frame can be safelly blend start with.
The relative code can be checked there in YYImage-YYImageCoder.m
Bugfix
For example, this WebP image:
http://i1.chuimg.com/d76f3bed2a67462994cf0bac727f68b7_1080w_606h.webp
It has the following frame info:
The bug screenshot:

The
frame 2, which useblend == yes, should keep theframe 1's draw context, and blend on it. But however, current implementation ignore this.See the debug result for the
frame 2representation, which does not haveframe 1's blend draw at all. Instead it use a clear context for drawing (CGContextClearRect)Fix
The correct result: