cljfx

ts1503 2023-03-21T15:13:59.400919Z

hello guys. I’m trying to write a simple app with cljfx but faced with a blocker issue related to the JavaFX and Apple M1 Loading library prism_es2 from resource failed: java.lang.UnsatisfiedLinkError: /Users/ts1503/.openjfx/cache/17.0.2-ea/libprism_es2.dylib: dlopen(/Users/ts1503/.openjfx/cache/17.0.2-ea/libprism_es2.dylib, 0x0001): tried: '/Users/ts1503/.openjfx/cache/17.0.2-ea/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/ts1503/.openjfx/cache/17.0.2-ea/libprism_es2.dylib' (no such file), '/Users/ts1503/.openjfx/cache/17.0.2-ea/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')) java.lang.UnsatisfiedLinkError: /Users/ts1503/.openjfx/cache/17.0.2-ea/libprism_es2.dylib: dlopen(/Users/ts1503/.openjfx/cache/17.0.2-ea/libprism_es2.dylib, 0x0001): tried: '/Users/ts1503/.openjfx/cache/17.0.2-ea/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/ts1503/.openjfx/cache/17.0.2-ea/libprism_es2.dylib' (no such file), '/Users/ts1503/.openjfx/cache/17.0.2-ea/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')) I know it’s not related to cljfx directly but I’m struggling to find useful tutorials or guides on how to update JavaFX on my machine I downloaded JavaFX 17-ea+8 from repo. How to tell JDK to use that version instead of .openjfx/cache ? Would be really appreciate for some links. Thanks

vlaaad 2023-03-21T15:25:03.821039Z

in your dependency management file (proejct.clj or deps.edn), you should specify explicit dependencies on javafx

vlaaad 2023-03-21T15:25:47.993599Z

like what cljfx itself does https://github.com/cljfx/cljfx/blob/master/deps.edn#L2-L6

ts1503 2023-03-21T15:25:52.293319Z

I’m using project.clj

vlaaad 2023-03-21T15:25:54.141209Z

but depend on the version you need

vlaaad 2023-03-21T15:26:26.283159Z

then it will be in a bit different syntax, e.g. [org.openjfx/javafx-controls "17-ea+8"]

ts1503 2023-03-21T15:28:45.705759Z

let me try

ts1503 2023-03-21T15:32:30.615229Z

so I updated libraries

ts1503 2023-03-21T15:33:10.976479Z

error is still the same but refers to the new path .openjfx/cache/17-ea/

ts1503 2023-03-21T15:34:26.028029Z

Loading library prism_es2 from resource failed: java.lang.UnsatisfiedLinkError: /Users/ts1503/.openjfx/cache/17-ea/libprism_es2.dylib: dlopen(/Users/ts1503/.openjfx/cache/17-ea/libprism_es2.dylib, 0x0001): tried: '/Users/ts1503/.openjfx/cache/17-ea/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/ts1503/.openjfx/cache/17-ea/libprism_es2.dylib' (no such file), '/Users/ts1503/.openjfx/cache/17-ea/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
java.lang.UnsatisfiedLinkError: /Users/ts1503/.openjfx/cache/17-ea/libprism_es2.dylib: dlopen(/Users/ts1503/.openjfx/cache/17-ea/libprism_es2.dylib, 0x0001): tried: '/Users/ts1503/.openjfx/cache/17-ea/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/ts1503/.openjfx/cache/17-ea/libprism_es2.dylib' (no such file), '/Users/ts1503/.openjfx/cache/17-ea/libprism_es2.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
	at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
	at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174)
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2389)
	at java.base/java.lang.Runtime.load0(Runtime.java:755)
	at java.base/java.lang.System.load(System.java:1953)
	at com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:214)
	at com.sun.glass.utils.NativeLibLoader.loadLibraryFromResource(NativeLibLoader.java:194)
	at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:135)
	at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:53)
	at com.sun.prism.es2.ES2Pipeline.lambda$static$0(ES2Pipeline.java:62)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
	at com.sun.prism.es2.ES2Pipeline.<clinit>(ES2Pipeline.java:51)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:375)
	at com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:218)
	at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:91)
	at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
	at java.base/java.lang.Thread.run(Thread.java:833)
