Open AvneeshSarwate opened 2 years ago
Hi. I'll be honest I haven't kept up with Java intricacies or changes in the mean time. Feel free to provide a PR with documentation updates, it would be appreciated! If you get it building, we can use the instructions to provide release for M1
Got it, I can take a shot at a new build. To build against the newest version of https://github.com/Syphon/Syphon-Framework and https://github.com/Syphon/Shared, would any changes to the Java source in this repo be necessary?
@AvneeshSarwate just looked at this briefly and seems like the gen_headers.sh could be fixed by using '''javac -h''' (whih is the replacement of javah) to read the source java files:
cd ../src
javac -h . jsyphon/JSyphonClient.java
javac -h . jsyphon/JSyphonImage.java
javac -h . jsyphon/JSyphonServer.java
javac -h . jsyphon/JSyphonServerList.java
mv jsyphon_*.h ../native_src/
cd ../native_src
I still need to review the rest of the build process.
Another issue is that some header files are no longer available on recent MacOS versions:
@vade just flagging this issue, will try to look at it again at a later time.
I think Java hasn't been included in macOS for some time, and the SDK has to be installed via something like https://adoptium.net (found via https://wolfpaulus.com/installing-java-on-macos/)
This likely changes some includes and complicates things?
Yes, I was testing things with Adoptium JDK 17 on macOS 13. It comes with a headers folder, including jni.h but not JavaVM.h so need to investigate further.
I've started a branch here working on supporting Apple silicon.
I tried to make everything cross-architecture but failed in the Xcode project itself, I think we need to different builds in Xcode, one for ARM and one for non-ARM. The ARM one needs to link to libjni.dylib
from the Microsoft openjdk (assuming that's what we go with) which it tries to do atm (user needs to download and install it, I added instructions in the README), and the non-ARM needs the JavaVM
and JavaNativeFoundation
frameworks added back in.
Here's what's updated:
JNF_COCOA_E{NTER,XIT} -> JNI_COCOA_E{NTER,XIT}
which is just #define
d in jsyphon_imports.h
to reduce code change in the .m
s)master
to main
)Still need to fix JNFJavaToNSString
and JNFNSToJavaString
which I pointed to JavaStringToNSString
and NSStringToJavaString
respectively, but those are part of the standard openjdk, not Microsoft's version, but I haven't found a build of the standard for macOS so we may want to try to build it or see how we can use the proper strings for Microsoft's.
Feel free to work on this PR if anyone wants to take a stab at the string portion!
Also note to get away from JNFDefaultCoercion
and some of the other changes, some were based on following errors and others I was attempting to implement based on how I saw things done in the various JDK-issues and git commits linked here, I then went to every related JDK issue and hit every git commit to see what they adjusted, specifically:
.m
s :)$ sh install.sh
...
...
** BUILD SUCCEEDED **
$
Builds are succeeding! Though I haven't looked at how it plugs into the other repos and no idea if it actually works :)
Also added an install.sh
that does everything, including installing Apache Ant, MS Openjdk, and downloading openjdk/jdk (only if needed -- multiple runs are supported). Cleaned up README a little as well.
Can someone see if this is actually working or if we need more changes? I've submitted PR #8
Okay, still needs some work, here it is using ARM Processing 4.2 + ARM Syphon bins w/SendFrames.pde + ReceiveFrames.pde. Note I adjusted the following since the PR (not sure if any were necessary)
JSyphon/native_src/gen_headers.sh
to use javac
directly from Processingtags/jdk-17+10
from github.com/openjdk/jdkSendFrames.pde (appears to work and displays when ReceiveFrames attempts to connect)
Syphon 4.0 by Andres Colubri, Tom Butterworth, Anton Marini http://syphon.v002.info/
2023-06-30 12:52:25.941 java[58867:11726023] SYPHON DEBUG: SyphonServerConnectionManager: Start Connection
2023-06-30 12:52:25.941 java[58867:11726023] SYPHON DEBUG: SyphonServerConnectionManager: Created connection with UUID: info.v002.Syphon.367667E0-5704-49B4-B5EF-20742F360AC6
2023-06-30 12:52:25.941 java[58867:11726023] SYPHON DEBUG: SyphonServerRendererCoreGL: SYPHON_CORE_SHARE
2023-06-30 12:52:37.872 java[58867:11725851] SYPHON DEBUG: SyphonServer: Got Discovery Request
2023-06-30 12:52:37.947 java[58867:11725865] SYPHON DEBUG: SyphonServerConnectionManager: Add info client: info.v002.Syphon.35EBF559-D51F-4C00-B719-50340D24BCDF
ReceiveFrames.pde
Syphon 4.0 by Andres Colubri, Tom Butterworth, Anton Marini http://syphon.v002.info/
2023-06-30 12:52:37.947 java[58882:11726182] SYPHON DEBUG: SyphonClientConnectionManager: Registering for info updates
2023-06-30 12:52:38.044 java[58882:11726314] -[__NSDictionaryI UTF8String]: unrecognized selector sent to instance 0x60000064a3c0
2023-06-30 12:52:38.045 java[58882:11726314] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSDictionaryI UTF8String]: unrecognized selector sent to instance 0x60000064a3c0'
*** First throw call stack:
(
0 CoreFoundation 0x00000001934b7154 __exceptionPreprocess + 176
1 libobjc.A.dylib 0x0000000192fd64d4 objc_exception_throw + 60
2 CoreFoundation 0x000000019355e110 -[NSObject(NSObject) __retain_OA] + 0
3 CoreFoundation 0x000000019341f0a0 ___forwarding___ + 1600
4 CoreFoundation 0x000000019341e9a0 _CF_forwarding_prep_0 + 96
5 libJSyphon.jnilib 0x00000001693d1aa8 Java_jsyphon_JSyphonClient_newFrameDataForContext + 628
6 ??? 0x00000001133dbbe0 0x0 + 4617780192
7 ??? 0x00000001133d6270 0x0 + 4617757296
8 ??? 0x00000001133d6270 0x0 + 4617757296
9 ??? 0x00000001133d6270 0x0 + 4617757296
10 ??? 0x00000001133d6270 0x0 + 4617757296
11 ??? 0x00000001133d66ac 0x0 + 4617758380
12 ??? 0x00000001133d66ac 0x0 + 4617758380
13 ??? 0x00000001133d709c 0x0 + 4617760924
14 ??? 0x00000001133d66ac 0x0 + 4617758380
15 ??? 0x00000001133d66ac 0x0 + 4617758380
16 ??? 0x00000001133d709c 0x0 + 4617760924
17 ??? 0x00000001133d66ac 0x0 + 4617758380
18 ??? 0x00000001133d66ac 0x0 + 4617758380
19 ??? 0x00000001133d709c 0x0 + 4617760924
20 ??? 0x00000001133d709c 0x0 + 4617760924
21 ??? 0x00000001133d66ac 0x0 + 4617758380
22 ??? 0x00000001133d66ac 0x0 + 4617758380
23 ??? 0x00000001133d66ac 0x0 + 4617758380
24 ??? 0x00000001133d0140 0x0 + 4617732416
25 libjvm.dylib 0x000000010386d330 _ZN9JavaCalls11call_helperEP9JavaValueRK12methodHandleP17JavaCallArgumentsP10JavaThread + 908
26 libjvm.dylib 0x000000010386c34c _ZN9JavaCalls12call_virtualEP9JavaValueP5KlassP6SymbolS5_P17JavaCallArgumentsP10JavaThread + 284
27 libjvm.dylib 0x000000010386c418 _ZN9JavaCalls12call_virtualEP9JavaValue6HandleP5KlassP6SymbolS6_P10JavaThread + 100
28 libjvm.dylib 0x000000010392445c _ZL12thread_entryP10JavaThreadS0_ + 196
29 libjvm.dylib 0x0000000103da7464 _ZN10JavaThread17thread_main_innerEv + 336
30 libjvm.dylib 0x0000000103da5aec _ZN6Thread8call_runEv + 224
31 libjvm.dylib 0x0000000103bc613c _ZL19thread_native_entryP6Thread + 344
32 libsystem_pthread.dylib 0x000000019335ffa8 _pthread_start + 148
33 libsystem_pthread.dylib 0x000000019335ada0 thread_start + 8
)
libc++abi: terminating due to uncaught exception of type NSException
Could not run the sketch (Target VM failed to initialize).
For more information, read Help → Troubleshooting.
@samyk thanks so much for taking a stab at this! Judging from your last couple of updates, seems like you figured out how to get this Java library into the Processing library, essentially you have to pull Syphon Java as a submodule into the Processing library source, as explained in the readme:
https://github.com/Syphon/Processing#getting-started
I'm not able to look at it in detail at this moment, but it sounds like when you try running the updated library in Processing, the client sketch crashes with the errors you posted above, before showing any frames from the server, correct?
Correct, I manually finagled the files/dirs in the Processing repo in order to get the right versions (since git would pull down the original), and I think I ultimately updated the Processing .zip with the binaries (and file
'd them to ensure they were all the correct architecture) -- before this I was not able to get Processing to run at all with the plugin. Steps once running Processing:
I suspect the issue is with the removal of JNFVectorCoercion
I mention in a prior note as I didn't really know how the code was operating or behaving on the underlying types, and I was copying/pasting and trying to correlate things but I had high suspicion that I did that piece wrong. I was mostly trying to copy how I saw the changes occurred here: https://github.com/openjdk/jdk/commit/4a8b5c16
Hey! Just chiming in to say I really appreciate all the diligent work here. I haven't touched Java or the P5 stuff in a hot minute, and it's great to have folks hacking on it. Sincerely appreciate it.
Thank you @samyk @codeanticode !
Hi, I posted in https://github.com/Syphon/Processing/issues/45 and was directed to this thread. Is there a very short summary of how I can install the Apple M1 update? And I'd love to understand exactly which files need updating: is it the contents of the Processing library (in ~/Documents/Processing/Libraries) or is this stuff that is installed deeper down?
@orsjb if you just want things to work, you can use the x86 version of Processing on your M1 (runs via Rosetta), and use the standard Syphon library. The goal here is to get a Syphon+Processing to be native on M1 without Rosetta
Is there any update on an Apple Silicon compatible version of the Syphon lib for Java? How can we help to have this? Where to start?
Latest updates are in this branch and documented in this thread above, no changes since then so please feel free to improve from there!
I am trying to build the library for M1 macs (pulling the latest Syphon-Framework branch), but the build instructions seem to be outdated (https://stackoverflow.com/questions/50352098/javah-missing-after-jdk-install) - it seems
javah
is no longer distributed with the JDK (in favor ofjavac -h
). Would it be possible to update the build instructions and/or provide updatednative_libs
artifacts?