Using Compose MPP 1.4.0, is anyone else experienci...
# compose-web
m
Using Compose MPP 1.4.0, is anyone else experiencing random crashes with a javascript console error in skiko of
caught RuntimeError: remainder by zero at skiko.wasm:0x28a295
? From what I can tell, there may be a low-level math bug somewhere related to shadow rendering?
I've managed to trace down one cause of this to a rather specific shadow modifier:
Copy code
.shadow(elevation = 2.dp, shape = RoundedCornerShape(topStart = 28.dp, topEnd = 28.dp))
Different elevation values don't trigger the crash. However, different shape values do. For example, this runs without an issue:
Copy code
.shadow(elevation = 2.dp, shape = RoundedCornerShape(8.dp))
We will fix it
o
m
Thanks folks! Subscribed to the bug. I may have found another circumstance that triggers this bug outside of corner rounding. If I can isolate it, I'll be sure to let you know.
Ah, I found it. This time I'm getting a similar wasm error but it's not related to the shape. The following code runs without issue of scaleX = scaleY, otherwise it crashes but only in JS - works fine on Desktop and Android.
Copy code
@Composable
fun AsymmetricScaleTester() {
    Box(
        Modifier.size(100.dp)
            .graphicsLayer(scaleX = 0.7f, scaleY = 1f)
            .shadow(elevation = 2.dp)
    )
}
The error is a divide by zero (vs the prior remainder by zero):
Copy code
skiko.wasm:0x28ab10 Uncaught RuntimeError: divide by zero
    at skiko.wasm:0x28ab10
@Dima Avdeev @Oleksandr Karpovich [JB], filed a bug on this for you with more context: https://github.com/JetBrains/compose-multiplatform/issues/3075
c
Are these issues resolved in 1.4.1? I’m seeing a similar crash now in skiko but for
Modifier.rotate
. But I have a feeling it’s not that. Is there a way to isolate what is causing Skiko crashes? Try/catches and println debugging doesn’t seem to be working initially.
o
Yes, the issue above is fixed in 1.4.1 So Modifier.rotate is probably different. Is it also "divide by zero" exception?
c
“Remainder by zero” - but I don’t actually think it’s
rotate
so trying to see how I can debug it properly to help
Right now it’s just a blind skiko runtime exception
Actually I’ve isolated it to chaining
rotate
and
shadow
- here’s the Composable that repros a
divide by zero
exception
Copy code
@Composable
fun SimpleView() {
    Box(
        modifier = Modifier
            .size(width = 360.dp, height = 360.dp)
            .rotate(-60.0f)
            .padding(42.dp)
            .shadow(elevation = 16.dp, shape = RoundedCornerShape(size = 32.dp))
            .background(color = Color.Yellow, shape = RoundedCornerShape(size = 32.dp))
    ) { }
}
o