takahirom / roborazzi

Make JVM Android integration test visible 🤖📸
https://takahirom.github.io/roborazzi/
Apache License 2.0
695 stars 29 forks source link

"Can't wrap nullptr" thrown from within skiko in compose jvm desktop test when using dialogs #244

Open ZacSweers opened 8 months ago

ZacSweers commented 8 months ago

Repro: https://github.com/slackhq/circuit/pull/1121

Version: 1.9.0-alpha-4

File: circuitx/overlays/src/jvmTest/kotlin/com/slack/circuitx/overlays/OverlaySnapshotTests.kt

Trace:

java.lang.RuntimeException: Can't wrap nullptr
    at org.jetbrains.skia.impl.Native.<init>(Native.jvm.kt:40)
    at org.jetbrains.skia.impl.Managed.<init>(Managed.jvm.kt:12)
    at org.jetbrains.skia.impl.RefCnt.<init>(RefCnt.jvm.kt:6)
    at org.jetbrains.skia.Image.<init>(Image.kt:6)
    at org.jetbrains.skia.Surface.makeImageSnapshot(Surface.kt:762)
    at androidx.compose.ui.test.SkikoComposeUiTest.captureToImage(ComposeUiTest.skikoMain.kt:343)
    at androidx.compose.ui.test.SkikoComposeUiTest.captureToImage(ComposeUiTest.skikoMain.kt:348)
    at io.github.takahirom.roborazzi.RoborazziDesktopKt.captureRoboImage(RoborazziDesktop.kt:39)
    at io.github.takahirom.roborazzi.RoborazziDesktopKt.captureRoboImage(RoborazziDesktop.kt:23)
    at io.github.takahirom.roborazzi.RoborazziDesktopKt.captureRoboImage$default(RoborazziDesktop.kt:16)
    at com.slack.circuitx.overlays.OverlaySnapshotTests$alertDialog$1.invoke(OverlaySnapshotTests.kt:62)
    at com.slack.circuitx.overlays.OverlaySnapshotTests$alertDialog$1.invoke(OverlaySnapshotTests.kt:34)
    at androidx.compose.ui.test.SkikoComposeUiTest.runTest(ComposeUiTest.skikoMain.kt:170)
    at androidx.compose.ui.test.ComposeUiTest_desktopKt.runDesktopComposeUiTest(ComposeUiTest.desktop.kt:41)
    at androidx.compose.ui.test.ComposeUiTest_desktopKt.runDesktopComposeUiTest$default(ComposeUiTest.desktop.kt:34)
    at com.slack.circuitx.overlays.OverlaySnapshotTests.alertDialog(OverlaySnapshotTests.kt:34)
takahirom commented 8 months ago

I've seen this before. It might be because you're using the window. Could you try using an inner Composable function instead? However, this may not be what you're looking for.

ZacSweers commented 8 months ago

Can you clarify what you mean by "inner composable function"?

takahirom commented 8 months ago

The inner composable function refers to taking a screenshot of the Composable function's content inside a dialog. However, I understand that this may not be what you, as the creator of a dialog display library, are looking for. When I tried it before, it was challenging to capture content from outside a Window on Desktop, so this issue might not be resolved quickly. It might be addressed as soon as a way is found to capture images per window or to effectively combine them per window.