question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference on Activity Pause

See original GitHub issue

New 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:closed
  • Created 2 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
Ferdaricommented, Nov 19, 2021

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!

1reaction
penfeizhoucommented, Nov 19, 2021

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/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Attempt to invoke virtual method 'boolean android.graphics. ...
java.lang.NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference · Ask ...
Read more >
android.graphics.Bitmap.isRecycled java code examples
How to use. isRecycled. method. in. android.graphics.Bitmap ... isRecycled() && mShowPauseCover) { mFullPauseBitmap.recycle(); mFullPauseBitmap = null; } ...
Read more >
Attempt to invoke virtual method ''void android.graphics. ...
NullPointerException: Attempt to invoke virtual method ''void android.graphics.Bitmap.setHasAlpha(boolean)'' on a null object reference at android.graphics.
Read more >
Bitmap
Flag for use with writeToParcel(Parcel, int) : the object being written is a return value, that is the result of a function such...
Read more >
Android – How to draw a bitmap to a SurfaceView - iTecNote
NullPointerException: Attempt to invoke virtual method 'boolean android.graphics.Bitmap.isRecycled()' on a null object reference ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found