Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference on Activity Pause
See original GitHub issueNew Issue Checklist
- [✔️] I have searched for a similar issue in the project and found 1 but the error still there in webp.
Issue Info
Info | Value | |
---|---|---|
Device Info | e.g. ZTE Blade V9, LG V50 | |
System Version | e.g. 7.1, 11 | |
APNG4Android Library Version | e.g. 2.16.1 | |
Repro rate | e.g. all the time (100%) | |
Repro with our demo project | e.g. Yes | |
Demo project link | e.g. link to a demo project that highlights the issue |
Issue Description and Steps
Hi, i have loaded 10-20 animated webps, it displays perfect, but when click a button that opens another Activity or AD it crashes with error:
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference at android.graphics.BaseCanvas.throwIfCannotDraw(BaseCanvas.java:65) at android.graphics.BaseCanvas.drawBitmap(BaseCanvas.java:113) at android.graphics.Canvas.drawBitmap(Canvas.java:1555) at com.github.penfeizhou.animation.webp.decode.AnimationFrame.draw(AnimationFrame.java:100) at com.github.penfeizhou.animation.webp.decode.AnimationFrame.draw(AnimationFrame.java:21) at com.github.penfeizhou.animation.webp.decode.WebPDecoder.renderFrame(WebPDecoder.java:147) at com.github.penfeizhou.animation.decode.FrameSeqDecoder.step(FrameSeqDecoder.java:505) at com.github.penfeizhou.animation.decode.FrameSeqDecoder.access$200(FrameSeqDecoder.java:36) at com.github.penfeizhou.animation.decode.FrameSeqDecoder$1.run(FrameSeqDecoder.java:60) at android.os.Handler.handleCallback(Handler.java:883) at android.os.Handler.dispatchMessage(Handler.java:100) at android.os.Looper.loop(Looper.java:214) at android.os.HandlerThread.run(HandlerThread.java:67)
It happen with all kind of animated webp, i think when activity got paused. i tried LG V50 and ZTE V9
Issue Analytics
- State:
- Created 2 years ago
- Comments:8 (3 by maintainers)
Its perfect! no errors thrown now, only one thing weird happened, its like the the imageviews lost frames when resumed, like white white white frame white white frame. but not a problem right now, i can redraw/reload the views on resume.
Thanks a lot @penfeizhou, keep up the great work!
I did publish to maven center. The synchronization need some time. You can download here. https://s01.oss.sonatype.org/content/repositories/releases/com/github/penfeizhou/android/animation/