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.17k stars 1.11k forks source link

Cannot boot for Desktop after upgrade to 1.6.10* #4816

Closed touchnotes closed 1 month ago

touchnotes commented 1 month ago

After upgrade from 1.6.0 to 1.6.10(I try 1.6.2, and it works well). The application run with below error:

5月 16, 2024 4:10:38 下午 com.sun.javafx.application.PlatformImpl startup
警告: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @534bf26d'
Exception in thread "main" java.lang.IllegalStateException: Method setCurrentState must be called on the main thread
    at androidx.lifecycle.LifecycleRegistry.enforceMainThreadIfNeeded(LifecycleRegistry.jvm.kt:302)
    at androidx.lifecycle.LifecycleRegistry.setCurrentState(LifecycleRegistry.jvm.kt:106)
    at androidx.compose.ui.scene.ComposeContainer.updateLifecycleState(ComposeContainer.desktop.kt:436)
    at androidx.compose.ui.scene.ComposeContainer.onChangeWindowFocus(ComposeContainer.desktop.kt:216)
    at androidx.compose.ui.scene.ComposeContainer.setWindow(ComposeContainer.desktop.kt:297)
    at androidx.compose.ui.scene.ComposeContainer.<init>(ComposeContainer.desktop.kt:164)
    at androidx.compose.ui.scene.ComposeContainer.<init>(ComposeContainer.desktop.kt:82)
    at androidx.compose.ui.awt.ComposeWindowPanel.<init>(ComposeWindowPanel.desktop.kt:56)
    at androidx.compose.ui.awt.ComposeWindow.<init>(ComposeWindow.desktop.kt:65)
    at androidx.compose.ui.awt.ComposeWindow.<init>(ComposeWindow.desktop.kt:63)
    at androidx.compose.ui.window.Window_desktopKt$Window$3.invoke(Window.desktop.kt:182)
    at androidx.compose.ui.window.Window_desktopKt$Window$3.invoke(Window.desktop.kt:176)
    at androidx.compose.ui.window.Window_desktopKt$Window$10.invoke(Window.desktop.kt:409)
    at androidx.compose.ui.window.Window_desktopKt$Window$10.invoke(Window.desktop.kt:406)
    at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$2.invoke(AwtWindow.desktop.kt:70)
    at androidx.compose.ui.window.AwtWindow_desktopKt$AwtWindow$2.invoke(AwtWindow.desktop.kt:69)
    at androidx.compose.runtime.DisposableEffectImpl.onRemembered(Effects.kt:82)
    at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1295)
    at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:984)
    at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:1005)
    at androidx.compose.runtime.Recomposer.composeInitial$runtime(Recomposer.kt:1099)
    at androidx.compose.runtime.CompositionImpl.composeInitial(Composition.kt:633)
    at androidx.compose.runtime.CompositionImpl.setContent(Composition.kt:619)
    at androidx.compose.ui.window.Application_desktopKt$awaitApplication$2$1$2.invokeSuspend(Application.desktop.kt:221)
    at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
    at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:104)
    at java.desktop/java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.desktop/java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
    at java.desktop/java.awt.EventQueue$3.run(Unknown Source)
    at java.base/java.security.AccessController.doPrivileged(Unknown Source)
    at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(Unknown Source)
    at java.desktop/java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.desktop/java.awt.EventDispatchThread.run(Unknown Source)

I tried to remove the code in main.kt and only run the following small piece of code, but the same issue still exists.

fun main() = application {
    Window(
        onCloseRequest = ::exitApplication,
        title = "Demo",
    ) {
        MaterialTheme {
            Text("123")
        }
    }
}

Versions

eymar commented 1 month ago

Using the same JDK (jbr 17.0.7) version on macos and the provided snippet doesn't reproduce the issue in my case.

Do you think there could be other required things to reproduce?

touchnotes commented 1 month ago

Create a new demo is work well, But for my old project, it reproduce the issue. I guess it is related to the integration of some libraries that I have done.

eymar commented 1 month ago

Got it! If you find any details to add which would help to reproduce the issue, feel free to reopen the issue :)

touchnotes commented 1 month ago

After add implementation("io.github.kevinnzou:compose-webview-multiplatform:1.2.0"), application reproduce the issue. compose-webview-multiplatform:1.9.7 works well, But 1.9.7 need to download kcef-bundle before show webview.