Java 22 mac osx native access - how?

classic Classic list List threaded Threaded
14 messages Options
Reply | Threaded
Open this post in threaded view
|

Java 22 mac osx native access - how?

imakerobots
This post was updated on .
Hello,

I tried to build and run Makleangelo Software (https://github.com/marginallyclever/makelangelo-software/) and Robot-Overlord (https://github.com/MarginallyClever/Robot-Overlord-App) in IDEA with Oracle's OpenJDK 25 and got a hard JVM crash.  

I got a warning about "--enable-native-access".  Research didn't lead to success.

How do I set up my app so that it runs (a) in debug and (b) when jpackaged?

Thank you!

PS: wow, i post a lot to this forum!
Reply | Threaded
Open this post in threaded view
|

Re: Java 22 mac osx native access - how?

gouessej
Administrator
Have you tried --enable-native-access=ALL-UNNAMED?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Java 22 mac osx native access - how?

imakerobots
Yes, both as a VM option in IDEA and as a command line argument.  It made the warning go away but didn't fix the issue.

Someone else suggested using -XstartOnFirstThread, apparently that's a thing LWJGL has to do.

> You should now be ready to develop and launch an LWJGL application. Following is a simple example that utilizes GLFW to create a window and clear the background color to red, using OpenGL.
> MacOS users should start their application passing "-XstartOnFirstThread" as a VM option.

Reply | Threaded
Open this post in threaded view
|

Re: Java 22 mac osx native access - how?

hharrison
The --enable-native-access shouldn't have any effect yet other than warning about jni use, it's not enforcing anything yet (as far as I've been able to tell from the jaamsim side so far). I just added the enable-native access = ALL-UNNAMED to the manifest for our executable jar to avoid the warning for now.

Harvey

Reply | Threaded
Open this post in threaded view
|

Re: Java 22 mac osx native access - how?

gouessej
Administrator
In reply to this post by imakerobots
imakerobots wrote
Yes, both as a VM option in IDEA and as a command line argument.  It made the warning go away but didn't fix the issue.
Please can you post a stacktrace of the crash?
Julien Gouesse | Personal blog | Website
Reply | Threaded
Open this post in threaded view
|

Re: Java 22 mac osx native access - how?

imakerobots
I upgraded to 2.6.0.  My minimal Gl2 example works, but the gl3 and gl4 do not.
Now they produce a black rectangle.  display() is definitely being called.  even glClear() does nothing.

> Please can you post a stacktrace of the crash?

of the JVM crash?  It doesn't offer a stacktrace, it offers a memory dump log file thing.

I'm working in https://github.com/MarginallyClever/Robot-Overlord-App/tree/dev
And the minimal tests are
src/test/java/com/marginallyclever/ro3/apps/viewport/MinimalOpenGL2.java
src/test/java/com/marginallyclever/ro3/apps/viewport/MinimalOpenGL3.java
src/test/java/com/marginallyclever/ro3/apps/viewport/MinimalOpenGL4.java
Reply | Threaded
Open this post in threaded view
|

Re: Java 22 mac osx native access - how?

hharrison
The log file may at least provide the faulting location if not a full stack trace, I think without any actual information to go on it's going to be very hard to help you out ;-)
Reply | Threaded
Open this post in threaded view
|

Re: Java 22 mac osx native access - how?

imakerobots
I know what you mean.  The computer I can test on is also where I have very limited access.  I don't have immediate way to deliver the log file from there.  That's why I offered instead the entire project in the hopes someone better connected than I could assist.  I'm still trying to get the file.
Reply | Threaded
Open this post in threaded view
|

Re: Java 22 mac osx native access - how?

imakerobots
Hello,

Thanks for your patience and understanding.

I finally had access again.  I have found that it will work with GLCanvas in MacOS, a GLJPanel in Windows, and never the other way around.  Surely I'm doing something wrong, os-specific code shouldn't happen in Java.

I'm currently working in https://github.com/MarginallyClever/Robot-Overlord-App/tree/dev/src/test/java/com/marginallyclever/ro3/apps/viewport/
The minimal tests for each GL version are MinimalOpenGL2, MinimalOpenGL3, and MinimalOpenGL4.

In MacOS it will not display a triangle if I call gl.glBindVertexArray(0) or gl.glUseProgram(0), failing silently even if I enable the debug pipeline with glAutodrawable.setGL(...).

In Windows it will not display if UNLESS I call gl.glBindVertexArray(0).

If I attempt to use a GLCanvas in windows, i get

com.jogamp.opengl.GLException: Unable to determine GraphicsConfiguration: WindowsWGLGraphicsConfiguration[DefaultGraphicsScreen[WindowsGraphicsDevice[type .windows, connection decon, unitID 0, handle 0x0, owner false, NullToolkitLock[obj 0x280f625c], obj 0x1e54cb33], idx 1], pfdID 44, ARB-Choosen true,
        requested GLCaps[rgba 8/8/8/1, opaque, accum-rgba 0/0/0/0, dp/st/ms 32/8/4, sample-ext default, dbl, mono  , hw, GLProfile[GL4bc/GL4bc.hw], on-scr[.]],
        chosen    GLCaps[wgl vid 44 arb: rgba 8/8/8/8, opaque, accum-rgba 0/0/0/0, dp/st/ms 32/8/4, sample-ext default, dbl, mono  , hw, GLProfile[GL4bc/GL4bc.hw], on-scr[.]]]

        at jogl.all@2.6.0/jogamp.opengl.windows.wgl.awt.WindowsAWTWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationImpl(WindowsAWTWGLGraphicsConfigurationFactory.java:194)
        at jogl.all@2.6.0/com.jogamp.nativewindow.GraphicsConfigurationFactory.chooseGraphicsConfiguration(GraphicsConfigurationFactory.java:424)
        at jogl.all@2.6.0/com.jogamp.opengl.awt.GLCanvas.chooseGraphicsConfiguration(GLCanvas.java:1520)
        at jogl.all@2.6.0/com.jogamp.opengl.awt.GLCanvas.addNotify(GLCanvas.java:613)
        at java.desktop/java.awt.Container.addNotify(Container.java:2804)
        at java.desktop/javax.swing.JComponent.addNotify(JComponent.java:4846)
Reply | Threaded
Open this post in threaded view
|

Re: Java 22 mac osx native access - how?

Sven Gothel
Administrator
I have looked at your MinimalOpenGL3.java file,
since you have to use a core GL3 profile across all desktop platforms.
(MacOS only supports a core context >= GL3).
(This is equivalent w/ ES3, FYI - in case you like to use mobile, use GL3ES3 in your app)

Root cause is that GL >= 3.1 enforces us to use our own default VAO buffer, see GLContext's
- hasNoDefaultVAO
- getDefaultVAO 

i.e. GLContext creates its own default VAO to allow majority of applications to just work w/o dealing w/ VAO.

GLJPanel uses its GLSL shader to flip the buffer to AWT orientation, which can be turned-off (see link).

You app uses its own VAO, which pulls GLJPanel's previous initialed VBO within GLContext's own default VAO.
This attached fix does the following:
- Using GL3 core profile
- Re-enable GLContext's default VAO after init and display

For simplification, I used JOGL's Matrix4f and Animator.

MinimalOpenGL3.diff

Edit: I tested this on GNU/Linux and Windows.
Reply | Threaded
Open this post in threaded view
|

Re: Java 22 mac osx native access - how?

imakerobots
Fantastic.  Why Animator instead of FPSAnimator?
Reply | Threaded
Open this post in threaded view
|

Re: Java 22 mac osx native access - how?

Sven Gothel
Administrator
imakerobots wrote
Fantastic.  Why Animator instead of FPSAnimator?
I prefer using hw-based vsync to avoid tearing,
but yes - this change wasn't required.

If you like to use a lower fps, you can utilize `setSwapInterval`,
AFAIK from GLAutoDrawable and/or GLContext.
Reply | Threaded
Open this post in threaded view
|

Re: Java 22 mac osx native access - how?

Sven Gothel
Administrator
In reply to this post by imakerobots
hope you have found my earlier reply to your request useful as well (stencil, depth, ..)
https://forum.jogamp.org/how-can-i-display-the-depth-stencil-buffer-tp4043810p4043842.html

;-)
Reply | Threaded
Open this post in threaded view
|

Re: Java 22 mac osx native access - how?

imakerobots
I added your changes to the minimal tests and they all run on macOS.  Huzzah!  

Then i copy the changes into the OpenGL3PanelTest ... no go.  The errors messages are cryptic and involve something deep inside jogamp.  I'm sorry I can't be more helpful on that front, I'll get you logs ASAP.