AdoptOpenJDK / IcedTea-Web

The new home for IcedTea-Web
Other
218 stars 84 forks source link

WebStart and SWT on macOS #844

Open torchwood1715 opened 2 years ago

torchwood1715 commented 2 years ago

Hello community. I have an issue with launching my app on macOS with WebStart. It uses SWT framework which requires "-XstartOnFirstThread" VM argument when running on macOS. At the same time the application works fine if running directly, so the issue seems in the WebStart. Last time SWT and WebStart were working fine on Java 8 prior to macOS Big Sur 11.0.1.

I am using OpenWebStart 1.4.0 with built-in IcedTeaWeb 1.8.6, Adopt OpenJDK 11.0.13/17.0.35 and macOS Monterey 12.0.1

Here is a small SWT jnlp app to easily reproduce the issue. Issue is only presented on macOS. (zipped jnlp) test.zip The jnlp sources are in the repo: https://github.com/torchwood1715/swt-test/tree/main/jnlp

The issue is that IcedTeaWeb stucks on startup even before the application code is run. Here is thread-dump:
threadDump.txt and OpenWebStart logs from IcedTeaWeb 2021-11-25_185058.805-ows-stage1.log , 2021-11-25_185058.805-ows-stage2.log.

It looks like AWT initialization hangs if -XstartOnFirstThread parameter is used. It is possible to bypass this by using -Djava.awt.headless parameter. But then SWT fails with InvalidThreadAccess exeption, which means -XstartOnFirstThread parameter is not completely honored, and the application was started in not main thread. Does anyone have idea how to fix this?

torchwood1715 commented 2 years ago

It is possible to bypass the hang if -XstartOnFirstThread is accompanied with -Xnosplash VM argument.

But I still have the issue with the incorrect thread. Since SWT requires to be opened from the main thread, it seems correct to provide a bypass like:

if macOS platform is used and -XstartOnFirstThread VM-argument is passed then business logic is run not in the TgTread net.sourceforge.jnlp.Launcher:156 but directly in the main. I must point that it may be not so trivial to check –XstartOnFirstThread argument presence, according to this stackoverflow item

AlBundy33 commented 5 months ago

are there any workarounds?