Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JOGL/GLUEGEN not loading on MacOS M1 Arm #258

Open
tmulle opened this issue Dec 2, 2022 · 5 comments
Open

JOGL/GLUEGEN not loading on MacOS M1 Arm #258

tmulle opened this issue Dec 2, 2022 · 5 comments

Comments

@tmulle
Copy link

tmulle commented Dec 2, 2022

Description

Downloading the 2.2.1.zip and attempting to run either the run-demo.bash or any of the example applications (ie. Airspaces.java from the source tree using NetBeans IDE fails to load the JOGL libs on my M1 ARM MacOS.

When I attempt to disable the automatic loading of the libraries using -Djogamp.gluegen.UseTempJarCache=false as described here https://jogamp.org/jogl/doc/userguide/index.html#traditionallibraryloading I get a different error as show below.

From above link:

Automated Native Library Loading

JOGL 2.0 has a brand new feature allowing to automatically extract the proper native libraries required to use JOGL from JARs containing them without relying on the Java library path or any platform-dependent environment variable allowing to set the location of native libraries. This allows desktop applications as well as traditional Applets as NApplets to utilize the native library JAR files the same way Webstart/JNLP does.

To allow the native JAR file library loading to work, ensure that all JogAmp JAR files are left unmodified within their common directory.

In case the native library JAR files cannot be opened, it falls back to the traditional native library loading mechanism via the java library path.

This feature is enabled by default and - for whatever reason - it can be disabled by setting the property jogamp.gluegen.UseTempJarCache to false (as a VM argument, -Djogamp.gluegen.UseTempJarCache=false in command line).

Traditional Native Library Loading

If you don't use automatic native libraries loading, as enabled by default, you must set either the VM property java.library.path or the platform-dependent environment variable used for the location of native libraries, PATH on Windows, LD_LIBRARY_PATH on Unix (Linux, Solaris, ..) and DYLD_LIBRARY_PATH on Mac OS X. The environment variable shall contain the full path to the "lib" directory; for example, on Windows, add "C:\Users\myhome\jogamp-all-platforms\lib\windows-amd64" to your PATH using the System control panel, Advanced tab, Environment Variables button. At this point your Java installation should be able to see the Jogl class files.

Steps to Reproduce

Automatic Loading
To Run the demo app as stated in the README

  1. Download and unzip the 2.2.1.zip from the releases page on an M1 ARM based Mac computer
  2. execute the run-demo.bash script
  3. Program will attempt to run and fail with the exception A

To run the examples from the source in NetBeans IDE:

  1. Open the Worldwind project in the Netbeans IDE
  2. Right click on the src/gov/nasa/worldwindx/examples/Airspaces.java and choose 'Run File'
  3. Program will attempt to run and fail with the exception A

Disabling Automatic Loading
To Run the demo app as stated in the README

  1. Download and unzip the 2.2.1.zip from the releases page on an M1 ARM based Mac computer
  2. Add the command line argument -Djogamp.gluegen.UseTempJarCache=false to the java command
  3. execute the run-demo.bash script
  4. Program will attempt to run and fail with the exception B

To run the examples from the source in NetBeans IDE:

  1. Open the Worldwind project in the Netbeans IDE
  2. Add the command line argument -Djogamp.gluegen.UseTempJarCache=false to the Run properties of the project
  3. Right click on the src/gov/nasa/worldwindx/examples/Airspaces.java and choose 'Run File'
  4. Program will attempt to run and fail with the exception B

Expected behavior:
To be able to launch any of the demo code

Actual behavior:

EXCEPTION A
All fail with this exception:

at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:480)
	at gov.nasa.worldwindx.examples.ApplicationTemplate.start(ApplicationTemplate.java:293)
	at gov.nasa.worldwindx.examples.Airspaces.main(Airspaces.java:470)
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: /var/folders/hh/zxltvdg95x57jm4ln9b7wl380000gn/T/jogamp_0000/file_cache/jln5621638363952472050/jln4872219641170749731/natives/macosx-universal/libgluegen_rt.dylib
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2393)
	at java.base/java.lang.Runtime.load0(Runtime.java:755)
	at java.base/java.lang.System.load(System.java:1953)
	at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:604)
	at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:64)

EXCEPTION B

at gov.nasa.worldwindx.examples.ApplicationTemplate.start(ApplicationTemplate.java:293)
	at gov.nasa.worldwindx.examples.Airspaces.main(Airspaces.java:470)
