build OpenJFX using Yocto for embedded system - javafx

Here's what I need: A working OpenJFX 14 environment with hardware acceleration.
I have a i.MX 8M ARMv8 embedded system for which I'm trying to get OpenJFX 14 or latest running. The chipset has a Vivante GC7000UL GPU. The current Yocto build I did has galcore module loaded. The X window environment works fine and it has libEGL.so, libGLESv2.so and libGL.so in /usr/lib. I am a java engineer, not an OpenGL expert so I don't know if anymore libraries are needed for OpenGL APIs.
I have looked at the prebuilt versions from LibericaFX and Azul zulu. The latter does not have a ARM build. The former has aarch64 build but it is does not have monocle implementation. They have the prism ES2 implementation but unfortunately it needs GLX v1.3 or higher which I don't seem to have.
I tried to compile OpenJFX myself for ARMv8 using a Yocto recipe based on armv6hf.gradle. I managed to compile successfully and able to run it. But it does not render using the hardware pipeline.
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_monocle
GraphicsPipeline.createPipeline failed for com.sun.prism.es2.ES2Pipeline
java.lang.UnsatisfiedLinkError: /usr/lib/jni/libprism_es2_monocle.so: /usr/lib/jni/libprism_es2_monocle.so: undefined symbol: getNativeDisplayType
at java.base/java.lang.ClassLoader$NativeLibrary.load0(Native Method)
...
at java.base/java.lang.Thread.run(Thread.java:832)
*** 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
Which makes sense because getNativeDisplayType() method is defined in eglWrapper.c which is not included as a part of prism_es2_monocle linking.
Ok. Cool. Let me add that file to the compilation step.
Now the compilation fails with this error.
jfx-14.0.2.1-1/modules/javafx.graphics/src/main/native-prism-es2/eglWrapper/eglWrapper
.c:71:1: error: unknown type name 'PrismNativePort'
71 | PrismNativePort prismPort;
| ^~~~~~~~~~~~~~~
This is where my journey ends. I cannot find PrismNativePort mentioned anywhere other than this file (I've searched entire internet with Google).
Has anybody tried to compile OpenJFX other than Android or Linux x86? Can anyone tell me if I can try anything to make it work with hardware acceleration? Thank you.
This is what I use to start the sample application.
java --module-path /opt/openjfx/jfx-14 \
--add-modules javafx.controls \
-Djava.library.path=/usr/lib/jni \
-Dembedded=monocle \
-Dprism.verbose=true \
ColorfulCircles
Update: I found the PrismNativePort defined in a very old version of JFX code from 2016. Looks like a component called LensPort was decommissioned but eglWrapper still has links to the deleted code.

Not a real answer, but just an idea. OpenJFX 16-ea has more improvements for Raspberry Pi, so maybe also for your use-case. I'm starting my app with following commands on the Raspberry Pi 3 B (gtk instead of monocle):
java -Dglass.platform=gtk \
-Dprism.verbose=true \
-Djavafx.verbose=true \
-p /opt/arm32fb-sdk/lib \
--add-modules javafx.controls \
-jar /home/pi/APP.jar

You have to tell Glass to use monocle :
-Dglass.platform=Monocle
Here is my full command line to start app :
java --module-path ./dist/libARMv8/ --add-modules javafx.controls,javafx.fxml \
-Dembedded=monocle \
-Dglass.platform=Monocle \
-Dmonocle.platform=MX8 \
-Dprism.order=es2 \
-Dprism.verbose=true \
-Djavafx.verbose=true \
-Dcom.sun.javafx.isEmbedded=true -Dcom.sun.javafx.touch=true -Dcom.sun.javafx.virtualKeyboard=javafx \
-jar ./dist/JavaFXTestApp4.jar
I made a build of javaFX for iMX8. The hardware acceleration work but there is some blinking issue : for example, when I click in textField to show the virtual keyboard the display start blinking. Same issues with comboBox.
This blinking issue does not happen in software rendering mode.
I'm not an openGL expert either, so no more ideas for now.... It is maybe an issue with the Vivante openGL driver.
I can share my build script and give more details if someone is interested in it.
edit : to avoid blinking issue with hardware acceleration, add this to the command line :
-Dprism.forceUploadingPainter=true
Best regards,

Related

Where do I find JavaFX ant tasks in Java 11?

VSCode, Java 11 JavaFX 18.0.2
I am trying to package my code up for distribution as a desktop app. In my case I want a fully self-contained app because of my target user's profile.
I have been through Jenkov add the Oracle docs here and here which suggest I need ant-javafx.jar. That jar file seems to have been dropped from the standard Java SDK some time around Java 7 and put into the regular JavaFX install lib folder.
It's not there in the build I have.
JavaFX seems to have gone to openjfx.io and nowhere in there can I see support for the ant packaging jar. In fact I see openjfx as a retrograde step as they are increasingly forcing everyone into paid plans (try going round and round the loop of downloading anything that doesn't require an LTS payment).
I have a suspicion that there is some silent assumption that everyone will use something from maven or gradle, and maybe the packaging tools are buried away in one of those build tools. For historical reasons I don't use either and it should be possible to do this packaging without one of them.
So where do I get the JavaFX Ant build tasks from without having to pay someone?
I have found that the following works as an alternative with Java 19 and OpenJFX 19. I use the maven-dependency-plugin to copy all the dependency jars (excluding JavaFX, which I use as modules from a "full" JDK [one that includes JavaFX)] into the target/lib directory.
#!/bin/bash
set -o errexit
set -o noclobber
set -o xtrace
# find dependency modules of required modules
DEP_MODS=$(jdeps -quiet --class-path "target/lib/*" --add-modules java.base,java.logging,java.sql,javafx.controls,javafx.fxml --multi-release base --ignore-missing-deps --print-module-deps target/myapp-4.0-beta.jar)
# create a modular runtime image
jlink --compress=1 --no-header-files --no-man-pages --add-modules "java.logging,java.sql,javafx.controls,javafx.fxml,$DEP_MODS" --output target/myapp-4.0-beta
# Example of running it out of the runtime image
# TEST target/myapp-4.0-beta/bin/java -cp "../../myapp-4.0-beta.jar:../../lib/*" org.myapp.App
# symlink to the artifact jar from the lib directory
$(cd target/lib && ln -s ../myapp-4.0-beta.jar)
# use the lib directory and modular runtime image as input to jpackage
jpackage --input target/lib --runtime-image target/myapp-4.0-beta --main-jar myapp-4.0-beta.jar --main-class org.myapp.App --type app-image --app-version 4.0 --name app --dest target/dist/bundle --mac-entitlements src/dist/mac/entitlements.plist

Has anyone tried to use Apache POI on JavaFX modular projects?

I've been trying to create a modular JavaFX project with Excel-reporting capabilities. It turned out Apache POI doesn't yet support modular Java apps. Has anyone here tried any work-around on this matter?
I migrated a project initially developed in jdk8, which uses JavaFx to jdk13 using openJfx.
I had to modify the project.properties file quite extensively.
this was done as per openjfx website specifications
javac.modulepath=\
D:\\Libraries\\Java9\\openjfx-13.0.2_windows-x64_bin-sdk\\javafx-sdk-13.0.2\\lib
run.jvmargs=--module-path "D:\\Libraries\\Java9\\openjfx-13.0.2_windows-x64_bin-sdk\\javafx-sdk-13.0.2\\lib" \
--add-modules=javafx.base,javafx.controls,javafx.fxml,javafx.graphics,javafx.media,javafx.swing,javafx.web \
added these in run.jvmargs using trial and error in the sense that the build breaks when it tries to instantiate things...
--add-exports=javafx.graphics/com.sun.javafx.application=ALL-UNNAMED \
--add-exports=javafx.web/com.sun.webkit.network=ALL-UNNAMED \
--add-exports=javafx.web/com.sun.webkit.dom=ALL-UNNAMED \
--add-exports=javafx.graphics/com.sun.scenario.animation.shared=ALL-UNNAMED \
--add-exports=javafx.graphics/com.sun.javafx.tk.quantum=ALL-UNNAMED
and these are some of the libs it's using
javac.classpath=\
${libs.JAVAFX13.classpath}:\
${libs.jsch.classpath}:\
${libs.poi.classpath}:\
JAVAFX, poi and jsch are plain libraries. NO extra work was needed here.
apart from the trial and error exports, i essentially followed stuff from this link:
https://openjfx.io/openjfx-docs/#IDE-NetBeans

Project ERROR: Could not find feature when running qmake on any qt module

i am following guide written in here: https://wiki.qt.io/RaspberryPi2EGLFS
everythng runs smooth (needed to add fonts) - I can run and debug an application on my device from my pc.
But if I try to install any module (qtdeclarative, qt3d, qtquickcontrols, qtquickcontrols2) it just tells me no for a lack of some feature.
For examplee:
git clone git://code.qt.io/qt/qtdeclarative.git -b 5.9.0
cd qtdeclarative
~/raspi/qt5/bin/qmake -r
Gives me lots of positive code, but ends with:
Reading /path/to/raspi/qtdeclarative/src/quick/quick.pro
Project ERROR: Could not find feature qml-network.
Similar thing applies for the rest.
Could anyone tell me what to do?
edit
to make it worse same thing happens on 5.9.2 but 5.7 isn't compatible with rpi3
Try to do
~/raspi/qt5/bin/qmake
without the -r option. It worked for me.

how to build qt for arm using cross compilar called xlinu-gcc

I want to build qt-4.7.4 open source for the arm platform using cross compilar named xlinux-gcc. Can any body tell me the steps to follow and also the commands to be used on the linux terminal. I am using linux mint - 13 as my workstation. I got some help from the internet but as i am a begineer i am very confused. Please help me to build qt. Also can you tell me how to add opengls es2 support in it.
You'll have to create a qmake specification file for your platform. Go into the mkspec directory and look the qmake.conf files written for similar platforms. Do the same for yours. You'll have to specify some variables to indicate your compiler, your sysroot, the location of specific libraries etc... Some of those variables are those needed to add es2 support. Also, when configuring, add the parameter -opengl es2. The summary at the end of the configure script will tell you if OpenGL ES 2 is enabled.

Running Qt applications on QNX

I'm trying to get Qt applications running on QNX 4.5. I've compiled Qt 4.6.3 on a linux box with this configuration:
./configure -xplatform unsupported/qws/qnx-i386-g++ -embedded i386 -no-gfx-linuxfb -no-mouse-linuxtp -no-kbd-tty -no-qt3support -qt-gfx-qnx -qt-mouse-qnx -qt-kbd-qnx -no-exceptions -little-endian -nomake demos -nomake examples
"make" required certain tweaking of environment and commenting out one function, but worked in the end. I've copied fonts and compiled Qt libraries onto QNX running in VMware, and created a sample Qt app (it just displays a button) which I compiled on my linux box and copied over to QNX.
I have a little script to launch the app:
io-display -d vid=0x15adh,did=0x405h
/usr/photon/bin/devi-hid -Pr kbd mouse
./app
Which runs the application, enabling experimental input drivers. With this script I was able to get somewhere by running the Qt app in Photon - screen rendering gets all screwed up, but I do see my Qt application.
However, if I exit Photon into a text mode, and try to run the application from there (using a slightly modified script with different vid and did values for launching the graphics server), I just see a blank screen.
I'm completely new to QNX and Qt, so I'm a bit stuck right now. I'm trying to read up on how Photon works and what kind of environment it sets up, to find what I might be missing in the text mode. However, I'm not sure this is even a right direction, so I thought I'd ask good folks on SO, in case somebody went through this before :)
cheers!
Have you tried adding "-qws" after you app? It tells the Qt app to initialize it's windowing system (qws). Only 1 qt app needs (or may have) the option specified.
I would also add a couple of environment variables to help Qt to know where to find your keyboard and mouse. (I also am not sure if you really need the first line.)
io-display -d vid=0x15adh,did=0x405h
/usr/photon/bin/devi-hid -Pr kbd mouse
export QWS_DISPLAY=qnx
export QWS_MOUSE_PROTO=qnx
export QWS_KEYBOARD=qnx
./app -qws
BTW, QNX has just released a port of Qt 4.7.1 for QNX 6.5. It can be found on the Foundry 27 Qt Project site.

Resources