Zhelyazko Atanasov
11/13/2024, 2:17 PMdrawWithContent
modifier to draw the contents of the composable onto the graphics layer:
.drawWithContent {
graphicsLayer.record {
this@drawWithContent.drawContent()
}
...
}
when I run this code on Web target, it works as expected. But if I run it against desktop, I get a compile error:
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00000001284a77cc, pid=21921, tid=73991
#
# JRE version: OpenJDK Runtime Environment (21.0.4) (build 21.0.4+-12422083-b607.1)
# Java VM: OpenJDK 64-Bit Server VM (21.0.4+-12422083-b607.1, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-amd64)
# Problematic frame:
# C [libskiko-macos-x64.dylib+0x1027cc] SkPictureRecorder::finishRecordingAsPicture()+0x2c
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
JNI global refs:
JNI global refs: 132, weak refs: 6
JNI global refs memory usage: 2099, weak refs: 833
If I remove this@drawWithContent.drawContent()
and replace it with draw commands like drawRect(...)
, it works as expected. Any idea what might be wrong?Kirill Grouchnikov
11/13/2024, 5:31 PMZhelyazko Atanasov
11/13/2024, 6:03 PMdrawWithContent
to a parent and inner child composable. 🤦♂️ Removing it from the child composable fixed it. It was something like
@Composable
fun MyElement(modifier: Modifier = Modifier) {
Surface(modifier) {
Text(modifier) // Passing same modifier - big mistake! Read Copilot code carefully guys!!
}
}
val screenshotModifier = Modifier.drawWithContent {
graphicsLayer.record {
this@drawWithContent.drawContent()
}
...
}
MyElement(screenshotModifier)
P.S. I'm quite happy to see you're still in the Android area, Kiril. I remember watching your talks about your work on Google Play Store 9-10 years ago 🙂