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

Performance issue on wasm with large (2MB) images #2793

Closed
oblakr24 opened this issue Jan 20, 2025 · 6 comments
Closed

Performance issue on wasm with large (2MB) images #2793

oblakr24 opened this issue Jan 20, 2025 · 6 comments

Comments

@oblakr24
Copy link

Describe the bug
Using a standard AsyncImage with a string url, when the image itself is larger (i.e. more than 2MB), there is a very significant stutter while the image is rendered.
It happens when the image is already loaded or in cache, every time it enters composition.
Does not happen on other platforms (Android, iOS, desktop JVM).
Happens on Chrome, Safari, Firefox.

To Reproduce

@Composable
fun imageLoader(): ImageLoader {
    val ctx = LocalPlatformContext.current
    return remember {
        val defaultMemCache = MemoryCache.Builder()
            .maxSizePercent(ctx)
            .build()    

        ImageLoader(ctx).newBuilder()
            .memoryCache(defaultMemCache)
            .crossfade(true)
            .logger(
                DebugLogger()
            ).build()
    }
}

@Composable
fun UrlImage(url: String, modifier: Modifier = Modifier, contentScale: ContentScale = ContentScale.Inside) {
    AsyncImage(
        model = url,
        contentDescription = null,
        imageLoader = loader,
        modifier = modifier,
        contentScale = contentScale,
    )
}

Version
3.0.4

@colinrtwhite
Copy link
Member

colinrtwhite commented Jan 21, 2025

@oblakr24 Does the issue also occur if you render the image without Coil (i.e. from Compose resources)?

@colinrtwhite
Copy link
Member

I see the same lag in the WASM sample, however if I display the same images without Coil I also see the same lag when drawing the image. I think will likely need to be optimized inside CMP/Skiko.

@colinrtwhite colinrtwhite closed this as not planned Won't fix, can't repro, duplicate, stale Jan 25, 2025
@oblakr24
Copy link
Author

@colinrtwhite
To answer the question - yes, same stutter when loading the image from disk.
I still think this is an issue, where should it be submitted then? I think this is quite significant for web projects.

The wasm sample above also stutters heavily on a top-spec M3 Max MBP, so I think this is definitely something to be tracked in the right place.

@mipastgt
Copy link

I'd report it without Coil on Jetbrains Youtrack for Compose and see what happens.

@colinrtwhite
Copy link
Member

@oblakr24 Yep your best bet it to file an issue with Compose Multiplatform or likely the Skiko issue tracker. Skiko is the library that Coil and Compose Multiplatform use to render the images.

@oblakr24
Copy link
Author

Reported on Skiko issue tracker:
SKIKO-998 Performance issue when rendering larger images (2MB) on WASM

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

3 participants