Open
Conversation
Port the neomacs Rust display engine (winit + wgpu/Metal) to macOS
arm64 by resolving build-time conflicts and a runtime threading
constraint.
Build fixes:
- Suppress NS/Cocoa detection when --with-neomacs is set
- Skip EGL and xkbcommon checks on macOS (Metal and native key APIs)
- Use macOS frameworks instead of -ldl for linking
- Disable WPE WebKit (Linux-only) via --no-default-features in cargo
- Guard header typedefs to prevent conflicts between nsgui.h and
neomacsgui.h (XCharStruct, NativeRectangle, Display_Info, Emacs_Pixmap)
- Replace unavailable QCid symbol with intern_c_string(":id")
- Add xkbcommon include guard and get_keysym_name fallback for macOS
Runtime fix:
- Invert thread model on macOS where winit 0.30 requires EventLoop on
the main thread: main() hands control to Rust via a trampoline that
spawns Emacs on a child thread and runs the render loop on the main
thread, coordinated through a condvar-based handoff in
neomacs_display_init_threaded
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the broken callback/pthread approach with a pump_app_events design that lets Emacs stay on the main thread while driving winit. - EventLoop and RenderApp are created on the main thread in neomacs_open_display (called from Lisp) and stored in thread_local! - neomacs_read_socket calls neomacs_display_pump_macos_events(0) periodically to process winit events non-blockingly - about_to_wait writes to wakeup_fd when animations are active so Emacs keeps calling pump during crossfade/scroll/cursor transitions - ControlFlow::Wait (not Poll) lets Metal VSync pace frame delivery - Rate-limit pump calls in neomacs_read_socket to ~120 Hz (8 ms) to avoid busy-spinning when Emacs polls rapidly - about_to_wait uses WaitUntil(+8ms) during active rendering and WaitUntil(+16ms) when idle instead of the old 4ms Poll spin - wakeup_fd is written during animations to maintain smooth frame delivery without stalling while Emacs waits for keyboard input - Register atexit handler that uses try_with + std::mem::forget to skip RenderApp/EventLoop Drop at process exit, preventing winit's window_will_close ObjC callback from firing during TLS destruction - RenderApp::Drop also forgets the Window Arc as a safety net - Fix DO_CODESIGN detection in Makefile.in (was always empty because @configuration@ substituted to ""); use $(shell uname -s) instead - Add codesign steps after temacs copy and after pdump in Makefile.in - Remove old macOS callback globals and pthread integration code - Fix wakeup_fd shadowing bug in neomacs_open_display Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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.
Neomacs PR Checklist
Compatibility Checks
make -C test/neovm/vm-compat check-one-neovm,check-all-neovm, etc.).make -C test/neovm/vm-compat compat-progressand attached output in PR notes.make -C test/neovm/vm-compat check-stub-budgetand confirmedexplicitly annotated function stubsbudget expectations.make -C test/neovm/vm-compat checkorcheck-neovmoutputs for changed case lists.check-builtin-registry-*output (at leastcheck-builtin-registry-fboundp).