1

I created a simple JavaFX application that compiles to binary using GraalVM with the Gluon maven plugin. However, the binary shows an empty window on some systems (for example, a fresh installed linux desktop). The compilation was made using a Github Action which runs mvn -Pdesktop gluonfx:build gluonfx:package.

Why does the binary only runs on some Linux systems?

The pom.xml configuration (full file here):

<plugin>
<groupId>com.gluonhq</groupId>
<artifactId>gluonfx-maven-plugin</artifactId>
<version>1.0.4</version>
<configuration>
    <mainClass>com.alinares.colorselectorfx.App</mainClass>
    <enableSWRendering>true</enableSWRendering>
    <nativeImageArgs>
          <arg>-Dprism.verbose=true</arg>
    </nativeImageArgs>
</configuration>
</plugin>

Screenshot of  with errors

Stacktrace:

WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @1edfedf1'
java.lang.UnsatisfiedLinkError: com.sun.pisces.JavaSurface.initialize(III)V [symbol: Java_com_sun_pisces_JavaSurface_initialize or Java_com_sun_pisces_JavaSurface_initialize__III]
    at com.oracle.svm.jni.access.JNINativeLinkage.getOrFindEntryPoint(JNINativeLinkage.java:153)
    at com.oracle.svm.jni.JNIGeneratedMethodSupport.nativeCallAddress(JNIGeneratedMethodSupport.java:57)
    at com.sun.pisces.JavaSurface.initialize(JavaSurface.java)
    at com.sun.pisces.JavaSurface.<init>(JavaSurface.java:45)
    at com.sun.prism.sw.SWRTTexture.<init>(SWRTTexture.java:51)
    at com.sun.prism.sw.SWResourceFactory.createRTTexture(SWResourceFactory.java:135)
    at com.sun.prism.sw.SWResourceFactory.createRTTexture(SWResourceFactory.java:124)
    at com.sun.javafx.tk.quantum.UploadingPainter.run(UploadingPainter.java:125)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
    at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:126)
    at java.lang.Thread.run(Thread.java:829)
    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:552)
    at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)

SS of the app

Update: Running the binary with -Dprism.verbose=true:

Aug 19, 2021 10:58:33 PM com.sun.javafx.application.PlatformImpl startup
WARNING: Unsupported JavaFX configuration: classes were loaded from 'unnamed module @11bd803'
Prism pipeline init order: es2 sw 
Using Double Precision Marlin Rasterizer
Using dirty region optimizations
Not using texture mask for primitives
Not forcing power of 2 sizes for textures
Using hardware CLAMP_TO_ZERO mode
Opting in for HiDPI pixel scaling
Prism pipeline name = com.sun.prism.es2.ES2Pipeline
Loading ES2 native library ... prism_es2
    succeeded.
GLFactory using com.sun.prism.es2.X11GLFactory
(X) Got class = class com.sun.prism.es2.ES2Pipeline
Failed Graphics Hardware Qualifier check.
System GPU doesn't meet the es2 pipe requirement
GraphicsPipeline.createPipeline: error initializing pipeline com.sun.prism.es2.ES2Pipeline
*** Fallback to Prism SW pipeline
Prism pipeline name = com.sun.prism.sw.SWPipeline
(X) Got class = class com.sun.prism.sw.SWPipeline
Initialized prism pipeline: com.sun.prism.sw.SWPipeline
 vsync: true vpipe: false
java.lang.UnsatisfiedLinkError: com.sun.pisces.JavaSurface.initialize(III)V [symbol: Java_com_sun_pisces_JavaSurface_initialize or Java_com_sun_pisces_JavaSurface_initialize__III]
    at com.oracle.svm.jni.access.JNINativeLinkage.getOrFindEntryPoint(JNINativeLinkage.java:153)
    at com.oracle.svm.jni.JNIGeneratedMethodSupport.nativeCallAddress(JNIGeneratedMethodSupport.java:57)
    at com.sun.pisces.JavaSurface.initialize(JavaSurface.java)
    at com.sun.pisces.JavaSurface.<init>(JavaSurface.java:45)
    at com.sun.prism.sw.SWRTTexture.<init>(SWRTTexture.java:51)
    at com.sun.prism.sw.SWResourceFactory.createRTTexture(SWResourceFactory.java:135)
    at com.sun.prism.sw.SWResourceFactory.createRTTexture(SWResourceFactory.java:124)
    at com.sun.javafx.tk.quantum.UploadingPainter.run(UploadingPainter.java:125)
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:305)
    at com.sun.javafx.tk.RenderJob.run(RenderJob.java:58)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
    at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:126)
    at java.lang.Thread.run(Thread.java:829)
    at com.oracle.svm.core.thread.JavaThreads.threadStartRoutine(JavaThreads.java:567)
    at com.oracle.svm.core.posix.thread.PosixJavaThreads.pthreadStartRoutine(PosixJavaThreads.java:192)

I added <enableSWRendering>true</enableSWRendering> to the pom.xml and added com.sun.pisces.JavaSurface.initialize to reflect-config.json and jni-config.json (after running gluonfx:runagent).

José Pereda
  • 44,311
  • 7
  • 104
  • 132
user547972
  • 11
  • 2
  • See related: [java.lang.UnsatisfiedLinkError](https://stackoverflow.com/questions/1403788/java-lang-unsatisfiedlinkerror-no-dll-in-java-library-path). A native library could not be loaded. How to resolve this for your particular configuration, I do not know. Perhaps you are trying to run your application on a platform that gluon does not support (again I do not know). – jewelsea Aug 19 '21 at 23:44
  • Can you run `mvn gluonfx:runagent`? See [docs](https://docs.gluonhq.com/#_gluonfxrunagent). It should create the config files for native-image that include the missing JNI method for `com.sun.pisces.JavaSurface.initialize`. You can add `-Dprism.order=sw` to your pom to force `sw`. – José Pereda Aug 20 '21 at 16:47
  • @JoséPereda Unfortunately, it didn't work. I updated the question with your suggestions to the gluon plugin configuration (I'm using maven) and the config file updates for JNI. Maybe I'm not editing the correct JNI config file? – user547972 Aug 21 '21 at 07:06
  • You need to change `` to ``, and add `` to the JavaFX maven plugin before you call `gluonfx:runagent`. Either way, it still fails on Linux, but works fine on Mac. – José Pereda Aug 21 '21 at 12:00
  • "Either way, it still fails on Linux, but works fine on Mac." If I understand correctly, if there is no hardware acceleration in Linux the native binary will not render the app? – user547972 Aug 21 '21 at 15:38
  • Gluon Substrate has recently added a GraalVM `Feature` for [Linux](https://github.com/gluonhq/substrate/commit/1bd2dae341807e5008e9c609771438bab6a32b08), and that is part of GluonFX plugin 1.0.4. [Currently](https://github.com/gluonhq/substrate/blob/master/src/main/java/com/gluonhq/substrate/feature/GluonFeature.java#L66) it is missing the `com.sun.pisces` package, and that causes the exception. If you try with GluonFX plugin 1.0.3 it will work. Can you file an issue [here](https://github.com/gluonhq/substrate/issues)? – José Pereda Aug 21 '21 at 20:10
  • Filed it myself: https://github.com/gluonhq/substrate/issues/990 – José Pereda Aug 23 '21 at 09:10
  • Thanks for all your help @JoséPereda! – user547972 Aug 23 '21 at 16:03

0 Answers0