You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
AnimatedImageViewDelegate callbacks happen too soon when animating a gif that has more frames than the framePreloadCount. Also, on the first loop, a frame is skipped because of an off-by-one error.
What
When the buffer for an animated image (imageView.framePreloadCount) is smaller than the number of frames in the animated image, the delegate method animatedImageView(_:didPlayAnimationLoops:) is called too soon. Instead of being called at the end of the loop, it is called when the number of frames in the buffer have been displayed. That means if you have a gif with 10 frames, and a framePreloadCount of 5, the delegate method will be called after 5 frames have been displayed. Similarly, if you’re using imageView.repeatCount = .once, the gif will stop playback after 5 frames instead of 10.
Reproduce
[The steps to reproduce this issue. What is the url you were trying to load, where did you put your code, etc.]
I’ll use this gif for demonstration, as it is easier to see what’s happening. It’s got 10 frames, and each frame displays a number, 0 thru 9. (External link).
To demonstrate this issue, we use the following code in a view controller, setting the framePreloadCount to 5, when we know the gif has 10 frames.
I am traveling now so I have no chance to look at it in detail. But you are definitely right according to the screenshot. The p-r also looks great! I’d check it as soon as my feet in land!
Check List
Thanks for considering to open an issue. Before you submit your issue, please confirm these boxes are checked.
Issue Description
AnimatedImageViewDelegate
callbacks happen too soon when animating a gif that has more frames than theframePreloadCount
. Also, on the first loop, a frame is skipped because of an off-by-one error.What
When the buffer for an animated image (
imageView.framePreloadCount
) is smaller than the number of frames in the animated image, the delegate methodanimatedImageView(_:didPlayAnimationLoops:)
is called too soon. Instead of being called at the end of the loop, it is called when the number of frames in the buffer have been displayed. That means if you have a gif with 10 frames, and aframePreloadCount
of5
, the delegate method will be called after 5 frames have been displayed. Similarly, if you’re usingimageView.repeatCount = .once
, the gif will stop playback after 5 frames instead of 10.Reproduce
[The steps to reproduce this issue. What is the url you were trying to load, where did you put your code, etc.]
I’ll use this gif for demonstration, as it is easier to see what’s happening. It’s got 10 frames, and each frame displays a number, 0 thru 9. (External link).
To demonstrate this issue, we use the following code in a view controller, setting the
framePreloadCount
to5
, when we know the gif has 10 frames.When we tap a play button, animation begins:
And finally, when the delegate method is called after a loop, we stop animating, and re-enable the play button:
The following shows this sample app running. Notice the two issues:
Other Comment
The text was updated successfully, but these errors were encountered: