Skip to content

Fix crashes on macOS Apple Silicon (ARM64)#8

Open
thomaslestum wants to merge 2 commits intohsource:masterfrom
thomaslestum:fix/apple-silicon-arm64
Open

Fix crashes on macOS Apple Silicon (ARM64)#8
thomaslestum wants to merge 2 commits intohsource:masterfrom
thomaslestum:fix/apple-silicon-arm64

Conversation

@thomaslestum
Copy link

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 QOpenGLWindow destroys and recreates the OpenGL context. PoB's Lua layer holds live QOpenGLTexture references that become invalid, causing a Lua PANIC.

  • Add macos_window.mm (Objective-C++) with disableNativeFullscreen() that strips NSWindowCollectionBehaviorFullScreenPrimary from the NSWindow, making the green button zoom/maximize instead.
  • Called via QTimer::singleShot(500ms) after show()must not be called from initializeGL(), as calling winId() there disrupts the active GL surface.
  • Also set Qt::WindowFullscreenButtonHint to false in POBWindow constructor as an additional guard.
  • Wire macos_window.mm into meson.build (objcpp language + AppKit framework).

2. Lua PANIC on any error ("error in error handling")

l_PCall retrieves "traceback" from the Lua registry to use as the error handler in lua_pcall. However, nothing ever stores it there — the field is nil. When any Lua error occurs inside PCall, the nil error handler causes LUA_ERRERR → unprotected lua_errorPANIC, killing the process with no useful output.

Fix: store debug.traceback in the registry immediately after luaL_openlibs.

3. Crash on skill tree / tooltips (invalid font 'FONTIN')

PoB's Lua code calls DrawString with "FONTIN", "FONTIN ITALIC", "FONTIN SC", and "FONTIN SC ITALIC" throughout (these are the standard PoE UI fonts on Windows). The fontMap in l_DrawString only declared FIXED, VAR, and VAR BOLD. luaL_checkoption raised 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, and DrawStringCursorIndex.

4. Hardcoded SDK path breaks builds on most machines

meson.build had -isysroot /Library/Developer/CommandLineTools/SDKs/MacOSX12.3.sdk hardcoded, failing immediately on any machine without that exact SDK installed.

Fix: remove the -isysroot flag and use the default host SDK.

Test plan

  • Build succeeds on ARM64 macOS with meson + ninja (no -pagezero_size/-image_base flags needed on ARM64)
  • App launches without crashing
  • Skill tree renders and can be navigated without crash
  • Green fullscreen button zooms/maximizes instead of crashing
  • Lua errors are caught and shown as error dialogs rather than killing the process

🤖 Generated with Claude Code

thomaslestum and others added 2 commits March 7, 2026 02:18
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>
@thomaslestum
Copy link
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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant