Skip to content

[Desktop/Skiko] NoSuchMethodError: org.jetbrains.skia.Image.encodeToData in SkiaBitmapImageSerializer with Compose Multiplatform 1.12+ / Skiko #295

Description

@maicol07

Describe the bug
On Desktop JVM target, loading remote images with default settings crashes when ResultCacheInterceptor executes SkiaBitmapImageSerializer.compress(). It throws java.lang.NoSuchMethodError because Skiko's org.jetbrains.skia.Image.encodeToData method signature has changed in recent Skiko/Compose Multiplatform releases.

Versions

  • sketch version*: 4.6.0
  • Kotlin version*: 2.4.10
  • Compose version(s)*: 1.12.0-beta02
  • Running Devices (*) (Model, OS, CPU Architecture, JDK.):
    • Windows 11; x86_64; JDK 21

Sample code

SubcomposeAsyncImage(
    ComposableImageRequest("https://example.com/image.png") {
        crossfade()
    },
    contentDescription = "Test Image"
)

Reproduction steps

  1. Run a Compose Multiplatform app on Desktop JVM with Compose 1.12+ and Sketch 4.6.0.
  2. Load any remote HTTP/HTTPS image using SubcomposeAsyncImage or rememberAsyncImageState with ResultCache enabled (default).
  3. Once the image is fetched and ResultCacheInterceptor attempts to write the cache to disk via SkiaBitmapImageSerializer.compress(), the app crashes with NoSuchMethodError.

Expected behavior
The image should be compressed and cached to ResultCache on Desktop without throwing a NoSuchMethodError on org.jetbrains.skia.Image.encodeToData.

Additional context
Stacktrace:

java.lang.NoSuchMethodError: 'org.jetbrains.skia.Data org.jetbrains.skia.Image.encodeToData(org.jetbrains.skia.EncodedImageFormat, int)'
    at com.github.panpf.sketch.cache.SkiaBitmapImageSerializer.compress(ImageSerializer.nonAndroid.kt:54)
    at com.github.panpf.sketch.cache.internal.ResultCacheInterceptor.writeCache(ResultCacheInterceptor.kt:145)
    at com.github.panpf.sketch.cache.internal.ResultCacheInterceptor.access$writeCache(ResultCacheInterceptor.kt:44)
    at com.github.panpf.sketch.cache.internal.ResultCacheInterceptor$intercept$2$1.invokeSuspend(ResultCacheInterceptor.kt:82)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:34)

Temporary Workaround
Disabling resultCachePolicy(CachePolicy.DISABLED) prevents SkiaBitmapImageSerializer.compress from being called, avoiding the crash.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions