-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
Delayed unsubscribe timing to unsubscribe after displaying the last i… #2298
Conversation
Thanks for your pull request. It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please visit https://cla.developers.google.com/ to sign. Once you've signed, please reply here (e.g.
|
I signed it! |
@@ -103,6 +104,7 @@ Bitmap getFirstFrame() { | |||
} | |||
|
|||
void subscribe(FrameCallback frameCallback) { | |||
unsubscribeRegisteredCallback(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What if subscribe is never called again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just fail safe.
Normally, unsubscribeRegisteredCallback() is called inside onFrameReady() and then callbacks will be unsubscribed.
When an user click image repeat quickly, subscribe() may be called before onFrameReady() is called.
Thanks for putting this up, I really appreciate the detail and the repro case. This is definitely a complicated problem. I'm sorry for the delay, it took me a bit to wrap my head around this. I think this solution isn't quite complete though. Let's say you have the same GIF animating in two views at the same time. Then, you stop both When the first When the second We really should be assigning ownership of the frame to the stopped One way to do this might be to have |
Targeting this for 4.2 since I'm already a day late for 4.1. |
Thank you for your reply and your detailed opinion |
CLAs look good, thanks! |
I believe this was fixed in #2526. |
…mage
Description
I want to stop/start animation gif.
I delay unsubscribe timing to fix an animation gif bug.
Motivation and Context
Current code of master branch, when you call stop() method of Animation interface, callback will be unsubscribed soon.
Then, in background thread, new bitmap for next frame is prepared and previous bitmap is recycled.
But, callback is already unsubscribed, so new bitmap will not be applied and previous bitmap will be used to draw other gif animation frame.
As a result, it seems that a image which is stopped animation is changed by other animation.
About reproduce:
More than two GIF animation are played, and when you stop animation of one file by using stop() method, you will find a bug.
The bug is that animating gif file will change image of not animating gif image.
You can reproduce it with this repo (https://github.com/matsuhiro/glide/tree/reproduce_bug).
(You can reproduce it by applying this patch matsuhiro@9359a7f)
For reproducing, it is easy to understand that images of the same size are being played at the same time.