From 5c1dcd4f970de8e307e2bdd9f546c09fb1a38b97 Mon Sep 17 00:00:00 2001 From: onemannoplan <96282233+onemannoplan@users.noreply.github.com> Date: Thu, 8 Oct 2026 23:53:21 -0500 Subject: [PATCH] fix(macos): prevent SIGILL crash on exit by replacing viewport close with clean process exit ### Summary When selecting "Quit LightCraft" from the native macOS menu bar, the application occasionally crashes with an `EXC_BAD_INSTRUCTION` (SIGILL) error report during shutdown. ### Root Cause 1. The native menu action triggered `ctx.send_viewport_cmd(egui::ViewportCommand::Close)`. 2. Forcing an explicit viewport close via the command queue while macOS and AppKit are initiating their own termination sequence creates a race condition with `winit`. 3. This conflict during native window, view, and observer teardown leads to an illegal instruction fault. ### Solution - Replaced the manual `ViewportCommand::Close` trigger on `QUIT` with a clean `std::process::exit(0)`. - This bypasses the problematic `winit`/AppKit teardown race condition on macOS, allowing the application to shut down instantly and cleanly without generating crash reports. --- apps/lightcraft/src/native_menu.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/apps/lightcraft/src/native_menu.rs b/apps/lightcraft/src/native_menu.rs index 647f7e27..6c6d2f2b 100644 --- a/apps/lightcraft/src/native_menu.rs +++ b/apps/lightcraft/src/native_menu.rs @@ -360,8 +360,7 @@ impl NativeMenu { lightcraft_ui_egui::i18n::set_language(app.ui.language); while let Ok(key) = self.rx.try_recv() { if key == QUIT { - ctx.send_viewport_cmd(egui::ViewportCommand::Close); - continue; + std::process::exit(0); } if key == "app.about" || key == SETTINGS { let _ = app.run(&key, serde_json::json!({}));