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.88k stars 1.15k forks source link

[compose-gradle-plugin] run task makes AWT segfault #2249

Open ptitjes opened 2 years ago

ptitjes commented 2 years ago

When your run a compose application with the run task contributed by the compose gradle plugin, it adds to the Java command line the following system property:

-Dcompose.application.configure.swing.globals=true

This makes the JVM crash when opening an AWT file dialog:

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f5c2c0fa3a7, pid=27662, tid=27710
#
# JRE version: OpenJDK Runtime Environment (Red_Hat-18.0.2.0.9-1.rolling.fc36) (18.0.2+9) (build 18.0.2+9)
# Java VM: OpenJDK 64-Bit Server VM (Red_Hat-18.0.2.0.9-1.rolling.fc36) (18.0.2+9, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C  [libcairo.so.2+0x973a7]
#
# Core dump will be written. Default location: Core dumps may be processed with "/usr/lib/systemd/systemd-coredump %P %u %g %s %t %c %h" (or dumping to /home/*************************/core.27662)
#
# An error report file with more information is saved as:
# /home/*************************/hs_err_pid27662.log
#
# If you would like to submit a bug report, please visit:
#   https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=java-latest-openjdk&version=36
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

Process finished with exit code 134 (interrupted by signal 6: SIGABRT)

I cannot provide the full error log nor the core dump.

However, the following minimal application runs well with -Dcompose.application.configure.swing.globals=false but crashes with -Dcompose.application.configure.swing.globals=true:

import androidx.compose.ui.window.*
import java.awt.*

fun main() = application {
    Window(
        title = "Test Application",
        onCloseRequest = ::exitApplication,
    ) {
        AwtWindow(
            create = {
                object : FileDialog(window, "Title", LOAD) {
                    override fun setVisible(value: Boolean) {
                        super.setVisible(value)
                        if (value) {
                            println(file)
                        }
                    }
                }
            },
            dispose = FileDialog::dispose
        )
    }
}

OS: Linux fedora 5.18.17-200.fc36.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 11 14:36:06 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux JVM version: openjdk 18.0.2 2022-07-19 (also crashes with openjdk 17.0.4 2022-07-19) Compose version: 1.2.0-alpha01-dev755

ptitjes commented 2 years ago

As a workaround, I override the jvm args with the compose gradle plugin dsl:

compose.desktop {
    application {
        // ...

        jvmArgs("-Dcompose.application.configure.swing.globals=false")

        // ...
    }
}
ptitjes commented 1 year ago

So now my workaround does not work anymore. Here is a reproduction repository https://github.com/ptitjes/repro-compose-issue-2249.

You'll find two main files:

sschuberth commented 1 year ago

I can also reproduce this with https://github.com/oss-review-toolkit/ort-workbench, ./gradlew run, and then clicking on "Load ORT Result".

sschuberth commented 1 year ago

Looks like it's related to using Wayland (as opposed to X11).

adstotz commented 11 months ago

I'm getting a different type of fatal error when running Compose Desktop on WSLg regardless of what I set -Dcompose.application.configure.swing.globals to. I'm trying to run the compose-multiplatform-template project from JetBrains out of the box on WSLg. The same works fine in an Ubuntu VM, just not WSLg for me. Were you able to get any type of resolution to this?

# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00007f5ab7f96e60, pid=21736, tid=21758
#
# JRE version: OpenJDK Runtime Environment Zulu17.44+53-CA (17.0.8.1+1) (build 17.0.8.1+1-LTS)
# Java VM: OpenJDK 64-Bit Server VM Zulu17.44+53-CA (17.0.8.1+1-LTS, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C  [libstdc++.so.6+0x229e60]
#
# No core dump will be written. Core dumps have been disabled. To enable core dumping, try "ulimit -c unlimited" before starting Java again
#
# An error report file with more information is saved as:
# /home/adstotz/code/personal/compose-multiplatform-template/desktopApp/hs_err_pid21736.log
#
# If you would like to submit a bug report, please visit:
#   http://www.azul.com/support/
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
okushnikov commented 2 weeks ago

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