width and height must be > 0
See original GitHub issueNew Issue Checklist
- [X ] I have searched for a similar issue in the project and found none
Issue Info
Info | Value | |
---|---|---|
Device Info | e.g. ZTE BLADE V9, and most Android 9 to lower | |
System Version | e.g. 7 to 9 | |
APNG4Android Library Version | e.g. 2.17 | |
Repro rate | e.g. all the time (100%) | |
Repro with our demo project | e.g. does it happen with our demo project? | |
Demo project link | none |
Issue Description and Steps
Im trying to solve error and to pass error with Try Catch without success, i have hours and days of debugging to check if app is passing a null image but not, it only happens on old Android devices when i load about 30 animated webps in imageviews, on newer version of android is OK.
Fatal Exception: java.lang.IllegalArgumentException: width and height must be > 0 at android.graphics.Bitmap.createBitmap(Bitmap.java:1114) at android.graphics.Bitmap.createBitmap(Bitmap.java:1081) at android.graphics.Bitmap.createBitmap(Bitmap.java:1031) at android.graphics.Bitmap.createBitmap(Bitmap.java:992) at com.github.penfeizhou.animation.decode.FrameSeqDecoder.obtainBitmap(FrameSeqDecoder.java:130) at com.github.penfeizhou.animation.webp.decode.WebPDecoder.renderFrame(WebPDecoder.java:146) 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$9.run(FrameSeqDecoder.java:446) at android.os.Handler.handleCallback(Handler.java:938) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:240) at android.os.HandlerThread.run(HandlerThread.java:67)
Happens on FrameSeqDecoder.obtainBitmap, i have more than 1000 alerts of errors on Crashlytics.
Issue Analytics
- State:
- Created 2 years ago
- Comments:41 (15 by maintainers)
Hi again, after heavy testing and debugging the new version, there is still the same problem,
Checking my webp files, i found one that is causing this bug, if webp has a transparent frame or blank frame it causes error width and height must be > 0 even if it has same height and width than next frames:
Look at first frame, it are blank frame/transparent frame, if use it in my app, app crashes(only on some phones).
But if i delete blank frame it work like charm in app, so the problem is in some devices blank frames are detected without size. apparently APNG detects the size of frame correctly, but not android.graphics.Bitmap.createBitmap 0x0px when passed to system.
Affected webp, test on your phone this files: https://cdn.noten.in/temp/badwebp.webp ❌ With blank frame https://cdn.noten.in/temp/goodwebp.webp ✔️Edited on EzGif
So how to check if frame is transparent? by size? by color depth? maybe can skip transparent frames.
My app loads dynamically a grid of imageviews, so i cant edit one by one, i have like 125,620 webps on server to load.
1870 user phones has same error
When parsing WebP formats, there is no relation to android platform api. And according to webp spec, the width and height cannot be less than 1.Because this is a unsigned value.
This could only happen when there is no ANIM Chunk, this library treats it as non animated webp. In this case, it calls platform api to get width and height.