Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error loading .svg image in Jetpack Compose for Desktop #2330

Open
jdsdhp opened this issue Jun 24, 2024 · 3 comments
Open

Error loading .svg image in Jetpack Compose for Desktop #2330

jdsdhp opened this issue Jun 24, 2024 · 3 comments

Comments

@jdsdhp
Copy link

jdsdhp commented Jun 24, 2024

Describe the bug
I am trying to load an image of type .svg in my app, but it is not allowed, and it returns an error in the onError callback. I am using Jetpack Compose for Desktop. Details are attached below.

To Reproduce

AsyncImage(
                    modifier = Modifier
                        .size(50.dp)
                        .padding(all = Paddings.tiny)
                        .clip(shape = MaterialTheme.shapes.small)
                        .border(
                            width = 2.dp,
                            color = MaterialTheme.colors.onSurface,
                            shape = MaterialTheme.shapes.small,
                        ),
                    model = workspace.avatar,
                    contentDescription = "Avatar",
                    placeholder = painterResource(Res.drawable.ic_image_placeholder),
                )

Logs/Screenshots
Error(painter=null, result=ErrorResult(image=null, request=ImageRequest(context=coil3.PlatformContext$Companion$INSTANCE$1@7a121de9, data=https://bitbucket.org/workspaces/my-company/avatar/?ts=1715362523, target=coil3.compose.AsyncImagePainter$updateRequest$$inlined$target$default$1@39b9e0d1, listener=null, memoryCacheKey=null, memoryCacheKeyExtras={}, diskCacheKey=null, fileSystem=NioSystemFileSystem, fetcherFactory=null, decoderFactory=null, interceptorDispatcher=Dispatchers.Main.immediate, fetcherDispatcher=Dispatchers.IO, decoderDispatcher=Dispatchers.IO, memoryCachePolicy=ENABLED, diskCachePolicy=ENABLED, networkCachePolicy=ENABLED, placeholderMemoryCacheKey=null, placeholderFactory=interface kotlin.jvm.functions.Function1, errorFactory=interface kotlin.jvm.functions.Function1, fallbackFactory=interface kotlin.jvm.functions.Function1, sizeResolver=coil3.compose.internal.ConstraintsSizeResolver@136a3a04, scale=FIT, precision=INEXACT, extras=Extras(data={}), defined=Defined(interceptorDispatcher=null, fetcherDispatcher=null, decoderDispatcher=null, memoryCachePolicy=null, diskCachePolicy=null, networkCachePolicy=null, placeholderFactory=interface kotlin.jvm.functions.Function1, errorFactory=interface kotlin.jvm.functions.Function1, fallbackFactory=interface kotlin.jvm.functions.Function1, sizeResolver=coil3.compose.internal.ConstraintsSizeResolver@136a3a04, scale=FIT, precision=INEXACT), defaults=Defaults(fileSystem=NioSystemFileSystem, interceptorDispatcher=Dispatchers.Main.immediate, fetcherDispatcher=Dispatchers.IO, decoderDispatcher=Dispatchers.IO, memoryCachePolicy=ENABLED, diskCachePolicy=ENABLED, networkCachePolicy=ENABLED, placeholderFactory=interface kotlin.jvm.functions.Function1, errorFactory=interface kotlin.jvm.functions.Function1, fallbackFactory=interface kotlin.jvm.functions.Function1, precision=AUTOMATIC, extras=Extras(data={coil3.Extras$Key@133df82=kotlin.Unit}))), throwable=java.lang.IllegalArgumentException: Failed to Image::makeFromEncoded))

Version

    val coilVersion = "3.0.0-alpha06"
    implementation("io.coil-kt.coil3:coil-compose:$coilVersion")
    implementation("io.coil-kt.coil3:coil-compose-core:$coilVersion")
    implementation("io.coil-kt.coil3:coil-network-ktor:$coilVersion")
    implementation("io.coil-kt.coil3:coil:$coilVersion")
@colinrtwhite
Copy link
Member

Can you post the failing image? java.lang.IllegalArgumentException: Failed to Image::makeFromEncoded) implies that the underlying Skia decoder failed to decode the image.

@jdsdhp
Copy link
Author

jdsdhp commented Jun 24, 2024

Hi @colinrtwhite, thank you for your response. Later, I did some tests with other svg files, obtaining the same reslt. I believe this is not a bug caused by this specific svg image.

workspace_code

@colinrtwhite
Copy link
Member

Does the image fail to decode when using the SVGDom class directly (see here)? If so the issue is with the underlying decoder and will need to be fixed in Skiko.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants