Fix crashes on macOS Apple Silicon (ARM64)#8
Open
thomaslestum wants to merge 2 commits intohsource:masterfrom
Open
Fix crashes on macOS Apple Silicon (ARM64)#8thomaslestum wants to merge 2 commits intohsource:masterfrom
thomaslestum wants to merge 2 commits intohsource:masterfrom
Conversation
Four separate issues prevented PoB from running on ARM64 macOS:
1. Native fullscreen crash (OpenGL context destroyed on transition)
- Add macos_window.mm with disableNativeFullscreen() that strips
NSWindowCollectionBehaviorFullScreenPrimary from the NSWindow,
making the green button zoom/maximize instead of entering native
fullscreen. Called via QTimer::singleShot(500ms) after show() —
must not be called from initializeGL() as winId() there disrupts
the GL surface.
- Also set Qt::WindowFullscreenButtonHint false in POBWindow ctor.
- Wire macos_window.mm into meson.build (objcpp language + AppKit).
2. Lua PANIC on any error ("error in error handling")
- l_PCall uses "traceback" from the Lua registry as its error
handler, but nothing ever stored it there. Any Lua error inside
PCall caused LUA_ERRERR -> unprotected lua_error -> PANIC.
- Fix: store debug.traceback in the registry after luaL_openlibs.
3. Crash on skill tree / tooltips (invalid font 'FONTIN')
- PoB's Lua code uses FONTIN, FONTIN ITALIC, FONTIN SC, and
FONTIN SC ITALIC throughout, but the fontMap in DrawString only
knew FIXED, VAR, and VAR BOLD. luaL_checkoption raised a Lua
error for any FONTIN call, which then hit bug hsource#2 -> PANIC.
- Fix: add all four FONTIN variants (mapped to Liberation Sans)
in DrawString, DrawStringWidth, and DrawStringCursorIndex.
4. Hardcoded SDK path breaks builds on most machines
- meson.build had -isysroot /Library/.../MacOSX12.3.sdk hardcoded,
failing on any machine without that exact SDK installed.
- Fix: remove the -isysroot flag; use the default host SDK.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Replace the hardcoded -isysroot SDK path with a dynamic xcrun call, based on the approach from alexogar/pobfrontend. This correctly resolves the SDK path on any machine regardless of Xcode/CommandLineTools version. Also apply SDK flags to the objcpp language (needed for macos_window.mm). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Author
|
Note: there is parallel work on this same problem in alexogar@91fb341 by @alexogar. Their commit focuses on the build pipeline (CI targeting macos-14, dynamic SDK path via xcrun, idempotent Makefile). I've incorporated the xcrun approach into this PR. The runtime fixes here (FONTIN fonts, debug.traceback, fullscreen) are not present in their branch — the two sets of changes are complementary. |
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.
Summary
Four separate issues prevented PoB from running reliably on ARM64 macOS (Apple Silicon). These were validated by building and running the app natively on an M-series Mac.
1. Native fullscreen crash (OpenGL context destroyed on transition)
When the green button triggers native macOS fullscreen, Qt5's
QOpenGLWindowdestroys and recreates the OpenGL context. PoB's Lua layer holds liveQOpenGLTexturereferences that become invalid, causing a Lua PANIC.macos_window.mm(Objective-C++) withdisableNativeFullscreen()that stripsNSWindowCollectionBehaviorFullScreenPrimaryfrom the NSWindow, making the green button zoom/maximize instead.QTimer::singleShot(500ms)aftershow()— must not be called frominitializeGL(), as callingwinId()there disrupts the active GL surface.Qt::WindowFullscreenButtonHintto false inPOBWindowconstructor as an additional guard.macos_window.mmintomeson.build(objcpplanguage +AppKitframework).2. Lua PANIC on any error ("error in error handling")
l_PCallretrieves"traceback"from the Lua registry to use as the error handler inlua_pcall. However, nothing ever stores it there — the field isnil. When any Lua error occurs insidePCall, the nil error handler causesLUA_ERRERR→ unprotectedlua_error→ PANIC, killing the process with no useful output.Fix: store
debug.tracebackin the registry immediately afterluaL_openlibs.3. Crash on skill tree / tooltips (invalid font 'FONTIN')
PoB's Lua code calls
DrawStringwith"FONTIN","FONTIN ITALIC","FONTIN SC", and"FONTIN SC ITALIC"throughout (these are the standard PoE UI fonts on Windows). ThefontMapinl_DrawStringonly declaredFIXED,VAR, andVAR BOLD.luaL_checkoptionraised a Lua error for every FONTIN call — which then hit bug #2 above, causing a silent PANIC.Fix: add all four FONTIN variants (mapped to Liberation Sans) in
DrawString,DrawStringWidth, andDrawStringCursorIndex.4. Hardcoded SDK path breaks builds on most machines
meson.buildhad-isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdkhardcoded, failing immediately on any machine without that exact SDK installed.Fix: remove the
-isysrootflag and use the default host SDK.Test plan
meson+ninja(no-pagezero_size/-image_baseflags needed on ARM64)🤖 Generated with Claude Code