sketch icon indicating copy to clipboard operation
sketch copied to clipboard

SVG Tint/Color Filter Bug in Lazy List

Open philipkraeutl opened this issue 4 months ago • 2 comments

Describe the bug

When scrolling lists that render images with sketch-compose (in Compose Multiplatform), the provided ColorFilter is not consistently applied.

Versions

  • sketch version*: 4.4.0-alpha01
  • Kotlin version*: 2.1.21
  • Compose version(s)*: 1.9.0-alpha02 (org.jetbrains.compose-plugin)
  • Running Devices (*) :
    • OnePlus 7T Pro, Android

Sample code Simpliefied Example:

LazyRow(Modifier.fillMaxWidth()) { 
        items(urls){ url ->
            AsyncImage(
                request = ComposableImageRequest(url) {
                    crossfade(durationMillis = 10, alwaysUse = true)
                    resizeOnDraw(false)
                    if (!url.contains(".svg")) {
                        precision(Precision.EXACTLY)
                    }
                    components {
                        supportSvg()
                    }
                }, contentDescription = "Test",
                modifier = Modifier.size(32.dp),
                contentScale = ContentScale.Fit,
                alignment = Alignment.Center,
                colorFilter = ColorFilter.tint(Color.White),
            )
            
        }
    }

Reproduction steps

  1. Open a screen rendering a LazyRow with ~20 SVG images loaded from the network.
  2. Scroll slowly left/right: occasionally, a row item shows the SVG in original colors (no tint).
  3. Scroll quickly: the tint is not applied for most or all visible SVGs.
  4. After minor scroll/jitter, some items may appear with tint again.

Expected behavior

The provided ColorFilter should be applied consistently to every item, independent of scroll speed or list orientation.

Screenshots

https://github.com/user-attachments/assets/fb2db1fc-6f47-4048-88ae-58f045ba10f6

philipkraeutl avatar Sep 02 '25 07:09 philipkraeutl

Important Update:

The issue is tied to crossfade. With crossfade disabled (e.g., crossfade(false)), the tint is applied consistently and everything works as expected. I’m fine proceeding without crossfade, so this is resolved on my end. Leaving this note in case the maintainers want to investigate the crossfade interaction further.

philipkraeutl avatar Sep 02 '25 11:09 philipkraeutl

This is a bug, I have fixed it and it will be released in the next version.

panpf avatar Sep 10 '25 12:09 panpf