Didier Villevalois
01/11/2023, 3:15 PMDidier Villevalois
01/11/2023, 3:15 PMfun main() = application {
Window(onCloseRequest = ::exitApplication) {
App(window)
}
}
@Composable
@Preview
fun App(window: ComposeWindow) {
var open by remember { mutableStateOf(false) }
var result by remember { mutableStateOf<String?>(null) }
Column {
Button(
onClick = { open = true }
) {
Text("Open")
}
Text("Result: $result")
}
if (open) {
AwtWindow(
create = {
object : FileDialog(window, "Select a file", LOAD) {
override fun setVisible(value: Boolean) {
super.setVisible(value)
if (value) {
result = file
open = false
}
}
}
}, dispose = FileDialog::dispose
)
}
}
Didier Villevalois
01/11/2023, 3:16 PM#
# A fatal error has been detected by the Java Runtime Environment:
#
# SIGSEGV (0xb) at pc=0x00007f06ef7736c7, pid=271663, tid=271752
#
# JRE version: OpenJDK Runtime Environment (Red_Hat-17.0.5.0.8-1.fc37) (17.0.5+8) (build 17.0.5+8)
# Java VM: OpenJDK 64-Bit Server VM (Red_Hat-17.0.5.0.8-1.fc37) (17.0.5+8, mixed mode, sharing, tiered, compressed oops, compressed class ptrs, g1 gc, linux-amd64)
# Problematic frame:
# C [libcairo.so.2+0x976c7]
#
# 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/didier/Code/Didier/test-compose-awt-filedialog/core.271663)
#
# An error report file with more information is saved as:
# /home/didier/Code/Didier/test-compose-awt-filedialog/hs_err_pid271663.log
#
# If you would like to submit a bug report, please visit:
# <https://bugzilla.redhat.com/enter_bug.cgi?product=Fedora&component=java-17-openjdk&version=37>
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#
The JVM crash log:
https://github.com/ptitjes/repro-compose-issue-2249/blob/main/hs_err_pid271663.logDidier Villevalois
01/11/2023, 3:19 PMStefan Oltmann
01/11/2023, 3:23 PMDidier Villevalois
01/11/2023, 3:32 PMStefan Oltmann
01/11/2023, 3:35 PMDidier Villevalois
01/11/2023, 3:43 PMcompose-multiplatform-file-picker
and I get the exact same crash with Cairo...Stefan Oltmann
01/11/2023, 3:45 PMDidier Villevalois
01/11/2023, 3:47 PMAlbert Chang
01/11/2023, 3:51 PMStefan Oltmann
01/11/2023, 3:52 PMUIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName())
Didier Villevalois
01/11/2023, 3:53 PMDidier Villevalois
01/11/2023, 3:58 PMMainAwt.kt
which does:
fun main() {
val frame = Frame("Window")
val dialog = FileDialog(frame, "Select a file", LOAD)
dialog.isVisible = true
}
This code works with the same JVM, OS, etc.Albert Chang
01/11/2023, 4:08 PMKirill Grouchnikov
01/11/2023, 4:22 PMKirill Grouchnikov
01/11/2023, 4:22 PMNative frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
C [libcairo.so.2+0x976c7]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j org.lwjgl.util.nfd.NativeFileDialog.nNFD_OpenDialog(JJJ)I+0
j org.lwjgl.util.nfd.NativeFileDialog.NFD_OpenDialog(Ljava/lang/CharSequence;Ljava/lang/CharSequence;Lorg/lwjgl/PointerBuffer;)I+71
j com.darkrockstudios.libraries.mpfilepicker.FileChooser$chooseFileNative$2.invokeSuspend(Ljava/lang/Object;)Ljava/lang/Object;+87
Didier Villevalois
01/11/2023, 4:22 PM1.2
version of Compose, this workaround does not work.Kirill Grouchnikov
01/11/2023, 4:22 PMDidier Villevalois
01/11/2023, 4:23 PMDidier Villevalois
01/11/2023, 4:23 PMKirill Grouchnikov
01/11/2023, 4:24 PMDidier Villevalois
01/11/2023, 4:27 PMAwtWindow
to make the dialog open in the UI thread?
(cf. code at the begining of the slack thread)Albert Chang
01/11/2023, 4:37 PMDidier Villevalois
01/11/2023, 4:39 PMDidier Villevalois
01/11/2023, 4:44 PMAbdelilah El Aissaoui
01/11/2023, 5:49 PMSean Proctor
01/11/2023, 9:28 PMAlbert Chang
01/12/2023, 1:46 AMNikita Lipsky
01/12/2023, 8:51 AMI am not that sure. Indeed, as explained in the main message, launching directly the AWT dialog without any Compose works!!I believe you can reproduce the issue with pure AWT code. What if you wrap your AWT code with invokeLater(), like: fun main() { SwingUtilities.invokeLater { val frame = Frame("Window") val dialog = FileDialog(frame, "Select a file", LOAD) SwingUtilities.invokeLater { dialog.isVisible = true } } }
Adam Brown
01/12/2023, 8:54 AMNikita Lipsky
01/12/2023, 9:01 AMthis might be related to the crashunlikely
Didier Villevalois
01/12/2023, 9:06 AMMainAwtLater.kt
with your suggestion to the reproduction repository (cf. start of the Slack thread). It doesn't crash on Fedora.Nikita Lipsky
01/12/2023, 9:34 AMDidier Villevalois
01/12/2023, 10:06 AMDidier Villevalois
01/18/2023, 9:27 AMEd Brindley
01/18/2023, 9:55 AMDidier Villevalois
01/18/2023, 10:07 AMEd Brindley
01/18/2023, 10:56 AMDidier Villevalois
01/18/2023, 10:58 AM