compose-multiplatform
compose-multiplatform copied to clipboard
The "TextField" in "Dialog(){}" gets the focus and then closes the "Dialog" will cause an exception
https://user-images.githubusercontent.com/76673990/106355429-bb7d5580-6332-11eb-935a-d7b613f6ea14.mp4
Can you please post a simple project (to github or some other git repository) which demonstrates the issue so we can reproduce. The video clearly shows the problem, but we will need a way to re-create the problem on our side in order to debug.
您能否将一个简单的项目发布到github或其他git仓库中,以演示该问题,以便我们进行复制。视频清楚地显示了问题,但是我们将需要一种方法来重新创建问题以进行调试。
This problem does not exist in "0.2.0-build132", but it exists in "0.3.0-build146"


Usually, this kind of issue comes from using operations with side effects, such as closing windows from @Composable which is not supported mode of operations use smth like SideEffect { window.close(} }.
Thanks for the report!
issue comes from using operations with side effects, such as closing windows from @Composable which is not supported mode of operations use smth like SideEffect { window.close(} }.
I checked - the bug exists. In example above there is no window.close() in Composable code.
@igordmn just want to give this a bump -
I am having this exact issue and wanted to provide some more context - I am showing a dialog like this:
var showEmailDialog by remember { mutableStateOf(false) }
{...}
Button(onClick = { showEmailDialog = true }) { }
if (showEmailDialog) {
EmailDialog(customers = filteredCustomers, onDismiss = {
showEmailDialog = false
})
}
and the dialog itself is structured like this:
@Composable
fun EmailDialog(
customers: List<Customer>,
onDismiss: () -> Unit
) {
Dialog(
content = {
EmailDialogContent(customers)
},
onDismissRequest = { onDismiss() },
properties = DialogProperties(size = IntSize(1080, 900))
)
}
The EmailDialogContent has two TextFields in it, and I can open and close the dialog multiple times, until I focus one of those TextFields, at which point, closing the dialog causes the following exception:
java.lang.ArrayIndexOutOfBoundsException: Index -2 out of bounds for length 5120
Is there a workaround for this while we wait for a fix?
@jollygreenegiant could you please provide a full stack trace?
@prepor
Exception in thread "AWT-EventQueue-0 @coroutine#2" java.lang.ArrayIndexOutOfBoundsException: Index -2 out of bounds for length 5120
at androidx.compose.runtime.SlotTableKt.groupSize(SlotTable.kt:2558)
at androidx.compose.runtime.SlotTableKt.access$groupSize(SlotTable.kt:1)
at androidx.compose.runtime.SlotReader.groupSize(SlotTable.kt:596)
at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2215)
at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2499)
at androidx.compose.runtime.ComposerImpl.recompose$runtime(Composer.kt:2625)
at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:406)
at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:724)
at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:100)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:437)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:411)
at androidx.compose.runtime.BroadcastFrameClock$FrameAwaiter.resume(BroadcastFrameClock.kt:41)
at androidx.compose.runtime.BroadcastFrameClock.sendFrame(BroadcastFrameClock.kt:62)
at androidx.compose.ui.platform.DesktopOwners.onFrame(DesktopOwners.desktop.kt:114)
at androidx.compose.desktop.ComposeLayer$1.onRender(ComposeLayer.desktop.kt:123)
at org.jetbrains.skiko.SkiaLayer.update$skiko(SkiaLayer.kt:91)
at org.jetbrains.skiko.redrawer.MacOsOpenGLRedrawer$frameDispatcher$1.invokeSuspend(MacOsOpenGLRedrawer.kt:79)
at org.jetbrains.skiko.redrawer.MacOsOpenGLRedrawer$frameDispatcher$1.invoke(MacOsOpenGLRedrawer.kt)
at org.jetbrains.skiko.FrameDispatcher$job$1.invokeSuspend(FrameDispatcher.kt:32)
(Coroutine boundary)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2.invokeSuspend(Recomposer.kt:411)
at androidx.compose.runtime.Recomposer$recompositionRunner$2$2.invokeSuspend(Recomposer.kt:639)
at androidx.compose.runtime.Recomposer$recompositionRunner$2.invokeSuspend(Recomposer.kt:638)
at androidx.compose.ui.platform.DesktopOwners$2.invokeSuspend(DesktopOwners.desktop.kt:85)
(Coroutine creation stacktrace)
at kotlinx.coroutines.intrinsics.UndispatchedKt.startCoroutineUndispatched(Undispatched.kt:186)
at kotlinx.coroutines.BuildersKt.launch(Unknown Source)
at androidx.compose.ui.platform.DesktopOwners.<init>(DesktopOwners.desktop.kt:84)
at androidx.compose.desktop.ComposeLayer.<init>(ComposeLayer.desktop.kt:59)
at androidx.compose.desktop.ComposeWindow.<init>(ComposeWindow.desktop.kt:33)
at androidx.compose.desktop.AppWindow.<init>(AppWindow.desktop.kt:114)
at androidx.compose.desktop.AppWindow.<init>(AppWindow.desktop.kt)
at androidx.compose.desktop.AppWindow_desktopKt$Window$1.run(AppWindow.desktop.kt:83)
at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:316)
at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:770)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:715)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:391)
at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:740)
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)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index -2 out of bounds for length 5120
at androidx.compose.runtime.SlotTableKt.groupSize(SlotTable.kt:2558)
Caused by: java.lang.ArrayIndexOutOfBoundsException: Index -2 out of bounds for length 5120
at androidx.compose.runtime.SlotTableKt.access$groupSize(SlotTable.kt:1)
at androidx.compose.runtime.SlotReader.groupSize(SlotTable.kt:596)
at androidx.compose.runtime.ComposerImpl.recomposeToGroupEnd(Composer.kt:2215)
at androidx.compose.runtime.ComposerImpl.skipCurrentGroup(Composer.kt:2499)
at androidx.compose.runtime.ComposerImpl.recompose$runtime(Composer.kt:2625)
at androidx.compose.runtime.CompositionImpl.recompose(Composition.kt:406)
at androidx.compose.runtime.Recomposer.performRecompose(Recomposer.kt:724)
at androidx.compose.runtime.Recomposer.access$performRecompose(Recomposer.kt:100)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:437)
at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$2.invoke(Recomposer.kt:411)
at androidx.compose.runtime.BroadcastFrameClock$FrameAwaiter.resume(BroadcastFrameClock.kt:41)
at androidx.compose.runtime.BroadcastFrameClock.sendFrame(BroadcastFrameClock.kt:62)
at androidx.compose.ui.platform.DesktopOwners.onFrame(DesktopOwners.desktop.kt:114)
at androidx.compose.desktop.ComposeLayer$1.onRender(ComposeLayer.desktop.kt:123)
at org.jetbrains.skiko.SkiaLayer.update$skiko(SkiaLayer.kt:91)
at org.jetbrains.skiko.redrawer.MacOsOpenGLRedrawer$frameDispatcher$1.invokeSuspend(MacOsOpenGLRedrawer.kt:79)
at org.jetbrains.skiko.redrawer.MacOsOpenGLRedrawer$frameDispatcher$1.invoke(MacOsOpenGLRedrawer.kt)
at org.jetbrains.skiko.FrameDispatcher$job$1.invokeSuspend(FrameDispatcher.kt:32)
at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
... 13 more
Please check the following ticket on YouTrack for follow-ups to this issue. GitHub issues will be closed in the coming weeks.