jdeploy icon indicating copy to clipboard operation
jdeploy copied to clipboard

Using a splash screen interferes with the class loader used by JavaFX

Open dlemmermann opened this issue 3 years ago • 5 comments

Our app was working perfectly fine, then I added a splash screen. After that the default class loader used by JavaFX was null. See method getDefaultClassLoader() in FXMLLoader.java. This caused our app to crash as soon as it tried to create a view via FXML. At first I thought it is caused by the short snippet used to close the splash screen (as it probably ran on the wrong thread), but even after commenting that out the app would still crash. It was only after I completely removed the splash screen from the jdeploy package that our app started working again.

dlemmermann avatar Apr 12 '22 12:04 dlemmermann

Perhaps the -splash:splash.gif command-line switch isn't compatible with JavaFX. I can't find anything confirming this yet, but I see lots of posts of people extending javafx.application.Preloader to make a splash screen. E.g. https://stackoverflow.com/questions/69237024/javafx-splashscreen-with-an-animated-gif

shannah avatar Apr 12 '22 13:04 shannah

Yes, Preloaders are the way to do it for JavaFX applications. But then I guess it becomes my responsibility to provide it ....?

dlemmermann avatar Apr 12 '22 13:04 dlemmermann

This is good to know. Since the installer app uses a splash image, I'll have to keep this in mind as we add support for installer themes written in JavaFX.

shannah avatar Apr 12 '22 13:04 shannah

I added a note to the manual:

NOTE: jDeploy uses the `-splash:splash.gif` CLI argument at runtime to add the splash screen.  
This https://github.com/shannah/jdeploy/issues/66[apparently causes some issues with JavaFX].  
Currently, the recommendation for adding splash screens to JavaFX apps is to use a Preloader.  https://blog.codecentric.de/en/2015/09/javafx-how-to-easily-implement-application-preloader-2/[Example here].

Will leave this open, as there may be other solutions for splash-screen that I can explore, such as spawning a separate "splash screen" process from the launcher to display the splashscreen while the app loads.

shannah avatar Apr 18 '22 13:04 shannah

Ok one year later I'm facing the same issue, is there any known workaround beside removing the splash screen? Is there anything we could help?

RouHim avatar Apr 25 '23 05:04 RouHim