glide icon indicating copy to clipboard operation
glide copied to clipboard

GifFrameLoader NPE

Open nickming opened this issue 2 years ago • 3 comments
trafficstars

Glide Version:4.15.1

Integration libraries:OKhttp

Device/Android Version:11,12,13

Issue details / Repro steps / Use case background: After loading the Gif resource, the GifDrawable implements the FrameCallback interface, but the Drawable may be recycled, but the callback is distributed through the Handler, so there may be a situation where the reference has been recycled, resulting in a null pointer exception. It is hoped that a short judgment can be made at the place of acquisition

java.lang.NullPointerException: Attempt to invoke interface method 'void com.bumptech.glide.load.resource.gif.GifFrameLoader$FrameCallback.g()' on a null object reference 08-25 08:32:38.046 23397 23397 E AndroidRuntime: at com.bumptech.glide.load.resource.gif.GifFrameLoader.a(GifFrameLoader.java:287) 08-25 08:32:38.046 23397 23397 E AndroidRuntime: at com.bumptech.glide.load.resource.gif.GifFrameLoader$FrameLoaderCallback.handleMessage(GifFrameLoader.java:308) 08-25 08:32:38.046 23397 23397 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:102) 08-25 08:32:38.046 23397 23397 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:223) 08-25 08:32:38.046 23397 23397 E AndroidRuntime: at android.os.Looper.loop(Looper.java:324) 08-25 08:32:38.046 23397 23397 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:8539) 08-25 08:32:38.046 23397 23397 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method) 08-25 08:32:38.046 23397 23397 E AndroidRuntime: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:582) 08-25 08:32:38.046 23397 23397 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1059)

nickming avatar Aug 25 '23 02:08 nickming

Glide Version: 4.13.2

Same NPE on GifFrameLoader.onFrameReady(GifFrameLoader.java:287)

baoti avatar Sep 27 '23 01:09 baoti

Does this happen on any particular set of devices? We only ever call subscribe/unsubscribe on the frame loader using this in GifDrawable. It looks like this NPE is saying that the callback itself is null, which shouldn't be possible.

sjudd avatar Sep 30 '23 04:09 sjudd

Does this happen on any particular set of devices? We only ever call subscribe/unsubscribe on the frame loader using this in GifDrawable. It looks like this NPE is saying that the callback itself is null, which shouldn't be possible.

It is not on a specific device. The main scenario is that we manually play the gif image, and the drawable is wrapped by softreference. The drawable may be recycled before starting to play, causing the handler to get null when processing.

nickming avatar Oct 08 '23 04:10 nickming