Coil: Native crash when using native ImageDecoderDecoder to load gifs on Android Q

Created on 14 Sep 2019  路  4Comments  路  Source: coil-kt/coil

Describe the bug
Loading these images results in a native crash on my Pixel 3: https://cdn.dribbble.com/users/730703/screenshots/7127901/landor.gif
https://assets.materialup.com/uploads/d760b727-b2bc-4e1e-8565-bd1155539e0c/animated_teaser.gif

Appears to happen with any gif

To Reproduce
How can we reproduce this?
The links above should work, can set up a repro branch in a side project app if you want more.

Expected behavior
Not crash

Logs/Screenshots

    --------- beginning of crash
2019-09-13 23:24:38.956 12100-12415/io.sweers.catchup.debug A/libc: Fatal signal 6 (SIGABRT), code -1 (SI_QUEUE) in tid 12415 (AnimatedImageTh), pid 12100 (s.catchup.debug)
2019-09-13 23:24:39.029 12422-12422/? A/DEBUG: pid: 12100, tid: 12415, name: AnimatedImageTh  >>> io.sweers.catchup.debug <<<

Library version
0.7.0

bug

All 4 comments

@ZacSweers Thank you for detailed issue. I reproduce it on simulador API 29, apparently and following the documentation to support the gif format you need to add an extension library, and implementing your own decoder.

val imageLoader = ImageLoader(context) {
    componentRegistry {
        if (SDK_INT >= P) {
            add(ImageDecoderDecoder())
        } else {
            add(GifDecoder())
        }
    }
}

The problem appear with the ImageDecoderDecoder(), a temporal work-around is to use GifDecoder() independent of API version. But let's investigate more deeply to understand what happens with ImageDecoderDecoder()

Stack trace:
2019-09-14 21:09:13.552 15455-15455/coil.sample E/RealImageLoader: android.graphics.ImageDecoder$DecodeException: Failed to create image decoder with message 'unimplemented'Input contained an error. at android.graphics.ImageDecoder.nCreate(Native Method) at android.graphics.ImageDecoder.access$100(ImageDecoder.java:173) at android.graphics.ImageDecoder$ByteBufferSource.createImageDecoder(ImageDecoder.java:247) at android.graphics.ImageDecoder.decodeDrawableImpl(ImageDecoder.java:1743) at android.graphics.ImageDecoder.decodeDrawable(ImageDecoder.java:1736) at coil.decode.ImageDecoderDecoder.decode(ImageDecoderDecoder.kt:64) at coil.RealImageLoader$loadData$2.invokeSuspend(RealImageLoader.kt:345) at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33) at kotlinx.coroutines.DispatchedTask.run(Dispatched.kt:241) at kotlinx.coroutines.scheduling.CoroutineScheduler.runSafely(CoroutineScheduler.kt:594) at kotlinx.coroutines.scheduling.CoroutineScheduler.access$runSafely(CoroutineScheduler.kt:60) at kotlinx.coroutines.scheduling.CoroutineScheduler$Worker.run(CoroutineScheduler.kt:740)

Yep I'm just going to use GifDecoder in the meantime. Have added my repro gifs to the issue tracker: https://issuetracker.google.com/issues/139371066. Closing for now as this is an android framework issue. Would suggest others star the issue/add their repro cases there

I'll update the documentation to recommend using GifDecoder for all API levels as well and link to the framework issue.

According to the Android framework team, this bug only occurs when using ImageDecoder.createSource(ByteBuffer). Unfortunately, that's the only method we can use to decode the Okio BufferedSource.

Hopefully, a fix will go out in the next Android maintenance release. In the meantime, I've updated the docs to recommend against using ImageDecoderDecoder.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

r4phab picture r4phab  路  6Comments

ianhanniballake picture ianhanniballake  路  3Comments

doilio picture doilio  路  3Comments

mario picture mario  路  3Comments

billyjoker picture billyjoker  路  5Comments