Caused by: java.lang.UnsatisfiedLinkError: Can't load library: /Users/tmulle/Downloads/worldwind-v2.2.1/natives/macosx-universal/gluegen_rt
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2393)
	at java.base/java.lang.Runtime.load0(Runtime.java:755)
	at java.base/java.lang.System.load(System.java:1953)
	at com.jogamp.common.jvm.JNILibLoaderBase.loadLibraryInternal(JNILibLoaderBase.java:625)

Reproduces how often: [What percentage of the time does it reproduce?]
100%

Operating System and Version

[What operating system and version are you using?]
Darwin mars.local 22.1.0 Darwin Kernel Version 22.1.0: Sun Oct 9 20:15:09 PDT 2022; root:xnu-8792.41.9~2/RELEASE_ARM64_T6000 arm64

Additional Information

Java Versions Tried:

openjdk version "17.0.5" 2022-10-18 LTS
OpenJDK Runtime Environment Zulu17.38+21-CA (build 17.0.5+8-LTS)
OpenJDK 64-Bit Server VM Zulu17.38+21-CA (build 17.0.5+8-LTS, mixed mode, sharing)

Any additional information, configuration or data that might be necessary to reproduce the issue.

@dolaf
Copy link

dolaf commented Apr 26, 2023

Thanks, tmulle , for the detailed report.

In the frame of further evolution of ESA's SNAP (http://step.esa.int/main/toolboxes/snap/), we are trying to integrate Worldwind 2.2.1 on MacOS M1 Arm with Java11. We are finally observing exactly the same kind of exceptions A and B as listed above. Our setup is similar:

openjdk 11.0.19 2023-04-18 LTS OpenJDK Runtime Environment (build 11.0.19+7-LTS) OpenJDK 64-Bit Server VM (build 11.0.19+7-LTS, mixed mode)

Darwin macstudio.bc.local 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 20:59:28 PST 2023; root:xnu-8796.101.5~3/RELEASE_ARM64_T6000 arm64

A suggestion for a fix or workaround would be much appreciated.

@tmulle
Copy link
Author

tmulle commented Apr 26, 2023

@dolaf based on the information in this ticket #261

I download the latest jars from https://jogamp.org/deployment/v2.4.0/jar/ and replaced all the ones in the WorldWind 2.2.1 directory when I unzipped the file.

I was then able to run the demo app sh run-demo.bash and the application worked and I saw the default plain globe and could move around with the mouse, etc.

Make sure you remove -Djogamp.gluegen.UseTempJarCache=false if you added to the command line or in the NetBeans RUN launcher for the example applications. I accidentally left it in and the IDE wasn't running the demos. Once I removed that property things worked with the automatic loading like it should.

Hopefully, this will help you as well.

Here are the jars I replaced for my M1 Mac:
Screenshot 2023-04-26 at 3 05 58 PM

Demo Working from command line:
Screenshot 2023-04-26 at 3 06 37 PM

I was also able to run the demo applications in the Netbeans IDE. I just had to replace the libs that were set in the project with the newly downloaded ones: (I created a Library called M1 Glugen/JOGL)
Screenshot 2023-04-26 at 3 21 13 PM

Demo application working from NetBeans IDE:
Screenshot 2023-04-26 at 3 22 47 PM

Screenshot 2023-04-26 at 3 24 36 PM

@dolaf
Copy link

dolaf commented Apr 26, 2023

@tmulle: This is great news, thanks a lot for the info! We will give it a try and report back to you...
Cheers,
Olaf

@dolaf
Copy link

dolaf commented Apr 27, 2023

@tmulle: In the meantime I replaced the jars as you suggested. Unfortunately, in our application this ends up in the error shown below. Have you ever seen this?
error_mac_CGL

@tmulle
Copy link
Author

tmulle commented Apr 27, 2023

@dolaf No sorry.. what version of SNAP are you using? I downloaded SNAP yesterday version 9 on my Mac and when I ran it for the first time I was able to see the WorldWind globe in the application. I didn't even have to replace any jars.

Unfortunately, after doing plugin upgrades as the IDE suggested, the application seemed to have broken. It loaded but no windows were visible anymore.

I uninstalled it since I have no need for the application, I just wanted to see what the SNAP tool was.

Maybe check your logs for the SNAP application and it will give you more information on the error. I wasn't able to find anything useful for MacOS based on the screenshot you sent. There were similar errors on Linux, but people said it seemed to resolve itself after system/graphics driver updates. So, not helpful :(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants