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
16.24k stars 1.18k forks source link

DateRangePicker Crashes on RTL layouts #4250

Closed tahaak67 closed 9 months ago

tahaak67 commented 9 months ago

Describe the bug when using material 3 DateRangePicker on a right to left layout after you pick the start date if you pick an end date it crashes

Affected platforms Select one of the platforms below:

Versions

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

  1. wrap DateRangePicker implementation with a compositionLocalProvider Rtl direction as below

    import androidx.compose.material3.DatePickerDialog
    import androidx.compose.material3.DateRangePicker
    import androidx.compose.material3.ExperimentalMaterial3Api
    import androidx.compose.material3.rememberDateRangePickerState
    
        CompositionLocalProvider(LocalLayoutDirection provides  LayoutDirection.Rtl){
            val dateRangePicker = rememberDateRangePickerState()
    
            DatePickerDialog(
                onDismissRequest = {},
                dismissButton = {},
                confirmButton = {}
            ){
                DateRangePicker(
                    state = dateRangePicker
                )
            }
        }
  2. Select start then any end date after the start date

Expected behavior End date is selected and displayed on the dialog.

Screenshots

image

Additional context

kirill-grouchnikov commented 9 months ago

What's the full stack trace in the terminal?

tahaak67 commented 9 months ago

What's the full stack trace in the terminal?

Stacktrace:

