Open marschwar opened 9 months ago
@marschwar Thanks for your feedback! Could have a try with the configuration mentioned in this reply
The app still crashes but the stack trace seems to be different. I also tried a few different JVM implementations.
@marschwar Could you attach your build.gradle
and main.kt
for desktopApp?
Thank you for looking into this. You can find the config here.
@marschwar Thank you for your information. I have reviewed the build.gradle
and main.kt
files and they seem fine to me. I have also checked the latest stack trace provided above, but I cannot find the specific error message that caused the crash. Is there any additional stack trace that you can provide?
I am sorry for the delay. I did find some information in the thread dump. I hope that is helpful to you.
#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x0000000101dfbc48, pid=76398, tid=68099
#
# JRE version: OpenJDK Runtime Environment (17.0.7) (build 17.0.7+0-17.0.7b1000.6-10550314)
# Java VM: OpenJDK 64-Bit Server VM (17.0.7+0-17.0.7b1000.6-10550314, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64)
# Problematic frame:
# V [libjvm.dylib+0x123c48] AccessInternal::PostRuntimeDispatch<G1BarrierSet::AccessBarrier<548964ull, G1BarrierSet>, (AccessInternal::BarrierType)2, 548964ull>::oop_access_barrier(void*)+0x8
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
# https://bugreport.java.com/bugreport/crash.jsp
#
--------------- S U M M A R Y ------------
Command Line: --add-opens=java.desktop/sun.awt=ALL-UNNAMED --add-opens=java.desktop/java.awt.peer=ALL-UNNAMED --add-opens=java.desktop/sun.awt=ALL-UNNAMED --add-opens=java.desktop/sun.lwawt=ALL-UNNAMED --add-opens=java.desktop/sun.lwawt.macosx=ALL-UNNAMED -Dfile.encoding=UTF-8 -Duser.country=DE -Duser.language=en -Duser.variant MainKt
Host: "MacBookPro18,1" arm64, 10 cores, 32G, Darwin 23.2.0, macOS 14.2.1 (23C71)
Time: Fri Feb 23 15:13:55 2024 CET elapsed time: 8.538802 seconds (0d 0h 0m 8s)
--------------- T H R E A D ---------------
Current thread (0x000000013b2afe00): JavaThread "AWT-EventQueue-0" [_thread_in_vm, id=68099, stack(0x0000000171cd0000,0x0000000171ed3000)]
Stack: [0x0000000171cd0000,0x0000000171ed3000], sp=0x0000000171ed1d90, free space=2055k
Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
V [libjvm.dylib+0x123c48] AccessInternal::PostRuntimeDispatch<G1BarrierSet::AccessBarrier<548964ull, G1BarrierSet>, (AccessInternal::BarrierType)2, 548964ull>::oop_access_barrier(void*)+0x8
V [libjvm.dylib+0x4d2464] jni_NewGlobalRef+0x100
C [libjcef.dylib+0x3ee28] ScopedJNIObjectGlobal::ScopedJNIObjectGlobal(JNIEnv_*, _jobject*)+0x2c
C [libjcef.dylib+0x56c4] Java_org_cef_browser_CefBrowser_1N_N_1CreateBrowser+0xcc
j org.cef.browser.CefBrowser_N.N_CreateBrowser(Lorg/cef/handler/CefClientHandler;JLjava/lang/String;ZZLjava/awt/Component;Lorg/cef/browser/CefRequestContext;)Z+0
j org.cef.browser.CefBrowser_N.lambda$createBrowser$1(Lorg/cef/handler/CefClientHandler;JLjava/lang/String;ZZLjava/awt/Component;)V+35
j org.cef.browser.CefBrowser_N$$Lambda$239+0x000000080040a9b0.run()V+28
j org.cef.browser.CefBrowser_N.executeNative(Ljava/lang/Runnable;Ljava/lang/String;)V+15
j org.cef.browser.CefBrowser_N.createBrowser(Lorg/cef/handler/CefClientHandler;JLjava/lang/String;ZZLjava/awt/Component;)V+64
j org.cef.browser.CefBrowserWr.createBrowserIfRequired(Z)Z+104
j org.cef.browser.CefBrowserWr$1$1.run()V+151
J 1772 c1 java.awt.event.InvocationEvent.dispatch()V java.desktop@17.0.7 (69 bytes) @ 0x0000000105afd494 [0x0000000105afd240+0x0000000000000254]
J 1810 c1 java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V java.desktop@17.0.7 (136 bytes) @ 0x0000000105b0dcc4 [0x0000000105b0c1c0+0x0000000000001b04]
J 1819 c1 java.awt.EventQueue$3.run()Ljava/lang/Void; java.desktop@17.0.7 (60 bytes) @ 0x0000000105b15cd0 [0x0000000105b15b80+0x0000000000000150]
J 1768 c1 java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V java.desktop@17.0.7 (80 bytes) @ 0x0000000105afb114 [0x0000000105afab80+0x0000000000000594]
J 1811 c1 java.awt.EventDispatchThread.pumpOneEventForFilters(I)V java.desktop@17.0.7 (113 bytes) @ 0x0000000105b10844 [0x0000000105b10180+0x00000000000006c4]
j java.awt.EventDispatchThread.pumpEventsForFilter(ILjava/awt/Conditional;Ljava/awt/EventFilter;)V+35 java.desktop@17.0.7
j java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+11 java.desktop@17.0.7
j java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4 java.desktop@17.0.7
j java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3 java.desktop@17.0.7
j java.awt.EventDispatchThread.run()V+18 java.desktop@17.0.7
v ~StubRoutines::call_stub
V [libjvm.dylib+0x47757c] JavaCalls::call_helper(JavaValue*, methodHandle const&, JavaCallArguments*, JavaThread*)+0x390
V [libjvm.dylib+0x4765e8] JavaCalls::call_virtual(JavaValue*, Klass*, Symbol*, Symbol*, JavaCallArguments*, JavaThread*)+0xf8
V [libjvm.dylib+0x4766b0] JavaCalls::call_virtual(JavaValue*, Handle, Klass*, Symbol*, Symbol*, JavaThread*)+0x64
V [libjvm.dylib+0x52aab4] thread_entry(JavaThread*, JavaThread*)+0xc4
V [libjvm.dylib+0x9b65c0] JavaThread::thread_main_inner()+0x14c
V [libjvm.dylib+0x9b4c2c] Thread::call_run()+0xe0
V [libjvm.dylib+0x7d0170] thread_native_entry(Thread*)+0x158
C [libsystem_pthread.dylib+0x7034] _pthread_start+0x88
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.cef.browser.CefBrowser_N.N_CreateBrowser(Lorg/cef/handler/CefClientHandler;JLjava/lang/String;ZZLjava/awt/Component;Lorg/cef/browser/CefRequestContext;)Z+0
j org.cef.browser.CefBrowser_N.lambda$createBrowser$1(Lorg/cef/handler/CefClientHandler;JLjava/lang/String;ZZLjava/awt/Component;)V+35
j org.cef.browser.CefBrowser_N$$Lambda$239+0x000000080040a9b0.run()V+28
j org.cef.browser.CefBrowser_N.executeNative(Ljava/lang/Runnable;Ljava/lang/String;)V+15
j org.cef.browser.CefBrowser_N.createBrowser(Lorg/cef/handler/CefClientHandler;JLjava/lang/String;ZZLjava/awt/Component;)V+64
j org.cef.browser.CefBrowserWr.createBrowserIfRequired(Z)Z+104
j org.cef.browser.CefBrowserWr$1$1.run()V+151
J 1772 c1 java.awt.event.InvocationEvent.dispatch()V java.desktop@17.0.7 (69 bytes) @ 0x0000000105afd494 [0x0000000105afd240+0x0000000000000254]
J 1810 c1 java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V java.desktop@17.0.7 (136 bytes) @ 0x0000000105b0dcc4 [0x0000000105b0c1c0+0x0000000000001b04]
J 1819 c1 java.awt.EventQueue$3.run()Ljava/lang/Void; java.desktop@17.0.7 (60 bytes) @ 0x0000000105b15cd0 [0x0000000105b15b80+0x0000000000000150]
J 1768 c1 java.awt.EventQueue.dispatchEvent(Ljava/awt/AWTEvent;)V java.desktop@17.0.7 (80 bytes) @ 0x0000000105afb114 [0x0000000105afab80+0x0000000000000594]
J 1811 c1 java.awt.EventDispatchThread.pumpOneEventForFilters(I)V java.desktop@17.0.7 (113 bytes) @ 0x0000000105b10844 [0x0000000105b10180+0x00000000000006c4]
j java.awt.EventDispatchThread.pumpEventsForFilter(ILjava/awt/Conditional;Ljava/awt/EventFilter;)V+35 java.desktop@17.0.7
j java.awt.EventDispatchThread.pumpEventsForHierarchy(ILjava/awt/Conditional;Ljava/awt/Component;)V+11 java.desktop@17.0.7
j java.awt.EventDispatchThread.pumpEvents(ILjava/awt/Conditional;)V+4 java.desktop@17.0.7
j java.awt.EventDispatchThread.pumpEvents(Ljava/awt/Conditional;)V+3 java.desktop@17.0.7
j java.awt.EventDispatchThread.run()V+18 java.desktop@17.0.7
v ~StubRoutines::call_stub
siginfo: si_signo: 11 (SIGSEGV), si_code: 2 (SEGV_ACCERR), si_addr: 0x0425000102149c78
<truncated>
@DatL4g Could you have a look at this issue?
I am affected by this aswell.
Sample App is crashing with same isuue as well.
I checked out 1.6.0 using CEF, and that worked, @DatL4g issue with KCEF likely ?
@Shabinder Your stacktrace says that a required module is missing from export. Please make sure to specify it in your build script.
@KevinnZou A updated version is available 2024.04.20
which is compatible with the newer versions of the cef core.
@Shabinder Your stacktrace says that a required module is missing from export.
Please make sure to specify it in your build script.
I am using includeAllModules = true, (which exports all into binary) Without changing my build.gradle.kts, just shifting version to 1.6.0 and References of KCEF to CEF, it auto worked.
@Shabinder that's not 100% right.
CEF uses internal Java methods using reflection which does not work by simply specifing to include all modules.
Heres an article to get a deeper look into this arguments: https://nipafx.dev/five-command-line-options-hack-java-module-system/
It is required to use --add-opens
as stated in the desktop related Readme.
It is required to use --add-opens as stated in the desktop related Readme.
This is done, I didnt change, following this as stated in readme, even while having this it still crashes.
Hi all,
I solved by passing the jvm args to the JavaExec tasks instead of doing it in the compose.desktop.application
lambda as described by the README.desktop.md.
tasks.withType<JavaExec> {
jvmArgs("--add-opens", "java.desktop/sun.awt=ALL-UNNAMED")
jvmArgs("--add-opens", "java.desktop/java.awt.peer=ALL-UNNAMED")
if (System.getProperty("os.name").contains("Mac")) {
jvmArgs("--add-opens", "java.desktop/sun.lwawt=ALL-UNNAMED")
jvmArgs("--add-opens", "java.desktop/sun.lwawt.macosx=ALL-UNNAMED")
}
}
I'm new to KMP so I'm not 100% sure why this happens, but when I run
./gradlew run
it works only with the standard configuration, but when I run
./gradlew desktopRun -DmainClass=com.example.MainKt --quiet
it works only with the workaround I provided (passing the arts to the JavaExec
tasks).
Hopefully someone with more experience is able to explain, I need to dig in deeper to understand why, but in the meantime I thought the workaround could help people struggling with this.
I guess I started using the desktopRun
task after following this compose multiplatform issue CMP-4666, but then, by following the links, I found out that the general recommendation on the CMP docs is to use the run
task.
As far as I understand, the desktopRun
task is specifically created for us by the CMP plugin, while run
is the generic Java application task. Despite that, the former seems to ignore the compose.desktop.application
configuration, I have no idea why, while the latter is aware of that config.
So, technically, the README.desktop.md is correct as long as you use ./gradlew run
to run the desktop application.
Unfortunately, if you search the web on how to run a CMP desktop app, there is a bit of confusion about what task to run to start a KMP desktop app, as it's full of suggestions to use the desktopRun
task instead (another example here from JetBrains), probably leading people to having this issue with this library (at least it was the case for me).
When I try to load a page in a WebView, the app crashes on desktop. It works perfectly fine on android and ios. I did follow the direction on the desktop readme page and something was downloaded when starting the app (from Android Studio).
WebViewMultiplatform: 1.8.8 OS: macOS 14.2.1 Kotlin: 1.9.21 Compose Plugin: 1.6.0-beta02
Stacktrace
Executing tasks: [desktopRun] in project /Users/ms/git/sekolah/apps/composeApp 2024-02-07 13:39:10.820 java[35254:1013717] WARNING: Secure coding is not enabled for restorable state! Enable secure coding by implementing NSApplicationDelegate.applicationSupportsSecureRestorableState: and returning YES. JCEF(39:11:385): initialized stderr logger, severity=LOGSEVERITY_DEFAULT JCEF_I(39:11:389): CefApp: set state NEW JCEF_V(39:11:392): Fixed args: [--framework-dir-path=/Users/ms/git/sekolah/apps/composeApp/kcef-bundle/Frameworks/Chromium Embedded Framework.framework, --browser-subprocess-path=/Users/ms/git/sekolah/apps/composeApp/kcef-bundle/Frameworks/jcef Helper.app/Contents/MacOS/jcef Helper, --main-bundle-path=/Users/ms/git/sekolah/apps/composeApp/kcef-bundle/Frameworks/jcef Helper.app] JCEF_I(39:11:393): CefApp: set state INITIALIZING JCEF_V(39:11:394): Initialize CefApp on Thread[CefInitialize-thread,6,main] [0207/133911.458017:WARNING:policy_logger.cc(151)] :components/enterprise/browser/controller/chrome_browser_cloud_management_controller.cc(88) Could not create policy manager as CBCM is not enabled. JCEF_V(39:11:509): CefApp: native initialization is finished. JCEF_I(39:11:509): CefApp: set state INITIALIZED JCEF_I(39:11:511): version: JCEF Version = 119.4.7.749.4467854d5d810e0758a861c8ebbc622f11fb7809 CEF Version = 119.4.7 Chromium Version = 119.0.6045.199 | settings: browser_subprocess_path=/Users/ms/git/sekolah/apps/composeApp/kcef-bundle/Frameworks/jcef Helper.app/Contents/MacOS/jcef Helper, windowless_rendering_enabled=true, command_line_args_disabled=false, cache_path=/Users/ms/git/sekolah/apps/composeApp/cache, persist_session_cookies=false, user_agent=null, user_agent_product=null, locale=null, log_file=null, log_severity=LOGSEVERITY_DEFAULT, javascript_flags=null, resources_dir_path=null, locales_dir_path=null, pack_loading_disabled=false, remote_debugging_port=0, uncaught_exception_stack_size=0, cookieable_schemes_list=null, cookieable_schemes_exclude_defaults=false, no_sandbox=true JCEF_W(39:24:360): failed to retrieve platform window handle java.lang.IllegalAccessError: class org.cef.browser.platform.CefBrowserWindowPlatform (in unnamed module @0x3cb906f6) cannot access class sun.awt.AWTAccessor (in module java.desktop) because module java.desktop does not export sun.awt to unnamed module @0x3cb906f6 at org.cef.browser.platform.CefBrowserWindowPlatform.getWindowHandle(CefBrowserWindowPlatform.java:28) at org.cef.browser.CefBrowserWr.getWindowHandle(CefBrowserWr.java:434) at org.cef.browser.CefBrowserWr$3.addNotify(CefBrowserWr.java:321) at java.desktop/java.awt.Container.addNotify(Unknown Source) at java.desktop/javax.swing.JComponent.addNotify(Unknown Source) at java.desktop/java.awt.Container.lambda$addImpl$0(Unknown Source) at java.desktop/sun.awt.SunToolkit.lambda$performWithTreeLock$1(Unknown Source) at java.desktop/sun.awt.SunToolkit.performOnMainThreadIfNeeded(Unknown Source) at java.desktop/sun.awt.SunToolkit.performWithTreeLock(Unknown Source) at java.desktop/java.awt.Container.addImpl(Unknown Source) at java.desktop/javax.swing.JLayeredPane.addImpl(Unknown Source) at java.desktop/java.awt.Container.add(Unknown Source) at androidx.compose.ui.scene.ComposeSceneMediator.addToLayer(ComposeSceneMediator.desktop.kt:388) at androidx.compose.ui.scene.ComposeSceneMediator.addToComponentLayer(ComposeSceneMediator.desktop.kt:396) at androidx.compose.ui.scene.ComposeContainer.addToComponentLayer(ComposeContainer.desktop.kt:198) at androidx.compose.ui.awt.ComposeWindowPanel.add(ComposeWindowPanel.desktop.kt:136) at androidx.compose.ui.awt.SwingPanel_desktopKt$SwingPanel$4.invoke(SwingPanel.desktop.kt:154) at androidx.compose.ui.awt.SwingPanel_desktopKt$SwingPanel$4.invoke(SwingPanel.desktop.kt:115) at androidx.compose.runtime.DisposableEffectImpl.onRemembered(Effects.kt:82) at androidx.compose.runtime.CompositionImpl$RememberEventDispatcher.dispatchRememberObservers(Composition.kt:1285) at androidx.compose.runtime.CompositionImpl.applyChangesInLocked(Composition.kt:982) at androidx.compose.runtime.CompositionImpl.applyChanges(Composition.kt:1003) at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:639) at androidx.compose.runtime.Recomposer$runRecomposeAndApplyChanges$2$1.invoke(Recomposer.kt:551) at androidx.compose.runtime.BroadcastFrameClock$FrameAwaiter.resume(BroadcastFrameClock.kt:42) at androidx.compose.runtime.BroadcastFrameClock.sendFrame(BroadcastFrameClock.kt:71) at androidx.compose.ui.scene.BaseComposeScene.render(BaseComposeScene.skiko.kt:163) at androidx.compose.ui.scene.ComposeSceneMediator$DesktopSkikoView.onRender(ComposeSceneMediator.desktop.kt:490) 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:82) 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(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) java.lang.IllegalAccessError: class org.cef.browser.platform.CefBrowserWindowPlatform (in unnamed module @0x3cb906f6) cannot access class sun.awt.AWTAccessor (in module java.desktop) because module java.desktop does not export sun.awt to unnamed module @0x3cb906f6 at org.cef.browser.platform.CefBrowserWindowPlatform.getWindowHandle(CefBrowserWindowPlatform.java:28) at org.cef.browser.CefBrowserWr.getWindowHandle(CefBrowserWr.java:434) at org.cef.browser.CefBrowserWr.getWindowHandle(CefBrowserWr.java:426) at org.cef.browser.CefBrowserWr.createBrowserIfRequired(CefBrowserWr.java:495) at org.cef.browser.CefBrowserWr$1$1.run(CefBrowserWr.java:65) 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) # # A fatal error has been detected by the Java Runtime Environment: # # SIGSEGV (0xb) at pc=0x0000000101813c48, pid=35254, tid=53779 # # JRE version: OpenJDK Runtime Environment (17.0.7) (build 17.0.7+0-17.0.7b1000.6-10550314) # Java VM: OpenJDK 64-Bit Server VM (17.0.7+0-17.0.7b1000.6-10550314, mixed mode, tiered, compressed oops, compressed class ptrs, g1 gc, bsd-aarch64) # Problematic frame: # V [libjvm.dylib+0x123c48] AccessInternal::PostRuntimeDispatch