Closed evayann closed 2 years ago
Thank you for working with me on this. There are a couple of things that surprise me here.
java.lang.UnsatisfiedLinkError: Can't load library: /Users/yannzavattero/Documents/Projects/py5/natives/macosx-universal/gluegen_rt
Seeing universal
is unexpected. After poking around in the Processing source code, I learned that there are such things are "universal" libraries for OSX machines.
Can you show me the full output of this command on your machine?
java -XshowSettings:properties -version
I'm particularly interested in the value of os.arch
.
The relevant py5 code is here. It is the only place where processing.natives.TestAppleSilicon
does anything.
Here's what confuses me: if System.getProperty("os.arch")
is equal to "universal"
, then wouldn't the if
statement on line 72 always be false, regardless of what processing.natives.TestAppleSilicon
is set to? If so, wouldn't your results be same when that add_options
line is used or not used? Is something changing System.getProperty("os.arch")
from "aarch64"
to "universal"
Somewhere? I don't see anything like that in the Processing code.
Can you try recreating that UnsatisfiedLinkError
exception and then run this python code:
import jpype
System = jpype.JClass("java.lang.System")
print(System.getProperty("os.arch"))
If something is changing it, this will show it.
Another thing I will ask you to try is this:
import py5_tools
py5_tools.add_options('-Dos.arch=x86_64')
import py5
def setup():
py5.size(500, 500, py5.P2D)
def draw():
py5.background(0.5)
py5.circle(250, 250, py5.sin(py5.frame_count / 100) * 50)
py5.run_sketch()
For the java -XshowSettings:properties -version
command, the output was :
$Property settings:
file.encoding = UTF-8
file.separator = /
ftp.nonProxyHosts = local|*.local|169.254/16|*.169.254/16
http.nonProxyHosts = local|*.local|169.254/16|*.169.254/16
java.class.path =
java.class.version = 61.0
java.home = /Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home
java.io.tmpdir = /var/folders/7x/dl2j91nd4_g1cl2t9479tr340000gn/T/
java.library.path = /Users/yannzavattero/Library/Java/Extensions
/Library/Java/Extensions
/Network/Library/Java/Extensions
/System/Library/Java/Extensions
/usr/lib/java
.
java.runtime.name = Java(TM) SE Runtime Environment
java.runtime.version = 17.0.2+8-LTS-86
java.specification.name = Java Platform API Specification
java.specification.vendor = Oracle Corporation
java.specification.version = 17
java.vendor = Oracle Corporation
java.vendor.url = https://java.oracle.com/
java.vendor.url.bug = https://bugreport.java.com/bugreport/
java.version = 17.0.2
java.version.date = 2022-01-18
java.vm.compressedOopsMode = Zero based
java.vm.info = mixed mode, sharing
java.vm.name = Java HotSpot(TM) 64-Bit Server VM
java.vm.specification.name = Java Virtual Machine Specification
java.vm.specification.vendor = Oracle Corporation
java.vm.specification.version = 17
java.vm.vendor = Oracle Corporation
java.vm.version = 17.0.2+8-LTS-86
jdk.debug = release
line.separator = \n
native.encoding = UTF-8
os.arch = aarch64
os.name = Mac OS X
os.version = 12.3
path.separator = :
socksNonProxyHosts = local|*.local|169.254/16|*.169.254/16
sun.arch.data.model = 64
sun.boot.library.path = /Library/Java/JavaVirtualMachines/jdk-17.0.2.jdk/Contents/Home/lib
sun.cpu.endian = little
sun.io.unicode.encoding = UnicodeBig
sun.java.launcher = SUN_STANDARD
sun.jnu.encoding = UTF-8
sun.management.compiler = HotSpot 64-Bit Tiered Compilers
sun.stderr.encoding = UTF-8
sun.stdout.encoding = UTF-8
user.country = FR
user.dir = /Users/yannzavattero/Documents/Projects/py5
user.home = /Users/yannzavattero
user.language = fr
user.name = yannzavattero
java version "17.0.2" 2022-01-18 LTS
Java(TM) SE Runtime Environment (build 17.0.2+8-LTS-86)
Java HotSpot(TM) 64-Bit Server VM (build 17.0.2+8-LTS-86, mixed mode, sharing)
So you can see the os.arch is set to aarch64
For the code
import jpype
System = jpype.JClass("java.lang.System")
print(System.getProperty("os.arch"))
the ouput is
Traceback (most recent call last):
File "/Users/yannzavattero/Documents/Projects/py5/test.py", line 3, in <module>
System = jpype.JClass("java.lang.System")
File "/opt/homebrew/lib/python3.9/site-packages/jpype/_jclass.py", line 99, in __new__
return _jpype._getClass(jc)
jpype._core.JVMNotRunning: Java Virtual Machine is not running
And for the last snippet
import py5_tools
py5_tools.add_options('-Dos.arch=x86_64')
import py5
def setup():
py5.size(500, 500, py5.P2D)
def draw():
py5.background(0.5)
py5.circle(250, 250, py5.sin(py5.frame_count / 100) * 50)
py5.run_sketch()
Output :
/opt/homebrew/bin/python3 /Users/yannzavattero/Documents/Projects/py5/py5_test.py
java.lang.UnsatisfiedLinkError: Can't load library: /Users/yannzavattero/Documents/Projects/py5/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)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:64)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:107)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:488)
at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:427)
at com.jogamp.common.os.Platform$1.run(Platform.java:321)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:290)
at com.jogamp.nativewindow.NativeWindowFactory$1.run(NativeWindowFactory.java:239)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at com.jogamp.nativewindow.NativeWindowFactory.<clinit>(NativeWindowFactory.java:236)
at com.jogamp.newt.NewtFactory$1.run(NewtFactory.java:69)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at com.jogamp.newt.NewtFactory.<clinit>(NewtFactory.java:66)
at processing.opengl.PSurfaceJOGL.initIcons(PSurfaceJOGL.java:475)
at processing.opengl.PSurfaceJOGL.initFrame(PSurfaceJOGL.java:147)
at processing.core.PApplet.initSurface(PApplet.java:10480)
at processing.core.PApplet.runSketch(PApplet.java:10386)
at org.jpype.proxy.JPypeProxy.hostInvoke(Native Method)
at org.jpype.proxy.JPypeProxy.invoke(Unknown Source)
at jdk.proxy2/jdk.proxy2.$Proxy8.run(Unknown Source)
at java.base/java.lang.Thread.run(Thread.java:833)
Can you try this:
import py5
System = jpype.JClass("java.lang.System")
print(System.getProperty("os.arch"))
def setup():
py5.size(500, 500, py5.P2D)
def draw():
py5.background(0.5)
py5.circle(250, 250, py5.sin(py5.frame_count / 100) * 50)
py5.run_sketch()
Then after you get the UnsatisfiedLinkError, do this again:
print(System.getProperty("os.arch"))
My guess is it will be aarch64
the first time and universal
the second time.
I don't succeed to make a print(System.getProperty("os.arch"))
again when UnsatisfiedLinkError is trigger.
But first time, the value is aarch64
I don't succeed to make a
print(System.getProperty("os.arch"))
again when UnsatisfiedLinkError is trigger. But first time, the value isaarch64
Why? Is Python crashing and preventing you from doing that?
Try this instead:
import py5
from java.lang import System
print(System.getProperty("os.arch"))
print(System.getProperty("java.library.path"))
This is helpful.
Python don't continue execution and still lock on UnstatisfiedLinkError.
aarch64
java.lang.UnsatisfiedLinkError: Can't load library: /Users/yannzavattero/Documents/Projects/py5/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)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:64)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:107)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:488)
at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:427)
at com.jogamp.common.os.Platform$1.run(Platform.java:321)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:290)
at com.jogamp.nativewindow.NativeWindowFactory$1.run(NativeWindowFactory.java:239)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at com.jogamp.nativewindow.NativeWindowFactory.<clinit>(NativeWindowFactory.java:236)
at com.jogamp.newt.NewtFactory$1.run(NewtFactory.java:69)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at com.jogamp.newt.NewtFactory.<clinit>(NewtFactory.java:66)
at processing.opengl.PSurfaceJOGL.initIcons(PSurfaceJOGL.java:475)
at processing.opengl.PSurfaceJOGL.initFrame(PSurfaceJOGL.java:147)
at processing.core.PApplet.initSurface(PApplet.java:10480)
at processing.core.PApplet.runSketch(PApplet.java:10386)
at org.jpype.proxy.JPypeProxy.hostInvoke(Native Method)
at org.jpype.proxy.JPypeProxy.invoke(Unknown Source)
at jdk.proxy2/jdk.proxy2.$Proxy8.run(Unknown Source)
at java.base/java.lang.Thread.run(Thread.java:833)
For the following code
import py5
from java.lang import System
print(System.getProperty("os.arch"))
print(System.getProperty("java.library.path"))
I have the output
aarch64
/Users/yannzavattero/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:.:/opt/homebrew/lib/python3.9/site-packages/py5/natives/macos-x86_64
Aha! I think I see what is going on.
From your earlier message 2 hours ago, you have
java.library.path = /Users/yannzavattero/Library/Java/Extensions
/Library/Java/Extensions
/Network/Library/Java/Extensions
/System/Library/Java/Extensions
/usr/lib/java
.
When you import py5, py5 is correctly adding /opt/homebrew/lib/python3.9/site-packages/py5/natives/macos-x86_64
to the end. However, Processing is trying to load the library from /Users/yannzavattero/Documents/Projects/py5/natives/macosx-universal/
, which is a subdirectory of the current working directory the py5_test.py file is in. The .
in your java.library.path is in front of what py5 is adding to the path. Maybe if that is removed it will stop looking in the current directory? Can you try this:
import py5
from java.lang import System
# remove . from java.library.path
System.setProperty("java.library.path", "/Users/yannzavattero/Library/Java/Extensions:/Library/Java/Extensions:/Network/Library/Java/Extensions:/System/Library/Java/Extensions:/usr/lib/java:/opt/homebrew/lib/python3.9/site-packages/py5/natives/macos-x86_64")
def setup():
py5.size(500, 500, py5.P2D)
def draw():
py5.background(0.5)
py5.circle(250, 250, py5.sin(py5.frame_count / 100) * 50)
py5.run_sketch()
If that doesn't work and you still get the same exact error, can you try copying the contents of /opt/homebrew/lib/python3.9/site-packages/py5/natives/macos-x86_64/
to a new directory /Users/yannzavattero/Documents/Projects/py5/natives/macosx-universal/
? This will at least tell us if it will work if it can find the native libraries.
The code snippet don't work sorry... I copy the content of the repertory like this :
And isn't better...
Still don't find the lib...
java.lang.UnsatisfiedLinkError: Can't load library: /Users/yannzavattero/Documents/Projects/py5/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)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:64)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:107)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:488)
at com.jogamp.common.os.DynamicLibraryBundle$GlueJNILibLoader.loadLibrary(DynamicLibraryBundle.java:427)
at com.jogamp.common.os.Platform$1.run(Platform.java:321)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at com.jogamp.common.os.Platform.<clinit>(Platform.java:290)
at com.jogamp.nativewindow.NativeWindowFactory$1.run(NativeWindowFactory.java:239)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at com.jogamp.nativewindow.NativeWindowFactory.<clinit>(NativeWindowFactory.java:236)
at com.jogamp.newt.NewtFactory$1.run(NewtFactory.java:69)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at com.jogamp.newt.NewtFactory.<clinit>(NewtFactory.java:66)
at processing.opengl.PSurfaceJOGL.initIcons(PSurfaceJOGL.java:475)
at processing.opengl.PSurfaceJOGL.initFrame(PSurfaceJOGL.java:147)
at processing.core.PApplet.initSurface(PApplet.java:10480)
at processing.core.PApplet.runSketch(PApplet.java:10386)
at org.jpype.proxy.JPypeProxy.hostInvoke(Native Method)
at org.jpype.proxy.JPypeProxy.invoke(Unknown Source)
at jdk.proxy2/jdk.proxy2.$Proxy8.run(Unknown Source)
at java.base/java.lang.Thread.run(Thread.java:833)
Hmmmm. I'm running out of ideas.
If you haven't done so already, can you download and install the Processing IDE from https://processing.org/download for Macs, and then run this simple Sketch through Processing:
size(200, 200, P2D);
println(System.getProperty("java.library.path"));
In the output you might see a directory name with macosx-universal
in it. If so, can you tell me the contents of that directory?
I have already installed processing. The result of
size(200, 200, P2D);
println(System.getProperty("java.library.path"));
is
:/Applications/Processing.app/Contents/Java/core/library/macos-x86_64:/Applications/Processing.app/Contents/MacOS
When I open the repository of macOS-x86_64, I have this element (same as in py5).
I try to copy past the content of this repo in my natives, macosx-universal but isn't better...
In /Applications/Processing.app/Contents/MacOS
, I just have the Processing application.
Have you installed Rosetta on your machine? I've done some research and it doesn't seem like it is installed by default.
Can you try running Sketches through Jupyter notebook instead of the generic Python interpreter? On OSX, if a Sketch is run through the generic Python interpreter, closing the Sketch will kill the Python process. This prevents any analysis of the situation after the Sketch is launched or an exception is thrown. However, if a Sketch is run through a Jupyter notebook, you can execute other cells while the Sketch is running or after it dies.
What you can do is run this series of notebook cells, one at a time:
%gui osx
then
import py5
from java.lang import System
print(System.getProperty("os.arch"))
print(System.getProperty("java.library.path"))
then run the Sketch
def setup():
py5.size(500, 500, py5.P2D)
def draw():
py5.background(0.5)
py5.circle(250, 250, py5.sin(py5.frame_count / 100) * 50)
py5.run_sketch()
while the Sketch is running, or after the exception is thrown, do this again:
print(System.getProperty("os.arch"))
print(System.getProperty("java.library.path"))
I'm convinced os.arch
will change from aarch64
to universal
.
The second problem is that OSX has this thing called "universal binaries" that can be created with the lipo
terminal command. The exception is being thrown because Processing is looking for these universal binaries but they are simply not on your machine anywhere. I'm not sure where they are supposed to come from.
https://developer.apple.com/documentation/apple-silicon/building-a-universal-macos-binary
I've been experimenting with pyinstaller and writing documentation for how package a py5 Sketch. My documentation works well Linux but does not work for OSX. When I run a packaged Sketch that uses the P2D renderer, I get this exception:
java.lang.UnsatisfiedLinkError: Can't load library: /private/tmp/test/dist/simple/natives/macosx-universal/nativewindow_awt
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)
at com.jogamp.common.jvm.JNILibLoaderBase.access$000(JNILibLoaderBase.java:64)
at com.jogamp.common.jvm.JNILibLoaderBase$DefaultAction.loadLibrary(JNILibLoaderBase.java:107)
at com.jogamp.common.jvm.JNILibLoaderBase.loadLibrary(JNILibLoaderBase.java:488)
at jogamp.nativewindow.NWJNILibLoader.access$000(NWJNILibLoader.java:39)
at jogamp.nativewindow.NWJNILibLoader$1.run(NWJNILibLoader.java:49)
at jogamp.nativewindow.NWJNILibLoader$1.run(NWJNILibLoader.java:41)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at jogamp.nativewindow.NWJNILibLoader.loadNativeWindow(NWJNILibLoader.java:41)
at jogamp.nativewindow.jawt.JAWTUtil.<clinit>(JAWTUtil.java:345)
at java.base/java.lang.Class.forName0(Native Method)
at java.base/java.lang.Class.forName(Class.java:467)
at com.jogamp.nativewindow.NativeWindowFactory$2.run(NativeWindowFactory.java:405)
at com.jogamp.nativewindow.NativeWindowFactory$2.run(NativeWindowFactory.java:401)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at com.jogamp.nativewindow.NativeWindowFactory.initSingleton(NativeWindowFactory.java:401)
at com.jogamp.newt.NewtFactory$1.run(NewtFactory.java:69)
at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
at com.jogamp.newt.NewtFactory.<clinit>(NewtFactory.java:66)
at processing.opengl.PSurfaceJOGL.initIcons(PSurfaceJOGL.java:475)
at processing.opengl.PSurfaceJOGL.initFrame(PSurfaceJOGL.java:147)
at processing.core.PApplet.initSurface(PApplet.java:10480)
at processing.core.PApplet.runSketch(PApplet.java:10386)
at org.jpype.proxy.JPypeProxy.hostInvoke(Native Method)
at org.jpype.proxy.JPypeProxy.invoke(Unknown Source)
at jdk.proxy2/jdk.proxy2.$Proxy8.run(Unknown Source)
at java.base/java.lang.Thread.run(Thread.java:833)
Observe it can't find a macosx-universal
library. This is on my non-Apple Silicon machine. Confusing, but perhaps it will give me a chance to understand where universal
is coming from.
py5 version 0.6.0 worked fine on Apple Silicon and I believe 0.7.0 worked also. The Processing team started making changes to use native opengl libraries on Apple Silicon, and those efforts are a work in progress. I need to understand what those changes are to repair py5 on that hardware.
The P2D and P3D renderers now work on Apple Silicon, as per tests done in issue #87. The error message in #87 will be resolved in the next release.
On my Mac Book Air M1 (2020), I run the following code :
When I running this program, I can see the sketch window appear and directly disappear. On terminal I have a
zsh trace trap
. With some search, this appear when exception isn't catch. More information here. And this exception can be due to NSException like it said here.If I don't use native Apple Silicon Lib to use Intel Lib instead. ie Remove line add_options ... . I have the following exception :