JetBrains / compose-multiplatform

Compose Multiplatform, a modern UI framework for Kotlin that makes building performant and beautiful user interfaces easy and enjoyable.
https://jetbrains.com/lp/compose-multiplatform
Apache License 2.0
15.94k stars 1.16k forks source link

iOS DrawScope.drawRect() kotlin.IllegalArgumentException: Rect::makeLTRB expected t <= b, got NaN > NaN for zero size areas #3794

Closed chokokatana closed 7 months ago

chokokatana commented 11 months ago

Describe the bug Implementing a graph drawing component using Canvas.drawRect everything was fine until at runtime some data made iOS crash the graph inside a horizontal pager being dragged horizontally.

Affected platforms Select one of the platforms below:

The same code on Android works fine and does not crash.

Versions

To Reproduce Steps and/or the code snippet to reproduce the behavior:

  1. Have a composable use a HorizontalPager with a Canvas and draw a zero sized rectangle.
    Canvas(modifier = Modifier.fillMaxSize(1f)) {
    …
                drawRect(
                    topLeft = …,
                    color = …,
                    size = Size(1.dp.toPx(), 0f),
                )
  2. Drag the canvas so that it scrolls. For some reason it does not crash while the screen is static. Also, the dragging of the pager has to show the next screen, if I try to drag against the normal direction the current page just bounces and no crash

Dump of runtime crash stack trace:

Uncaught Kotlin exception: kotlin.IllegalArgumentException: Rect::makeLTRB expected t <= b, got NaN > NaN
    at 0   KmmLocations                        0x107a52c07        kfun:kotlin.Throwable#<init>(kotlin.String?){} + 123 
    at 1   KmmLocations                        0x107a4b8bb        kfun:kotlin.Exception#<init>(kotlin.String?){} + 119 
    at 2   KmmLocations                        0x107a4bbe7        kfun:kotlin.RuntimeException#<init>(kotlin.String?){} + 119 
    at 3   KmmLocations                        0x107a4bf13        kfun:kotlin.IllegalArgumentException#<init>(kotlin.String?){} + 119 
    at 4   KmmLocations                        0x107ec08bb        kfun:org.jetbrains.skia.Rect.Companion#makeLTRB(kotlin.Float;kotlin.Float;kotlin.Float;kotlin.Float){}org.jetbrains.skia.Rect + 1031 
    at 5   KmmLocations                        0x107f5dcbf        kfun:androidx.compose.ui.graphics.SkiaBackedCanvas#drawRect(kotlin.Float;kotlin.Float;kotlin.Float;kotlin.Float;androidx.compose.ui.graphics.Paint){} + 307 
    at 6   KmmLocations                        0x107f46787        kfun:androidx.compose.ui.graphics.drawscope.CanvasDrawScope#drawRect(androidx.compose.ui.graphics.Color;androidx.compose.ui.geometry.Offset;androidx.compose.ui.geometry.Size;kotlin.Float;androidx.compose.ui.graphics.drawscope.DrawStyle;androidx.compose.ui.graphics.ColorFilter?;androidx.compose.ui.graphics.BlendMode){} + 575 
    at 7   KmmLocations                        0x108138be7        kfun:androidx.compose.ui.node.LayoutNodeDrawScope#drawRect(androidx.compose.ui.graphics.Color;androidx.compose.ui.geometry.Offset;androidx.compose.ui.geometry.Size;kotlin.Float;androidx.compose.ui.graphics.drawscope.DrawStyle;androidx.compose.ui.graphics.ColorFilter?;androidx.compose.ui.graphics.BlendMode){} + 231 
    at 8   KmmLocations                        0x107f51827        kfun:androidx.compose.ui.graphics.drawscope.DrawScope#drawRect$default(androidx.compose.ui.graphics.Color;androidx.compose.ui.geometry.Offset?;androidx.compose.ui.geometry.Size?;kotlin.Float;androidx.compose.ui.graphics.drawscope.DrawStyle?;androidx.compose.ui.graphics.ColorFilter?;androidx.compose.ui.graphics.BlendMode?;kotlin.Int){} + 1287 
    at 9   KmmLocations                        0x1088facaf        kfun:com.geodb.wallace.kmm.ui.biomarkers.Graph$lambda$34#internal + 2975 
    at 10  KmmLocations                        0x1088fec8f        kfun:com.geodb.wallace.kmm.ui.biomarkers.$Graph$lambda$34$FUNCTION_REFERENCE$22.invoke#internal + 127 
    at 11  KmmLocations                        0x1088feddb        kfun:com.geodb.wallace.kmm.ui.biomarkers.$Graph$lambda$34$FUNCTION_REFERENCE$22.$<bridge-UNNN>invoke(androidx.compose.ui.graphics.drawscope.DrawScope){}#internal + 123 
    at 12  KmmLocations                        0x10803abab        kfun:androidx.compose.ui.draw.DrawBackgroundModifier#draw__at__androidx.compose.ui.graphics.drawscope.ContentDrawScope(){} + 271 
    at 13  KmmLocations                        0x10813b40f        kfun:androidx.compose.ui.node.LayoutNodeDrawScope#drawDirect(androidx.compose.ui.graphics.Canvas;androidx.compose.ui.geometry.Size;androidx.compose.ui.node.NodeCoordinator;androidx.compose.ui.node.DrawModifierNode){} + 1203 
    at 14  KmmLocations                        0x10813a9b3        kfun:androidx.compose.ui.node.LayoutNodeDrawScope#draw(androidx.compose.ui.graphics.Canvas;androidx.compose.ui.geometry.Size;androidx.compose.ui.node.NodeCoordinator;androidx.compose.ui.Modifier.Node){} + 875 
    at 15  KmmLocations                        0x10817402f        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 623 
    at 16  KmmLocations                        0x108173c9b        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 715 
    at 17  KmmLocations                        0x108119097        kfun:androidx.compose.ui.node.LayoutModifierNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 283 
    at 18  KmmLocations                        0x108173f83        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 451 
    at 19  KmmLocations                        0x108173c9b        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 715 
    at 20  KmmLocations                        0x1081292d7        kfun:androidx.compose.ui.node.LayoutNode#draw(androidx.compose.ui.graphics.Canvas){} + 239 
    at 21  KmmLocations                        0x10810e6a3        kfun:androidx.compose.ui.node.InnerNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 679 
    at 22  KmmLocations                        0x108173f83        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 451 
    at 23  KmmLocations                        0x108173c9b        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 715 
    at 24  KmmLocations                        0x108119097        kfun:androidx.compose.ui.node.LayoutModifierNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 283 
    at 25  KmmLocations                        0x108173f83        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 451 
    at 26  KmmLocations                        0x108173c9b        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 715 
    at 27  KmmLocations                        0x108119097        kfun:androidx.compose.ui.node.LayoutModifierNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 283 
    at 28  KmmLocations                        0x108173f83        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 451 
    at 29  KmmLocations                        0x108173c9b        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 715 
    at 30  KmmLocations                        0x1081292d7        kfun:androidx.compose.ui.node.LayoutNode#draw(androidx.compose.ui.graphics.Canvas){} + 239 
    at 31  KmmLocations                        0x10810e6a3        kfun:androidx.compose.ui.node.InnerNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 679 
    at 32  KmmLocations                        0x108173f83        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 451 
    at 33  KmmLocations                        0x108173c9b        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 715 
    at 34  KmmLocations                        0x108119097        kfun:androidx.compose.ui.node.LayoutModifierNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 283 
    at 35  KmmLocations                        0x108173f83        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 451 
    at 36  KmmLocations                        0x1081812e7        kfun:androidx.compose.ui.node.NodeCoordinator.invoke$lambda$2#internal + 195 
    at 37  KmmLocations                        0x1081820c3        kfun:androidx.compose.ui.node.NodeCoordinator.$invoke$lambda$2$FUNCTION_REFERENCE$2.invoke#internal + 99 
    at 38  KmmLocations                        0x108182217        kfun:androidx.compose.ui.node.NodeCoordinator.$invoke$lambda$2$FUNCTION_REFERENCE$2.$<bridge-UNN>invoke(){}#internal + 95 
    at 39  KmmLocations                        0x107d73537        kfun:androidx.compose.runtime.snapshots.Snapshot.Companion#observe(kotlin.Function1<kotlin.Any,kotlin.Unit>?;kotlin.Function1<kotlin.Any,kotlin.Unit>?;kotlin.Function0<0:0>){0§<kotlin.Any?>}0:0 + 1179 
    at 40  KmmLocations                        0x107db241f        kfun:androidx.compose.runtime.snapshots.SnapshotStateObserver.ObservedScopeMap.observe#internal + 855 
    at 41  KmmLocations                        0x107daf8eb        kfun:androidx.compose.runtime.snapshots.SnapshotStateObserver#observeReads(0:0;kotlin.Function1<0:0,kotlin.Unit>;kotlin.Function0<kotlin.Unit>){0§<kotlin.Any>} + 699 
    at 42  KmmLocations                        0x10818c4d7        kfun:androidx.compose.ui.node.OwnerSnapshotObserver#observeReads(0:0;kotlin.Function1<0:0,kotlin.Unit>;kotlin.Function0<kotlin.Unit>){0§<androidx.compose.ui.node.OwnerScope>} + 247 
    at 43  KmmLocations                        0x108174efb        kfun:androidx.compose.ui.node.NodeCoordinator#invoke(androidx.compose.ui.graphics.Canvas){} + 491 
    at 44  KmmLocations                        0x1081810bf        kfun:androidx.compose.ui.node.NodeCoordinator.<init>$lambda$0#internal + 211 
    at 45  KmmLocations                        0x108181d53        kfun:androidx.compose.ui.node.NodeCoordinator.$<init>$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 123 
    at 46  KmmLocations                        0x108181e83        kfun:androidx.compose.ui.node.NodeCoordinator.$<init>$lambda$0$FUNCTION_REFERENCE$0.$<bridge-UNNN>invoke(androidx.compose.ui.graphics.Canvas){}#internal + 123 
    at 47  KmmLocations                        0x1081e0427        kfun:androidx.compose.ui.platform.RenderNodeLayer.performDrawLayer#internal + 2547 
    at 48  KmmLocations                        0x1081df4a7        kfun:androidx.compose.ui.platform.RenderNodeLayer#drawLayer(androidx.compose.ui.graphics.Canvas){} + 543 
    at 49  KmmLocations                        0x108173b53        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 387 
    at 50  KmmLocations                        0x1081292d7        kfun:androidx.compose.ui.node.LayoutNode#draw(androidx.compose.ui.graphics.Canvas){} + 239 
    at 51  KmmLocations                        0x10810e6a3        kfun:androidx.compose.ui.node.InnerNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 679 
    at 52  KmmLocations                        0x108173f83        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 451 
    at 53  KmmLocations                        0x1081812e7        kfun:androidx.compose.ui.node.NodeCoordinator.invoke$lambda$2#internal + 195 
    at 54  KmmLocations                        0x1081820c3        kfun:androidx.compose.ui.node.NodeCoordinator.$invoke$lambda$2$FUNCTION_REFERENCE$2.invoke#internal + 99 
    at 55  KmmLocations                        0x108182217        kfun:androidx.compose.ui.node.NodeCoordinator.$invoke$lambda$2$FUNCTION_REFERENCE$2.$<bridge-UNN>invoke(){}#internal + 95 
    at 56  KmmLocations                        0x107d73537        kfun:androidx.compose.runtime.snapshots.Snapshot.Companion#observe(kotlin.Function1<kotlin.Any,kotlin.Unit>?;kotlin.Function1<kotlin.Any,kotlin.Unit>?;kotlin.Function0<0:0>){0§<kotlin.Any?>}0:0 + 1179 
    at 57  KmmLocations                        0x107db241f        kfun:androidx.compose.runtime.snapshots.SnapshotStateObserver.ObservedScopeMap.observe#internal + 855 
    at 58  KmmLocations                        0x107daf8eb        kfun:androidx.compose.runtime.snapshots.SnapshotStateObserver#observeReads(0:0;kotlin.Function1<0:0,kotlin.Unit>;kotlin.Function0<kotlin.Unit>){0§<kotlin.Any>} + 699 
    at 59  KmmLocations                        0x10818c4d7        kfun:androidx.compose.ui.node.OwnerSnapshotObserver#observeReads(0:0;kotlin.Function1<0:0,kotlin.Unit>;kotlin.Function0<kotlin.Unit>){0§<androidx.compose.ui.node.OwnerScope>} + 247 
    at 60  KmmLocations                        0x108174efb        kfun:androidx.compose.ui.node.NodeCoordinator#invoke(androidx.compose.ui.graphics.Canvas){} + 491 
    at 61  KmmLocations                        0x1081810bf        kfun:androidx.compose.ui.node.NodeCoordinator.<init>$lambda$0#internal + 211 
    at 62  KmmLocations                        0x108181d53        kfun:androidx.compose.ui.node.NodeCoordinator.$<init>$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 123 
    at 63  KmmLocations                        0x108181e83        kfun:androidx.compose.ui.node.NodeCoordinator.$<init>$lambda$0$FUNCTION_REFERENCE$0.$<bridge-UNNN>invoke(androidx.compose.ui.graphics.Canvas){}#internal + 123 
    at 64  KmmLocations                        0x1081e0427        kfun:androidx.compose.ui.platform.RenderNodeLayer.performDrawLayer#internal + 2547 
    at 65  KmmLocations                        0x1081df4a7        kfun:androidx.compose.ui.platform.RenderNodeLayer#drawLayer(androidx.compose.ui.graphics.Canvas){} + 543 
    at 66  KmmLocations                        0x108173b53        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 387 
    at 67  KmmLocations                        0x108119097        kfun:androidx.compose.ui.node.LayoutModifierNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 283 
    at 68  KmmLocations                        0x108173f83        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 451 
    at 69  KmmLocations                        0x1081812e7        kfun:androidx.compose.ui.node.NodeCoordinator.invoke$lambda$2#internal + 195 
    at 70  KmmLocations                        0x1081820c3        kfun:androidx.compose.ui.node.NodeCoordinator.$invoke$lambda$2$FUNCTION_REFERENCE$2.invoke#internal + 99 
    at 71  KmmLocations                        0x108182217        kfun:androidx.compose.ui.node.NodeCoordinator.$invoke$lambda$2$FUNCTION_REFERENCE$2.$<bridge-UNN>invoke(){}#internal + 95 
    at 72  KmmLocations                        0x107d73537        kfun:androidx.compose.runtime.snapshots.Snapshot.Companion#observe(kotlin.Function1<kotlin.Any,kotlin.Unit>?;kotlin.Function1<kotlin.Any,kotlin.Unit>?;kotlin.Function0<0:0>){0§<kotlin.Any?>}0:0 + 1179 
    at 73  KmmLocations                        0x107db241f        kfun:androidx.compose.runtime.snapshots.SnapshotStateObserver.ObservedScopeMap.observe#internal + 855 
    at 74  KmmLocations                        0x107daf8eb        kfun:androidx.compose.runtime.snapshots.SnapshotStateObserver#observeReads(0:0;kotlin.Function1<0:0,kotlin.Unit>;kotlin.Function0<kotlin.Unit>){0§<kotlin.Any>} + 699 
    at 75  KmmLocations                        0x10818c4d7        kfun:androidx.compose.ui.node.OwnerSnapshotObserver#observeReads(0:0;kotlin.Function1<0:0,kotlin.Unit>;kotlin.Function0<kotlin.Unit>){0§<androidx.compose.ui.node.OwnerScope>} + 247 
    at 76  KmmLocations                        0x108174efb        kfun:androidx.compose.ui.node.NodeCoordinator#invoke(androidx.compose.ui.graphics.Canvas){} + 491 
    at 77  KmmLocations                        0x1081810bf        kfun:androidx.compose.ui.node.NodeCoordinator.<init>$lambda$0#internal + 211 
    at 78  KmmLocations                        0x108181d53        kfun:androidx.compose.ui.node.NodeCoordinator.$<init>$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 123 
    at 79  KmmLocations                        0x108181e83        kfun:androidx.compose.ui.node.NodeCoordinator.$<init>$lambda$0$FUNCTION_REFERENCE$0.$<bridge-UNNN>invoke(androidx.compose.ui.graphics.Canvas){}#internal + 123 
    at 80  KmmLocations                        0x1081e0427        kfun:androidx.compose.ui.platform.RenderNodeLayer.performDrawLayer#internal + 2547 
    at 81  KmmLocations                        0x1081df4a7        kfun:androidx.compose.ui.platform.RenderNodeLayer#drawLayer(androidx.compose.ui.graphics.Canvas){} + 543 
    at 82  KmmLocations                        0x108173b53        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 387 
    at 83  KmmLocations                        0x108119097        kfun:androidx.compose.ui.node.LayoutModifierNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 283 
    at 84  KmmLocations                        0x108173f83        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 451 
    at 85  KmmLocations                        0x108173c9b        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 715 
    at 86  KmmLocations                        0x108119097        kfun:androidx.compose.ui.node.LayoutModifierNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 283 
    at 87  KmmLocations                        0x108173f83        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 451 
    at 88  KmmLocations                        0x108173c9b        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 715 
    at 89  KmmLocations                        0x108119097        kfun:androidx.compose.ui.node.LayoutModifierNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 283 
    at 90  KmmLocations                        0x108173f83        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 451 
    at 91  KmmLocations                        0x108173c9b        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 715 
    at 92  KmmLocations                        0x1081292d7        kfun:androidx.compose.ui.node.LayoutNode#draw(androidx.compose.ui.graphics.Canvas){} + 239 
    at 93  KmmLocations                        0x10810e6a3        kfun:androidx.compose.ui.node.InnerNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 679 
    at 94  KmmLocations                        0x108173f83        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 451 
    at 95  KmmLocations                        0x1081812e7        kfun:androidx.compose.ui.node.NodeCoordinator.invoke$lambda$2#internal + 195 
    at 96  KmmLocations                        0x1081820c3        kfun:androidx.compose.ui.node.NodeCoordinator.$invoke$lambda$2$FUNCTION_REFERENCE$2.invoke#internal + 99 
    at 97  KmmLocations                        0x108182217        kfun:androidx.compose.ui.node.NodeCoordinator.$invoke$lambda$2$FUNCTION_REFERENCE$2.$<bridge-UNN>invoke(){}#internal + 95 
    at 98  KmmLocations                        0x107d73537        kfun:androidx.compose.runtime.snapshots.Snapshot.Companion#observe(kotlin.Function1<kotlin.Any,kotlin.Unit>?;kotlin.Function1<kotlin.Any,kotlin.Unit>?;kotlin.Function0<0:0>){0§<kotlin.Any?>}0:0 + 1179 
    at 99  KmmLocations                        0x107db241f        kfun:androidx.compose.runtime.snapshots.SnapshotStateObserver.ObservedScopeMap.observe#internal + 855 
    at 100 KmmLocations                        0x107daf8eb        kfun:androidx.compose.runtime.snapshots.SnapshotStateObserver#observeReads(0:0;kotlin.Function1<0:0,kotlin.Unit>;kotlin.Function0<kotlin.Unit>){0§<kotlin.Any>} + 699 
    at 101 KmmLocations                        0x10818c4d7        kfun:androidx.compose.ui.node.OwnerSnapshotObserver#observeReads(0:0;kotlin.Function1<0:0,kotlin.Unit>;kotlin.Function0<kotlin.Unit>){0§<androidx.compose.ui.node.OwnerScope>} + 247 
    at 102 KmmLocations                        0x108174efb        kfun:androidx.compose.ui.node.NodeCoordinator#invoke(androidx.compose.ui.graphics.Canvas){} + 491 
    at 103 KmmLocations                        0x1081810bf        kfun:androidx.compose.ui.node.NodeCoordinator.<init>$lambda$0#internal + 211 
    at 104 KmmLocations                        0x108181d53        kfun:androidx.compose.ui.node.NodeCoordinator.$<init>$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 123 
    at 105 KmmLocations                        0x108181e83        kfun:androidx.compose.ui.node.NodeCoordinator.$<init>$lambda$0$FUNCTION_REFERENCE$0.$<bridge-UNNN>invoke(androidx.compose.ui.graphics.Canvas){}#internal + 123 
    at 106 KmmLocations                        0x1081e0427        kfun:androidx.compose.ui.platform.RenderNodeLayer.performDrawLayer#internal + 2547 
    at 107 KmmLocations                        0x1081df4a7        kfun:androidx.compose.ui.platform.RenderNodeLayer#drawLayer(androidx.compose.ui.graphics.Canvas){} + 543 
    at 108 KmmLocations                        0x108173b53        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 387 
    at 109 KmmLocations                        0x108119097        kfun:androidx.compose.ui.node.LayoutModifierNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 283 
    at 110 KmmLocations                        0x108173f83        kfun:androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers#internal + 451 
    at 111 KmmLocations                        0x1081812e7        kfun:androidx.compose.ui.node.NodeCoordinator.invoke$lambda$2#internal + 195 
    at 112 KmmLocations                        0x1081820c3        kfun:androidx.compose.ui.node.NodeCoordinator.$invoke$lambda$2$FUNCTION_REFERENCE$2.invoke#internal + 99 
    at 113 KmmLocations                        0x108182217        kfun:androidx.compose.ui.node.NodeCoordinator.$invoke$lambda$2$FUNCTION_REFERENCE$2.$<bridge-UNN>invoke(){}#internal + 95 
    at 114 KmmLocations                        0x107d73537        kfun:androidx.compose.runtime.snapshots.Snapshot.Companion#observe(kotlin.Function1<kotlin.Any,kotlin.Unit>?;kotlin.Function1<kotlin.Any,kotlin.Unit>?;kotlin.Function0<0:0>){0§<kotlin.Any?>}0:0 + 1179 
    at 115 KmmLocations                        0x107db241f        kfun:androidx.compose.runtime.snapshots.SnapshotStateObserver.ObservedScopeMap.observe#internal + 855 
    at 116 KmmLocations                        0x107daf8eb        kfun:androidx.compose.runtime.snapshots.SnapshotStateObserver#observeReads(0:0;kotlin.Function1<0:0,kotlin.Unit>;kotlin.Function0<kotlin.Unit>){0§<kotlin.Any>} + 699 
    at 117 KmmLocations                        0x10818c4d7        kfun:androidx.compose.ui.node.OwnerSnapshotObserver#observeReads(0:0;kotlin.Function1<0:0,kotlin.Unit>;kotlin.Function0<kotlin.Unit>){0§<androidx.compose.ui.node.OwnerScope>} + 247 
    at 118 KmmLocations                        0x108174efb        kfun:androidx.compose.ui.node.NodeCoordinator#invoke(androidx.compose.ui.graphics.Canvas){} + 491 
    at 119 KmmLocations                        0x1081810bf        kfun:androidx.compose.ui.node.NodeCoordinator.<init>$lambda$0#internal + 211 
    at 120 KmmLocations                        0x108181d53        kfun:androidx.compose.ui.node.NodeCoordinator.$<init>$lambda$0$FUNCTION_REFERENCE$0.invoke#internal + 123 
    at 121 KmmLocations                        0x108181e83        kfun:androidx.compose.ui.node.NodeCoordinator.$<init>$lambda$0$FUNCTION_REFERENCE$0.$<bridge-UNNN>invoke(androidx.compose.ui.graphics.Canvas){}#internal + 123 
    at 122 KmmLocations                        0x1081e0427        kfun:androidx.compose.ui.platform.RenderNodeLayer.performDrawLayer#internal + 2547 
    at 123 KmmLocations                        0x1081df4a7        kfun:androidx.compose.ui.platform.RenderNodeLayer#drawLayer(androidx.compose.ui.graphics.Canvas){} + 543 
    at 124 KmmLocations                        0x108173b53        kfun:androidx.compose.ui.node.NodeCoordinator#draw(androidx.compose.ui.graphics.Canvas){} + 387 
    at 125 KmmLocations                        0x108119097        kfun:androidx.compose.ui.node.LayoutModifierNodeCoordinator#performDraw(androidx.compose.ui.graphics.Canvas){} + 283 
Signal: SIGABRT (signal SIGABRT)

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

Expected behavior After debugging the issue and finding out that the problem is a zero sized rect, the only expected behavior would be that iOS does not crash like Android. Or if this is bad, maybe make the android version assert the input size so it can be caught earlier during development?

alexzhirkevich commented 11 months ago

+1. I also have a lot of such crashes, but i was not able to find a reason. Sems like pager with Modifier.drawBehind on page also causes this crash sometimes

chokokatana commented 11 months ago

The bug is elusive, tried to isolate it with the following code, but this doesn't crash despite having similar widget hierarchy as my real app:

@OptIn(ExperimentalFoundationApi::class)
@Composable
fun BugComposeScreen(
    backClick: Block,
) {

    val pagerState = rememberPagerState(
        initialPage = 0,
        initialPageOffsetFraction = 0f
    ) {
        4
    }
    Surface(
        modifier = Modifier.fillMaxSize(),
        color = MaterialTheme.colorScheme.background
    ) {
        Column(
            modifier = Modifier.verticalScroll(rememberScrollState()),
            verticalArrangement = Arrangement.Bottom
        ) {
            Spacer(Modifier.height(20.dp))

            Button(onClick = backClick) { Text(text = "Back") }

            Spacer(Modifier.height(10.dp))

            Text(text = "This is the second")

            HorizontalPager(
                state = pagerState,
                modifier = Modifier
                    .fillMaxWidth()
                    .height(294.dp)
                    .background(Color.Blue),
                pageSpacing = 8.dp,
            ) { pageIndex ->
                Card(pageIndex)
            }
        }
    }
}

@Composable
private fun Card(
    index: Int,
) {
    Column(
        modifier = Modifier.padding(start = 34.dp, end = 34.dp)
    ) {
        Canvas(modifier = Modifier.fillMaxSize(1f).background(Color.Black)) {

            drawRect(
                topLeft = Offset(
                    x = 0f,
                    y = 10f,
                ),
                color = Color.DarkGray,
                size = Size(1.dp.toPx(), 0f),
            )
            drawRect(
                topLeft = Offset(
                    x = index * 100f,
                    y = 10f,
                ),
                color = Color.White,
                size = Size(1.dp.toPx(), index * 10f),
            )
        }
    }
}
alexzhirkevich commented 11 months ago

I don't even draw zero sized rects. It happens randomly after a fast fling or navigation transition. And it not always NaN > NaN. Sometimes it is normal numbers. This was from the early experimental iOS Compose. Now this happens much less often.

elijah-semyonov commented 11 months ago

Hi, thanks for the report. Sadly, I fail to reproduce it. From code analysis, it seems that topLeft alone and/or size have NaNs here when the crash happens. But it's hard to pinpoint the exact source of a problem without investigating a reliable repro.

And I'm not sure whether we should do early exit on NaNs in skia layer instead of throwing exception here, because it could actually mask the problem that could affect something else.

okushnikov commented 3 weeks ago

Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.