Loading library prism_sw from resource failed: java.lang.UnsatisfiedLinkError: /Users/ts1503/.openjfx/cache/17-ea/libprism_sw.dylib: dlopen(/Users/ts1503/.openjfx/cache/17-ea/libprism_sw.dylib, 0x0001): tried: '/Users/ts1503/.openjfx/cache/17-ea/libprism_sw.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/ts1503/.openjfx/cache/17-ea/libprism_sw.dylib' (no such file), '/Users/ts1503/.openjfx/cache/17-ea/libprism_sw.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
java.lang.UnsatisfiedLinkError: /Users/ts1503/.openjfx/cache/17-ea/libprism_sw.dylib: dlopen(/Users/ts1503/.openjfx/cache/17-ea/libprism_sw.dylib, 0x0001): tried: '/Users/ts1503/.openjfx/cache/17-ea/libprism_sw.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/System/Volumes/Preboot/Cryptexes/OS/Users/ts1503/.openjfx/cache/17-ea/libprism_sw.dylib' (no such file), '/Users/ts1503/.openjfx/cache/17-ea/libprism_sw.dylib' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64'))
	at java.base/jdk.internal.loader.NativeLibraries.load(Native Method)
	at java.base/jdk.internal.loader.NativeLibraries$NativeLibraryImpl.open(NativeLibraries.java:388)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:232)
	at java.base/jdk.internal.loader.NativeLibraries.loadLibrary(NativeLibraries.java:174)
	at java.base/java.lang.ClassLoader.loadLibrary(ClassLoader.java:2389)
	at java.base/java.lang.Runtime.load0(Runtime.java:755)
	at java.base/java.lang.System.load(System.java:1953)
	at com.sun.glass.utils.NativeLibLoader.installLibraryFromResource(NativeLibLoader.java:214)
	at com.sun.glass.utils.NativeLibLoader.loadLibraryFromResource(NativeLibLoader.java:194)
	at com.sun.glass.utils.NativeLibLoader.loadLibraryInternal(NativeLibLoader.java:135)
	at com.sun.glass.utils.NativeLibLoader.loadLibrary(NativeLibLoader.java:53)
	at com.sun.prism.sw.SWPipeline.lambda$static$0(SWPipeline.java:42)
	at java.base/java.security.AccessController.doPrivileged(AccessController.java:318)
	at com.sun.prism.sw.SWPipeline.<clinit>(SWPipeline.java:41)
	at java.base/java.lang.Class.forName0(Native Method)
	at java.base/java.lang.Class.forName(Class.java:375)
	at com.sun.prism.GraphicsPipeline.createPipeline(GraphicsPipeline.java:218)
	at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.init(QuantumRenderer.java:91)
	at com.sun.javafx.tk.quantum.QuantumRenderer$PipelineRunnable.run(QuantumRenderer.java:124)
	at java.base/java.lang.Thread.run(Thread.java:833)
Graphics Device initialization failed for :  es2, sw
Error initializing QuantumRenderer: no suitable pipeline found
java.lang.RuntimeException: java.lang.RuntimeException: Error initializing QuantumRenderer: no suitable pipeline found

vlaaad 2023-03-21T15:42:42.282479Z

do you use arm jdk?

vlaaad 2023-03-21T15:44:12.950649Z

is it possible that you launch this program using e.g. arm build of intellij idea that uses x64 jdk?

ts1503 2023-03-21T15:46:06.496159Z

openjdk version “17.0.6” 2023-01-17 OpenJDK Runtime Environment Homebrew (build 17.0.6+0) OpenJDK 64-Bit Server VM Homebrew (build 17.0.6+0, mixed mode, sharing)

ts1503 2023-03-21T15:46:26.806529Z

this is printed from java --version

ts1503 2023-03-21T15:46:54.549109Z

I installed it with brew install openjdk@17

ts1503 2023-03-21T15:48:52.164859Z

ts1503 2023-03-21T15:49:09.277899Z

I choose this version in intellij

ts1503 2023-03-21T15:57:25.874949Z

you might be right here

ts1503 2023-03-21T15:58:02.147119Z

I tried lein repl and error seems to gone

ts1503 2023-03-21T16:02:36.229299Z

or maybe not. lein repl starts but when I’m trying to render something it fails

2023-03-21 17:01:22.166 java[38812:8133311] *** Assertion failure in -[_NSTrackingAreaAKViewHelper removeTrackingRect:], _NSTrackingAreaAKManager.m:1613
2023-03-21 17:01:22.168 java[38812:8133311] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '0x0 is an invalid NSTrackingRectTag. Common possible reasons for this are: 1. already removed this trackingRectTag, 2. Truncated the NSTrackingRectTag to 32bit at some point.'

ts1503 2023-03-21T16:44:30.428049Z

So I switched to JDK 19.0.2 and javafx 20-ea+19 and now it works from lein repl. but still doesn’t work if I run repl from intellij

ts1503 2023-03-21T16:44:56.690119Z

I think I can live with it for now. Thanks

vlaaad 2023-03-21T16:55:14.090829Z

Glad you got it working for you

vlaaad 2023-03-21T16:55:29.425879Z

We had this issue at work. It looks like a bug in cursive

ts1503 2023-03-21T16:55:56.318549Z

maybe it because it still using rosetta?

ts1503 2023-03-21T16:56:27.988729Z

but not sure

ts1503 2023-03-21T16:56:37.064039Z

anyway, thank you

vlaaad 2023-03-21T16:57:36.663589Z

It seems cursive uses intellij's own arm JVM when calculating classpath, but in case of javafx the classpath depends on the JVM used to calculate classpath where it selects arm vs x64 dependencies to use

vlaaad 2023-03-21T16:59:14.421409Z

So far we found 2 workarounds: start the JVM from the terminal so the classpath is calculated using the same JVM, or use x64 idea — you can download it on their site