Skip to content

Error image not displayed in Compose Wasm #2786

Open
@zsmb13

Description

@zsmb13

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    help wantedIssues that are up for grabs + are good candidates for community PRs

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions