facebook / fresco

An Android library for managing images and the memory they use.
https://frescolib.org/
MIT License
17.05k stars 3.75k forks source link

How can I deal with the "Failed to decode frame" exception? #1868

Open UFreedom opened 6 years ago

UFreedom commented 6 years ago

I see the abnormal information display is decode frame problem, but I don't know which frame has the problem and what is the problem, such as picture is invalid, picture format info wrong, or other questions about the frame,

If my app has this problem, how can I solve it and then avoid this problem?

Fatal Exception: java.lang.IllegalStateException: Failed to decode frame
       at com.facebook.animated.webp.WebPFrame.nativeRenderFrame(SourceFile)
       at com.facebook.animated.webp.WebPFrame.renderFrame(SourceFile:50)
       at com.facebook.imagepipeline.animated.impl.AnimatedDrawableBackendImpl.renderImageSupportsScaling(SourceFile:203)
       at com.facebook.imagepipeline.animated.impl.AnimatedDrawableBackendImpl.renderFrame(SourceFile:177)
       at com.facebook.imagepipeline.animated.impl.AnimatedImageCompositor.renderFrame(SourceFile:120)
       at com.facebook.fresco.animation.bitmap.wrapper.AnimatedDrawableBackendFrameRenderer.renderFrame(SourceFile:74)
       at com.facebook.fresco.animation.bitmap.preparation.DefaultBitmapFramePreparer$FrameDecodeRunnable.renderFrameAndCache(SourceFile:175)
       at com.facebook.fresco.animation.bitmap.preparation.DefaultBitmapFramePreparer$FrameDecodeRunnable.prepareFrameAndCache(SourceFile:154)
       at com.facebook.fresco.animation.bitmap.preparation.DefaultBitmapFramePreparer$FrameDecodeRunnable.prepareFrameAndCache(SourceFile:162)
       at com.facebook.fresco.animation.bitmap.preparation.DefaultBitmapFramePreparer$FrameDecodeRunnable.run(SourceFile:112)
       at com.facebook.common.executors.ConstrainedExecutorService$Worker.run(SourceFile:177)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
       at com.facebook.imagepipeline.core.PriorityThreadFactory$1.run(SourceFile:42)
       at java.lang.Thread.run(Thread.java:818)
oprisnik commented 6 years ago

Do you have a image URI for such a corrupted / invalid WebP?

UFreedom commented 6 years ago

@oprisnik

That's why I asked this question, because when APP was released, I couldn't have known which webp picture was wrong, but I didn't want to APP to stop because of the problem,

So I would like to know how can i can avoid this problem, or when this problem occurs,Fresco may take a user-friendly solution, rather than throwing Fatal Exception.

dss886 commented 6 years ago

Same problem, can I try-catch somewhere so that my app won't crash?

When this exception occur, the webp animation stop or even go invisible is ok for me.

oprisnik commented 6 years ago

Yeah, having an option not to crash would be nice. Feel free to check out the stack trace and submit a pull request :)