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
Glide Version: 3.7.0 Integration libraries: N/A Device/Android Version: Galaxy S4 / 4.4.2 Issue details / Repro steps / Use case background:
While investigating another issue I played around with an animated GIF (has 5 frames, and long delays). The setup is simple: show an image in a fragment on startup, and there's button to call Glide.clear(imageView).
In the below log you can see:
the load succeeded as expected
it showed frames 0,1,2,3
GLIDE: Clearing target is the button press
continued to load frames 4,0,1,2, ...
While on the UI:
placeholder while downloading image
frames 0,1,2,3
placeholder after pressing button
Weirdly it doesn't always happen, if the resource is loaded from memory cache, then after clearing there are no more frames loaded. This is because there's a placeholder and TransitionDrawable (see "Proposed fix" for more).
Glide load line / GlideModule (if any) / list Adapter code (if any):
Workaround:
Most of the time users won't experience this issue, becuase this continuous loading is stopped when a GC happens, but it's still a good idea to properly free resources.
Proposed fix:
I think the problem is in GlideDrawableImageViewTarget where onResourceReadyresource.start() is called, but the animation is only stopped when the activity/fragment is stopped. I think that class needs to override another method too:
The comment in GifDrawable.stop() says there's an automatic detection of "no longer in use". This doesn't work when the GifDrawable is part of a TransitionDrawable because that sets itself as callback to the GifDrawable. So the check that would clean up resources fails in onFrameReady. This only happens when a thumbnail or a placeholder was displayed with crossFade before the GIF load finished. This may worth fixing as well as part of this issue, for example changing getCallback() to something like findCallback():
/** * Find out if there's a real Callback registered to this Drawable. * In case of multiple layers of drawables, like in case of `TransitionDrawable`, * find the topmost callback. */privateCallbackfindCallback() {
Callbackcallback = getCallback();
while (callbackinstanceofDrawable) {
callback = ((Drawable)callback).getCallback();
}
returncallback;
}
The text was updated successfully, but these errors were encountered:
Glide Version: 3.7.0
Integration libraries: N/A
Device/Android Version: Galaxy S4 / 4.4.2
Issue details / Repro steps / Use case background:
While investigating another issue I played around with an animated GIF (has 5 frames, and long delays). The setup is simple: show an image in a fragment on startup, and there's button to call
Glide.clear(imageView)
.In the below log you can see:
GLIDE: Clearing target
is the button pressWhile on the UI:
Weirdly it doesn't always happen, if the resource is loaded from memory cache, then after clearing there are no more frames loaded. This is because there's a placeholder and
TransitionDrawable
(see "Proposed fix" for more).Glide load line /
GlideModule
(if any) / list Adapter code (if any):Stack trace / LogCat:
Workaround:
Most of the time users won't experience this issue, becuase this continuous loading is stopped when a GC happens, but it's still a good idea to properly free resources.
Proposed fix:
I think the problem is in
GlideDrawableImageViewTarget
whereonResourceReady
resource.start()
is called, but the animation is only stopped when the activity/fragment is stopped. I think that class needs to override another method too:The comment in
GifDrawable.stop()
says there's an automatic detection of "no longer in use". This doesn't work when theGifDrawable
is part of aTransitionDrawable
because that sets itself as callback to theGifDrawable
. So the check that would clean up resources fails inonFrameReady
. This only happens when a thumbnail or a placeholder was displayed with crossFade before the GIF load finished. This may worth fixing as well as part of this issue, for example changinggetCallback()
to something likefindCallback()
:The text was updated successfully, but these errors were encountered: