coil-kt / coil

Image loading for Android and Compose Multiplatform.
https://coil-kt.github.io/coil/
Apache License 2.0
10.84k stars 665 forks source link

Some Images Fail Randomley #2508

Closed YoussefHachicha closed 1 month ago

YoussefHachicha commented 1 month ago

Describe the bug I'm fetching images from an API, downloading them to internal storage, and then using Coil3 to display them. However, some images randomly appear blank (there is no issue with the image itself, coil fails to load the image), the images URLs are fetched from the API then downloaded to the internal storage then displayed by coil.

Stacktrace this is what the debugger shows Failed to create image decoder with message 'unimplemented'. Input contained an error.

this is what one of the images requests looks like:

ImageRequest(
    context = packageName.activities.AppActivity@dc8156a,
    data = /data/user/0/packageName/files/images/https___www.dropbox.com_scl_fi_tp3vnv117uncyp7ga0rgx_page337.png,
    target = coil3.compose.AsyncImagePainter$updateRequest$$inlined$target$default$1@76c5374,
    listener = null,
    memoryCacheKey = null,
    memoryCacheKeyExtras = {},
    diskCacheKey = null,
    fileSystem = NioSystemFileSystem,
    fetcherFactory = null,
    decoderFactory = null,
    interceptorDispatcher = Dispatchers.Unconfined,
    fetcherDispatcher = Dispatchers.IO,
    decoderDispatcher = Dispatchers.IO,
    memoryCachePolicy = ENABLED,
    diskCachePolicy = ENABLED,
    networkCachePolicy = ENABLED,
    placeholderMemoryCacheKey = null,
    placeholderFactory = coil3.util.Utils_commonKt$EMPTY_IMAGE_FACTORY$1@e61912,
    errorFactory = coil3.util.Utils_commonKt$EMPTY_IMAGE_FACTORY$1@e61912,
    fallbackFactory = coil3.util.Utils_commonKt$EMPTY_IMAGE_FACTORY$1@e61912,
    sizeResolver = coil3.compose.internal.ConstraintsSizeResolver@eb532e0,
    scale = FILL,
    precision = INEXACT,
    extras = Extras(data = {coil3.Extras$Key@c04b320=GlobalLifecycle}),
    defined = Defined(
        fileSystem = null,
        interceptorDispatcher = null,
        fetcherDispatcher = null,
        decoderDispatcher = null,
        memoryCachePolicy = null,
        diskCachePolicy = null,
        networkCachePolicy = null,
        placeholderFactory = coil3.util.Utils_commonKt$EMPTY_IMAGE_FACTORY$1@e61912,
        errorFactory = coil3.util.Utils_commonKt$EMPTY_IMAGE_FACTORY$1@e61912,
        fallbackFactory = coil3.util.Utils_commonKt$EMPTY_IMAGE_FACTORY$1@e61912,
        sizeResolver = coil3.compose.internal.ConstraintsSizeResolver@eb532e0,
        scale = FILL,
        precision = INEXACT
    ),
    defaults = Defaults(
        fileSystem = NioSystemFileSystem,
        interceptorDispatcher = Dispatchers.Unconfined,
        fetcherDispatcher = Dispatchers.IO,
        decoderDispatcher = Dispatchers.IO,
        memoryCachePolicy = ENABLED,
        diskCachePolicy = ENABLED,
        networkCachePolicy = ENABLED,
        placeholderFactory = coil3.util.Utils_commonKt$EMPTY_IMAGE_FACTORY$1@e61912,
        errorFactory = quran.ui.components.page.QuranImageKt$QuranImage$4$$ExternalSyntheticLambda4@16015b,
        fallbackFactory = coil3.util.Utils_commonKt$EMPTY_IMAGE_FACTORY$1@e61912,
        sizeResolver = RealSizeResolver(size = Size(width = Undefined, height = Undefined)),
        scale = FIT,
        precision = EXACT,
        extras = Extras(data = {})
    )
)

To Reproduce I don't know how to reproduce this it usually happens randomly, I believe it usually happens when I am cancelling the job of getting a certain image or something like that.

Current Solution My current solution is to redownload the image again.

Version kotlin = "2.0.20" compose-plugin = "1.7.0-alpha02" coil = "3.0.0-alpha07"

this happens both on Android and Ios

colinrtwhite commented 1 month ago

Sorry this issue isn't actionable without a way to reproduce the issue. Failed to create image decoder with message 'unimplemented'. Input contained an error. generally indicates that that image data is malformed and can't be decoded. Either the image data is being downloaded malformed or it's becoming malformed while saving it to disk.

colinrtwhite commented 1 month ago

@YoussefHachicha Please interact with positive intent. Coil gets a lot of incoming issues and it's not possible for me to deeply investigate each issue - especially when it's not possible to reproduce the issue. I maintain Coil in my spare time for free. Coil's code is open source so it should be possible for you to debug the issue and submit a fix if this is high priority for you.