Skip to content
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

NPE recycling null Bitmap #212

Closed
sjudd opened this issue Oct 23, 2014 · 1 comment
Closed

NPE recycling null Bitmap #212

sjudd opened this issue Oct 23, 2014 · 1 comment
Assignees
Labels
Milestone

Comments

@sjudd
Copy link
Collaborator

sjudd commented Oct 23, 2014

Internal bug is b/18093433.

Not totally clear how this would happen, I'll start by adding assertions that data is not null when resources are created.

E/AndroidRuntime(  506): FATAL EXCEPTION: main
E/AndroidRuntime(  506): Process: com.android.camera2, PID: 506
E/AndroidRuntime(  506): java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isMutable()' on a null object reference
E/AndroidRuntime(  506):        at com.bumptech.glide.load.engine.bitmap_recycle.LruBitmapPool.put(LruBitmapPool.java:65)
E/AndroidRuntime(  506):        at com.bumptech.glide.load.resource.bitmap.BitmapResource.recycle(BitmapResource.java:32)
E/AndroidRuntime(  506):        at com.bumptech.glide.load.engine.EngineResource.recycle(EngineResource.java:57)
E/AndroidRuntime(  506):        at com.bumptech.glide.load.engine.Engine$ResourceRecyclerCallback.handleMessage(Engine.java:273)
E/AndroidRuntime(  506):        at android.os.Handler.dispatchMessage(Handler.java:98)
E/AndroidRuntime(  506):        at android.os.Looper.loop(Looper.java:135)
E/AndroidRuntime(  506):        at android.app.ActivityThread.main(ActivityThread.java:5221)
E/AndroidRuntime(  506):        at java.lang.reflect.Method.invoke(Native Method)
E/AndroidRuntime(  506):        at java.lang.reflect.Method.invoke(Method.java:372)
E/AndroidRuntime(  506):        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
E/AndroidRuntime(  506):        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)
W/ActivityManager(  758):   Force finishing activity com.android.camera2/com.android.camera.CameraLauncher
@sjudd sjudd added bug and removed bug labels Oct 23, 2014
@sjudd sjudd added this to the 3.4 milestone Oct 23, 2014
@sjudd sjudd self-assigned this Oct 23, 2014
sjudd added a commit to sjudd/glide that referenced this issue Oct 23, 2014
sjudd added a commit to sjudd/glide that referenced this issue Oct 23, 2014
@sjudd
Copy link
Collaborator Author

sjudd commented Oct 25, 2014

I believe the earlier commits fixed the recycling problem and have revealed the underlying cause. When the drawable is stopped and then started again while a frame is being decoded (via start/stop or setVisible), the decoder is advanced and a second frame decode may be started simultaneously using the same GifDecoder, resulting in the error below.

D/GenericRequest( 6031): load failed
D/GenericRequest( 6031): java.lang.ArrayIndexOutOfBoundsException: length=4097; index=4097
D/GenericRequest( 6031):        at com.bumptech.glide.gifdecoder.GifDecoder.decodeBitmapData(GifDecoder.java:616)
D/GenericRequest( 6031):        at com.bumptech.glide.gifdecoder.GifDecoder.setPixels(GifDecoder.java:450)
D/GenericRequest( 6031):        at com.bumptech.glide.gifdecoder.GifDecoder.getNextFrame(GifDecoder.java:294)
D/GenericRequest( 6031):        at com.bumptech.glide.load.resource.gif.GifFrameResourceDecoder.decode(GifFrameResourceDecoder.java:19)
D/GenericRequest( 6031):        at com.bumptech.glide.load.resource.gif.GifFrameResourceDecoder.decode(GifFrameResourceDecoder.java:10)
D/GenericRequest( 6031):        at com.bumptech.glide.load.engine.DecodeJob.decodeFromSourceData(DecodeJob.java:143)
D/GenericRequest( 6031):        at com.bumptech.glide.load.engine.DecodeJob.decodeSource(DecodeJob.java:131)
D/GenericRequest( 6031):        at com.bumptech.glide.load.engine.DecodeJob.decodeFromSource(DecodeJob.java:101)
D/GenericRequest( 6031):        at com.bumptech.glide.load.engine.EngineRunnable.decodeFromSource(EngineRunnable.java:121)
D/GenericRequest( 6031):        at com.bumptech.glide.load.engine.EngineRunnable.decode(EngineRunnable.java:100)
D/GenericRequest( 6031):        at com.bumptech.glide.load.engine.EngineRunnable.run(EngineRunnable.java:57)
D/GenericRequest( 6031):        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
D/GenericRequest( 6031):        at java.util.concurrent.FutureTask.run(FutureTask.java:237)
D/GenericRequest( 6031):        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
D/GenericRequest( 6031):        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
D/GenericRequest( 6031):        at java.lang.Thread.run(Thread.java:841)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant