Skip to content

Fix file dialog on modern macOS (13+)#173

Open
snegnik wants to merge 1 commit intowjakob:masterfrom
snegnik:fix/macos-file-dialog
Open

Fix file dialog on modern macOS (13+)#173
snegnik wants to merge 1 commit intowjakob:masterfrom
snegnik:fix/macos-file-dialog

Conversation

@snegnik
Copy link
Copy Markdown

@snegnik snegnik commented Mar 8, 2026

Summary

  • On modern macOS (13–15), clicking "Open mesh" does nothing — the file dialog never appears
  • Root cause: NanoGUI's file_dialog() calls NSOpenPanel.runModal which returns immediately with NSModalResponseCancel when invoked within GLFW's event loop
  • Fix: Replace with an osascript-based native file dialog that runs in a separate process, bypassing the GLFW event loop conflict
  • Guarded with #ifdef __APPLE__ — Linux and Windows builds are unaffected

Changed files

File Change
src/native_file_dialog.h New header declaring native_file_dialog()
src/native_file_dialog.cpp Implementation using osascript / AppleScript choose file
src/viewer.cpp Route all file_dialog calls through im_file_dialog macro
CMakeLists.txt Include new source file on Apple builds

Test plan

  • Build on macOS (Apple Silicon, macOS 15)
  • "Open mesh" button opens native macOS file picker
  • Selecting an OBJ/PLY file loads the mesh successfully
  • No crashes
  • Verify Linux/Windows builds are unaffected

🤖 Generated with Claude Code

On modern macOS (13+), NanoGUI's file_dialog() using NSOpenPanel/NSSavePanel
fails silently because runModal returns immediately when called within
GLFW's event loop. The file picker never appears.

Replace with an osascript-based implementation that spawns a native macOS
file dialog in a separate process, bypassing the GLFW event loop conflict.

The fix is guarded with #ifdef __APPLE__ so Linux and Windows builds
remain unchanged.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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.

2 participants