coil-kt/coil

Error image not displayed in Compose Wasm

Open

#2.786 geöffnet am 14. Jan. 2025

Auf GitHub ansehen
 (2 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Kotlin (757 Forks)batch import
help wanted

Repository-Metriken

Stars
 (11.779 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 20h 14m) (28 gemergte PRs in 30 T)

Beschreibung

Describe the bug When an URL fails to load, the "error" image is not displayed on the web target. I'm trying to test a case where I load a value like "invalid url".

image

The same code works fine on Desktop:

image

The logs show that loading the image fails, but it doesn't display the error resource:

🚨 Failed - invalid url
KotlinConfApp-ui-components-gallery-wasm-js.uninstantiated.mjs:129 IllegalStateException: Unable to create a fetcher that supports: invalid url
    at kotlin.captureStackTrace (webpack-internal:///./kotlin/KotlinConfApp-ui-components-gallery-wasm-js.uninstantiated.mjs:21:44)
    at <KotlinConfApp:ui-components-gallery>.kotlin.captureStackTrace__externalAdapter (http://localhost:8080/536236261657b35af741.wasm:wasm-function[13473]:0x3c0e80)
    at <KotlinConfApp:ui-components-gallery>.kotlin.Throwable.<init> (http://localhost:8080/536236261657b35af741.wasm:wasm-function[13463]:0x3c0cd6)
    at <KotlinConfApp:ui-components-gallery>.kotlin.Throwable.<init> (http://localhost:8080/536236261657b35af741.wasm:wasm-function[13464]:0x3c0d0f)
    at <KotlinConfApp:ui-components-gallery>.kotlin.Exception.<init> (http://localhost:8080/536236261657b35af741.wasm:wasm-function[13849]:0x3c543e)
    at <KotlinConfApp:ui-components-gallery>.kotlin.RuntimeException.<init> (http://localhost:8080/536236261657b35af741.wasm:wasm-function[13839]:0x3c5260)
    at <KotlinConfApp:ui-components-gallery>.kotlin.IllegalStateException.<init> (http://localhost:8080/536236261657b35af741.wasm:wasm-function[13854]:0x3c552d)
    at <KotlinConfApp:ui-components-gallery>.coil3.intercept.$fetchCOROUTINE$4.doResume (http://localhost:8080/536236261657b35af741.wasm:wasm-function[61530]:0x81fcde)
    at <KotlinConfApp:ui-components-gallery>.coil3.intercept.EngineInterceptor.fetch (http://localhost:8080/536236261657b35af741.wasm:wasm-function[61541]:0x8203dc)
    at <KotlinConfApp:ui-components-gallery>.coil3.intercept.$executeCOROUTINE$3.doResume (http://localhost:8080/536236261657b35af741.wasm:wasm-function[61528]:0x81f7fa)

KotlinConfApp-ui-components-gallery-wasm-js.uninstantiated.mjs:129 🚨 Failed - invalid url

Other errors produce the correct behavior, for example, trying to load "https://example.com/not-an-image.jpg" throws a CORS error and displays the error drawable as expected. Just not completely invalid strings like the one shown here.

To Reproduce

AsyncImage(
    model = "invalid url",
    contentDescription = null,
    modifier = Modifier.size(96.dp),
    placeholder = painterResource(Res.drawable.kodee_emotion_positive), // Any value could go here
    error = painterResource(Res.drawable.kodee_emotion_neutral), // Any value could go here
)

Version 3.0.3

Contributor Guide