Exception in thread "AWT-EventQueue-0" java.lang.IllegalArgumentException: Rect::makeLTRB expected l <= r, got 528.0 > 336.0
    at org.jetbrains.skia.Rect$Companion.makeLTRB(Rect.kt:91)
    at androidx.compose.ui.graphics.SkiaBackedCanvas.drawRect(SkiaBackedCanvas.skiko.kt:120)
    at androidx.compose.ui.graphics.drawscope.CanvasDrawScope.drawRect-n-J9OG0(CanvasDrawScope.kt:190)
    at androidx.compose.ui.node.LayoutNodeDrawScope.drawRect-n-J9OG0(LayoutNodeDrawScope.kt)
    at androidx.compose.ui.graphics.drawscope.DrawScope.drawRect-n-J9OG0$default(DrawScope.kt:407)
    at androidx.compose.material3.DateRangePickerKt.drawRangeBackground-mxwnekA(DateRangePicker.kt:725)
    at androidx.compose.material3.DatePickerKt$Month$rangeSelectionDrawModifier$1$1.invoke(DatePicker.kt:1430)
    at androidx.compose.material3.DatePickerKt$Month$rangeSelectionDrawModifier$1$1.invoke(DatePicker.kt:1428)
    at androidx.compose.ui.draw.DrawWithContentModifier.draw(DrawModifier.kt:309)
    at androidx.compose.ui.node.LayoutNodeDrawScope.drawDirect-x_KDEd0$ui(LayoutNodeDrawScope.kt:105)
    at androidx.compose.ui.node.LayoutNodeDrawScope.draw-x_KDEd0$ui(LayoutNodeDrawScope.kt:86)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:369)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:182)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutNode.draw$ui(LayoutNode.kt:922)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:182)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers(NodeCoordinator.kt:54)
    at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke(NodeCoordinator.kt:388)
    at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke(NodeCoordinator.kt:387)
    at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2300)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:471)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:234)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui(OwnerSnapshotObserver.kt:133)
    at androidx.compose.ui.node.NodeCoordinator.invoke(NodeCoordinator.kt:387)
    at androidx.compose.ui.node.NodeCoordinator$invokeOnCanvasInstance$1.invoke(NodeCoordinator.kt:204)
    at androidx.compose.ui.node.NodeCoordinator$invokeOnCanvasInstance$1.invoke(NodeCoordinator.kt:204)
    at androidx.compose.ui.platform.RenderNodeLayer.performDrawLayer(RenderNodeLayer.skiko.kt:274)
    at androidx.compose.ui.platform.RenderNodeLayer.drawLayer(RenderNodeLayer.skiko.kt:218)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353)
    at androidx.compose.ui.node.LayoutNode.draw$ui(LayoutNode.kt:922)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers(NodeCoordinator.kt:54)
    at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke(NodeCoordinator.kt:388)
    at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke(NodeCoordinator.kt:387)
    at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2300)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:471)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:234)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui(OwnerSnapshotObserver.kt:133)
    at androidx.compose.ui.node.NodeCoordinator.invoke(NodeCoordinator.kt:387)
    at androidx.compose.ui.node.NodeCoordinator$invokeOnCanvasInstance$1.invoke(NodeCoordinator.kt:204)
    at androidx.compose.ui.node.NodeCoordinator$invokeOnCanvasInstance$1.invoke(NodeCoordinator.kt:204)
    at androidx.compose.ui.platform.RenderNodeLayer.performDrawLayer(RenderNodeLayer.skiko.kt:274)
    at androidx.compose.ui.platform.RenderNodeLayer.drawLayer(RenderNodeLayer.skiko.kt:218)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:182)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutNode.draw$ui(LayoutNode.kt:922)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:182)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutNode.draw$ui(LayoutNode.kt:922)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers(NodeCoordinator.kt:54)
    at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke(NodeCoordinator.kt:388)
    at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke(NodeCoordinator.kt:387)
    at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2300)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:471)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:234)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui(OwnerSnapshotObserver.kt:133)
    at androidx.compose.ui.node.NodeCoordinator.invoke(NodeCoordinator.kt:387)
    at androidx.compose.ui.node.NodeCoordinator$invokeOnCanvasInstance$1.invoke(NodeCoordinator.kt:204)
    at androidx.compose.ui.node.NodeCoordinator$invokeOnCanvasInstance$1.invoke(NodeCoordinator.kt:204)
    at androidx.compose.ui.platform.RenderNodeLayer.performDrawLayer(RenderNodeLayer.skiko.kt:274)
    at androidx.compose.ui.platform.RenderNodeLayer.drawLayer(RenderNodeLayer.skiko.kt:218)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:182)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutNode.draw$ui(LayoutNode.kt:922)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutNode.draw$ui(LayoutNode.kt:922)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:182)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutNode.draw$ui(LayoutNode.kt:922)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutNode.draw$ui(LayoutNode.kt:922)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers(NodeCoordinator.kt:54)
    at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke(NodeCoordinator.kt:388)
    at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke(NodeCoordinator.kt:387)
    at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2300)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:471)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:234)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui(OwnerSnapshotObserver.kt:133)
    at androidx.compose.ui.node.NodeCoordinator.invoke(NodeCoordinator.kt:387)
    at androidx.compose.ui.node.NodeCoordinator$invokeOnCanvasInstance$1.invoke(NodeCoordinator.kt:204)
    at androidx.compose.ui.node.NodeCoordinator$invokeOnCanvasInstance$1.invoke(NodeCoordinator.kt:204)
    at androidx.compose.ui.platform.RenderNodeLayer.performDrawLayer(RenderNodeLayer.skiko.kt:274)
    at androidx.compose.ui.platform.RenderNodeLayer.drawLayer(RenderNodeLayer.skiko.kt:218)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:182)
    at androidx.compose.ui.node.LayoutNodeDrawScope.drawContent(LayoutNodeDrawScope.kt:66)
    at androidx.compose.foundation.BackgroundNode.draw(Background.kt:155)
    at androidx.compose.ui.node.LayoutNodeDrawScope.drawDirect-x_KDEd0$ui(LayoutNodeDrawScope.kt:105)
    at androidx.compose.ui.node.LayoutNodeDrawScope.draw-x_KDEd0$ui(LayoutNodeDrawScope.kt:86)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:369)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:182)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:182)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutNode.draw$ui(LayoutNode.kt:922)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:182)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutModifierNodeCoordinator.performDraw(LayoutModifierNodeCoordinator.kt:182)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutNode.draw$ui(LayoutNode.kt:922)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:366)
    at androidx.compose.ui.node.NodeCoordinator.access$drawContainedDrawModifiers(NodeCoordinator.kt:54)
    at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke(NodeCoordinator.kt:388)
    at androidx.compose.ui.node.NodeCoordinator$invoke$1.invoke(NodeCoordinator.kt:387)
    at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:2300)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver$ObservedScopeMap.observe(SnapshotStateObserver.kt:471)
    at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:234)
    at androidx.compose.ui.node.OwnerSnapshotObserver.observeReads$ui(OwnerSnapshotObserver.kt:133)
    at androidx.compose.ui.node.NodeCoordinator.invoke(NodeCoordinator.kt:387)
    at androidx.compose.ui.node.NodeCoordinator$invokeOnCanvasInstance$1.invoke(NodeCoordinator.kt:204)
    at androidx.compose.ui.node.NodeCoordinator$invokeOnCanvasInstance$1.invoke(NodeCoordinator.kt:204)
    at androidx.compose.ui.platform.RenderNodeLayer.performDrawLayer(RenderNodeLayer.skiko.kt:274)
    at androidx.compose.ui.platform.RenderNodeLayer.drawLayer(RenderNodeLayer.skiko.kt:218)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:353)
    at androidx.compose.ui.node.LayoutNode.draw$ui(LayoutNode.kt:922)
    at androidx.compose.ui.node.InnerNodeCoordinator.performDraw(InnerNodeCoordinator.kt:174)
    at androidx.compose.ui.node.LayoutNodeDrawScope.drawContent(LayoutNodeDrawScope.kt:66)
    at androidx.compose.ui.draw.DrawBackgroundModifier.draw(DrawModifier.kt:117)
    at androidx.compose.ui.node.LayoutNodeDrawScope.drawDirect-x_KDEd0$ui(LayoutNodeDrawScope.kt:105)
    at androidx.compose.ui.node.LayoutNodeDrawScope.draw-x_KDEd0$ui(LayoutNodeDrawScope.kt:86)
    at androidx.compose.ui.node.NodeCoordinator.drawContainedDrawModifiers(NodeCoordinator.kt:369)
    at androidx.compose.ui.node.NodeCoordinator.draw(NodeCoordinator.kt:358)
    at androidx.compose.ui.node.LayoutNode.draw$ui(LayoutNode.kt:922)
    at androidx.compose.ui.platform.SkiaBasedOwner.draw(SkiaBasedOwner.skiko.kt:352)
    at androidx.compose.ui.ComposeScene.render(ComposeScene.skiko.kt:550)
    at androidx.compose.ui.awt.ComposeBridge$skikoView$1$onRender$1.invoke(ComposeBridge.desktop.kt:178)
    at androidx.compose.ui.awt.ComposeBridge$skikoView$1$onRender$1.invoke(ComposeBridge.desktop.kt:177)
    at androidx.compose.ui.awt.ComposeBridge.catchExceptions(ComposeBridge.desktop.kt:150)
    at androidx.compose.ui.awt.ComposeBridge.access$catchExceptions(ComposeBridge.desktop.kt:64)
    at androidx.compose.ui.awt.ComposeBridge$skikoView$1.onRender(ComposeBridge.desktop.kt:177)
    at org.jetbrains.skiko.SkiaLayer.update$skiko(SkiaLayer.awt.kt:548)
    at org.jetbrains.skiko.redrawer.AWTRedrawer.update(AWTRedrawer.kt:54)
    at org.jetbrains.skiko.redrawer.MetalRedrawer$frameDispatcher$1.invokeSuspend(MetalRedrawer.kt:81)
    at org.jetbrains.skiko.redrawer.MetalRedrawer$frameDispatcher$1.invoke(MetalRedrawer.kt)
    at org.jetbrains.skiko.redrawer.MetalRedrawer$frameDispatcher$1.invoke(MetalRedrawer.kt)
    at org.jetbrains.skiko.FrameDispatcher$job$1.invokeSuspend(FrameDispatcher.kt:33)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:108)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:318)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:773)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:720)
    at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:714)
    at java.base/java.security.AccessController.doPrivileged(AccessController.java:400)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:87)
    at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:742)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
    at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)
    Suppressed: kotlinx.coroutines.internal.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@452dba34, SwingDispatcher@318b2839]

Build Analyzer results available
2:28:43 AM: Execution finished 'desktopRun -DmainClass=MainKt --quiet'.
okushnikov commented 3 months ago

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