Universal (Apple Silicon + Intel) build without Xcode - #9
Open
trackme518 wants to merge 2 commits into
Open
trackme518 wants to merge 2 commits into
trackme518 wants to merge 2 commits into
Conversation
Apple removed JavaNativeFoundation and JavaVM headers from the macOS SDK, so the Xcode project can no longer link the JNI library, and the shipped x86_64-only binaries fail to load on arm64 JVMs. - build_universal.sh: builds Syphon and libJSyphon.jnilib as universal (x86_64 + arm64) with the Command Line Tools only; statically links the vendored JavaNativeFoundation sources (apple/openjdk xcodejdk14-release, APSL 2.0) instead of the removed system framework; ad-hoc code signs. - Vendored JavaNativeFoundation sources under JSyphon/native_src/jnf. - Replace removed <JavaVM/...> imports with <jni.h> in JNI sources. - Build Syphon with -DSYPHON_CORE_RESTORE: restores GL state (VAO etc.) around core-profile publishing. Apple's driver shares these bindings across share-group contexts, so without it Processing's shader validation failed with 'No vertex array object bound'. - tests/vao_test.m: regression test for the VAO binding restore. - Rebuilt jsyphon.jar and universal native_libs binaries. - Bump Syphon-Framework to f476167 (post-5.0 main): adds Apple Silicon 32BGRA pixel format fix and core-profile improvements. Tested on macOS 26 (arm64 and x86_64 via Rosetta) with Processing 4.5.6.
trackme518
force-pushed
the
universal-binary-support
branch
from
September 21, 2026 14:32
d46c515 to
1fe588e
Compare
On Apple Silicon (and recent Intel macOS) the OpenGL implementation backs GL with Metal and shares some per-context state (texture unit bindings, blend, VAO/FBO bindings) between contexts in a share group. Publishing a frame draws a quad on the server's context, which silently clobbers state the calling context relies on: after one publish, Processing draws subsequent image() calls with corrupted vertex attributes (flat color or wrong size). - JNI: capture and re-apply the full state set Syphon may touch (active texture unit, 2D/rectangle texture bindings on units 0-3, VAO, read/draw FBO, renderbuffer, array/element buffers, viewport, scissor, blend, current program) around publishFrameTexture. No copies, no sync stalls. - Syphon-Framework: extend SYPHON_CORE_RESTORE in SyphonServerRendererCoreGL drawFrameTexture to also save/restore active texture unit, unit-0 texture bindings, viewport and blend (previously only the target texture binding was restored, and that from the wrong unit when the caller had a unit other than 0 active).
Author
Update: GL state restore fix (a5ad314)The universal build worked on Apple Silicon, but any draw on the Processing context after This commit:
Verified: minimal repro (offscreen P2D published once, then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Added support for macOS Apple Silicon (arm64), while remaining compatible with Intel macOS
The shipped
native_libsbinaries are x86_64-only, so they fail to load in arm64 JVMs (e.g. Processing 4 on Apple Silicon). Compiling with the current Xcode project is also impossible on modern macOS: Apple removed theJavaVM/JavaNativeFoundationframeworks and their headers from the SDK.Changes
JSyphon/native_src/build_universal.sh– new script that buildsSyphonandlibJSyphon.jnilibas universal (x86_64+arm64) binaries using only the Command Line Tools and a JDK (forjni.h) — no Xcode required. Results are ad-hoc code signed.JSyphon/native_src/jnf/– vendored JavaNativeFoundation sources (fromapple/openjdk,xcodejdk14-release, APSL 2.0), compiled statically intolibJSyphon.jnilibto replace the removed system framework.<JavaVM/JavaVM.h>/<JavaVM/jni.h>imports with<jni.h>.-DSYPHON_CORE_RESTORE– the upstream state-restore code paths were never enabled in the Xcode build. Without them, Apple's OpenGL driver (which shares VAO/FBO/VBO bindings across share-group contexts) corrupts the host app's GL state when publishing frames from a core-profile context. This causedRuntimeException: Cannot validate shader program: Validation Failed: No vertex array object bound.in Processing P3D.tests/vao_test.mis a regression test for it.c404f3c(v5) →f476167(post-5.0 tip ofmain, +99 commits): ARC conversion, modern atomics,Explicitly set pixel format type to 32BGRAand other Apple-Silicon-relevant fixes, Metal server/client support.jsyphon.jar(unchanged bytecode, Java 8 target) and universalnative_libs/{Syphon,libJSyphon.jnilib}.Verification
lipo -infoshowsx86_64 arm64for both native binaries; both are code-signed.JSyphonServerList, server publish and client receive verified on arm64, and on x86_64 via Rosetta (vao_test.mpasses on both: host VAO binding preserved, no GL errors).SendFrames,ReceiveFrames,SendScreenexamples).