gluonhq / substrate

Create native Java(FX) apps for desktop, mobile and embedded
GNU General Public License v2.0
390 stars 52 forks source link

JavaFX Native Image For Media #1233

Open natsufumij opened 1 year ago

natsufumij commented 1 year ago

Expected Behavior

It is hoped that after JavaFX Native Image, the content of the Media module can be used normally, including common classes such as MediaPlayer、Media etc.

Current Behavior

Although JavaFX programs containing Media modules can pass Native Image, they cannot access code and data normally after running, which is equivalent to media modules not working.

Context

In the sample example given by gluon, I added the reference to media, and added the writing of moduleinfo, and the nativeimage passed, but did not successfully access the content of media, could not play the content, and even the creation of media failed. These can be viewed at gluonfx:nativerun.

I made an attempt to embed the jni and reflect configurations in the project to simulate the configuration of Linux in the media .jar in the substrate, so that it would compile normally and use the contents of the media module. The project address is: https://github.com/natsufumij/javafx-native-media-demo If someone could translate my work into something that would be useful directly to the substrate project, thanks!

by Natsufumi Junichi

credmond commented 1 year ago

@johanvos / @jperedadnr : could someone from GluonFX comment on this -- is it this simple (surely not...)?

I'd be willing to help add support via PRs, if it is achievable. Bit could I get some background information on why media and web are not supported in Windows or MacOS in the first place? What were the challenges?

johanvos commented 1 year ago

@natsufumij and @credmond Thanks for bringing this to our attention. Without a detailed look, my first guess is that it should more or less work this way indeed. The difficult part is to have the correct set of jni/reflection configs, to make sure that the versions match correctly, and to avoid duplicate symbols. The latter has been a problem in the past, as the native library for the javafx media includes symbols that have the same name as symbols used in other libraries, so that is something that needs to be fixed as well. But we have to work on that, as I agree it would be a great enhancement.

credmond commented 1 year ago

Thanks for the reply. I won't pretend to fully understand the challenges at the moment.

Happy to help on this if someone on your side could provide some adhoc support (i.e., "am I on the right track?") via some channel.

I have Linux, MacOS and Windows, so testing is covered. Depends on the appetite @ Gluon. I can sense there's not much bandwidth to work on these repos lately, and also that your focus is mobile and commercial changes...