penfeizhou / APNG4Android

Android animation support for APNG & Animated WebP & Gif & Animated AVIF, High performance
Apache License 2.0
579 stars 76 forks source link

Specific Gif causes crash #148

Closed connyduck closed 2 years ago

connyduck commented 2 years ago

This gif causes the library to crash. I'm using the Glide integration, version 2.20.0

  java.lang.NullPointerException: Attempt to invoke virtual method 'int android.graphics.Rect.width()' on a null object reference
        at com.github.penfeizhou.animation.gif.decode.GifDecoder.renderFrame(GifDecoder.java:113)
        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 com.github.penfeizhou.animation.decode.FrameSeqDecoder.innerStart(FrameSeqDecoder.java:310)
        at com.github.penfeizhou.animation.decode.FrameSeqDecoder.access$900(FrameSeqDecoder.java:36)
        at com.github.penfeizhou.animation.decode.FrameSeqDecoder$6.run(FrameSeqDecoder.java:280)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loopOnce(Looper.java:201)
        at android.os.Looper.loop(Looper.java:288)
        at android.os.HandlerThread.run(HandlerThread.java:67)
jingpeng commented 2 years ago

Can you paste the explicit gif file here?

connyduck commented 2 years ago

3e2e282b-152f-4a70-8d1d-eb7797d002e3

connyduck commented 2 years ago

@penfeizhou any chance you can take a look at this? 🥺

penfeizhou commented 2 years ago

OK, let me see.

penfeizhou commented 2 years ago

This gif file's Background Color Index is out of range. This should not happen. I'll add some protection code.

penfeizhou commented 2 years ago

Please try v2.22.0

connyduck commented 2 years ago

Yes it works with 2.22.0, thank you