Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Crash when trying to mix window visibility and undecorated state on Windows #1652

Closed
NoUsername opened this issue Dec 30, 2021 · 1 comment
Closed

Comments

@NoUsername
Copy link

This example reproduces the issue:

fun main() = application {
    var isVisible by remember { mutableStateOf(false) }
    Window(onCloseRequest = ::exitApplication, visible = isVisible, undecorated = true) {
        WindowDraggableArea {
            Box(Modifier.fillMaxWidth().height(48.dp).background(Color.DarkGray))
        }
    }
}

Exception:

Exception in thread "main" java.awt.IllegalComponentStateException: The frame is displayable.
	at java.desktop/java.awt.Frame.setUndecorated(Frame.java:926)
	at androidx.compose.ui.awt.ComposeWindow.setUndecorated(ComposeWindow.desktop.kt:102)
	at androidx.compose.ui.util.Windows_desktopKt.setUndecoratedSafely(Windows.desktop.kt:137)
	at androidx.compose.ui.window.Window_desktopKt$Window$5$1$3.invoke(Window.desktop.kt:194)
	at androidx.compose.ui.window.Window_desktopKt$Window$5$1$3.invoke(Window.desktop.kt:194)
	at androidx.compose.ui.util.ComponentUpdater$UpdateScope.set(ComponentUpdater.kt:45)
	at androidx.compose.ui.window.Window_desktopKt$Window$5$1.invoke(Window.desktop.kt:194)
	at androidx.compose.ui.window.Window_desktopKt$Window$5$1.invoke(Window.desktop.kt:191)
	at androidx.compose.ui.util.ComponentUpdater.update(ComponentUpdater.kt:27)
	at androidx.compose.ui.window.Window_desktopKt$Window$5.invoke(Window.desktop.kt:191)
	at androidx.compose.ui.window.Window_desktopKt$Window$5.invoke(Window.desktop.kt:152)
	at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$3.invoke(AwtWindow.desktop.kt:88)
	at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$3.invoke(AwtWindow.desktop.kt:87)
	at androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2$performUpdate$2.invoke(UpdateEffect.desktop.kt:58)
	at androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2$performUpdate$2.invoke(UpdateEffect.desktop.kt:54)
	at androidx.compose.runtime.snapshots.Snapshot$Companion.observe(Snapshot.kt:1798)
	at androidx.compose.runtime.snapshots.SnapshotStateObserver.observeReads(SnapshotStateObserver.kt:121)
	at androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2.invoke$performUpdate(UpdateEffect.desktop.kt:54)
	at androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2.invoke(UpdateEffect.desktop.kt:62)
	at androidx.compose.ui.util.UpdateEffect_desktopKt$UpdateEffect$2.invoke(UpdateEffect.desktop.kt:47)
	at androidx.compose.runtime.DisposableEffectImpl.onRemembered(Effects.kt:81)
	at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:802)
	at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:647)
	at androidx.compose.runtime.Recomposer.composeInitial$runtime(Recomposer.kt:763)
	at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:433)
	at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2.invokeSuspend(Application.desktop.kt:179)
	at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
	at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	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:389)
	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)

Process finished with exit code 1

Trying to workaround by setting undecorated to isVisible as well (only enabling undecorated when visible) doesn't work either, as soon as the value is toggled once, the same exception appears.

@akurasov akurasov added this to the 1.0.1 milestone Dec 30, 2021
@akurasov akurasov modified the milestones: 1.0.1, 1.1 Jan 11, 2022
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Feb 17, 2022
…orated = true

window.makeDisplayable() is a default behaviour now for any AWT window, which is called only after we set all properties for the window

Fixes JetBrains/compose-multiplatform#1652
igordmn added a commit to JetBrains/compose-multiplatform-core that referenced this issue Feb 18, 2022
…orated = true

window.makeDisplayable() is a default behaviour now for any AWT window, which is called only after we set all properties for the window

Fixes JetBrains/compose-multiplatform#1652
@igordmn
Copy link
Collaborator

igordmn commented Feb 27, 2022

Should be fixed in 1.1.0

@igordmn igordmn closed this as completed Feb 27, 2022
copybara-service bot pushed a commit to androidx/androidx that referenced this issue Mar 1, 2022
Fixes JetBrains/compose-multiplatform#1794
Fixes JetBrains/compose-multiplatform#1652

If the first frame is too long to draw (> 500ms), users should make their apps asynchronous and draw UI gradually in multiple frames without blocking the UI thread for too long in single frame.

Change-Id: I3f01c963478bf23ee75e4adeb45a172b25591073
Test: ./gradlew jvmTest desktopTest -Pandroidx.compose.multiplatformEnabled=true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants