From e662b9bb2fd4c550c765827dffc0ac09ba9c4c9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gruber=20Kristo=CC=81f?= Date: Sat, 30 May 2026 22:56:28 +0200 Subject: [PATCH 1/2] Fix crash on macOS 26 when closing the splash window The splash window's NIB never set "release when closed" to NO (unlike the main window), so the window defaulted to releasing itself on close. On modern macOS this is fatal: the splash is made key at launch, and when it is closed the NSWindow is deallocated while SplashWindowController (retained for the app's lifetime by the app delegate) still references it. When first-responder status returns to the main window, AppKit's automatic focus ring messages the freed window: +[_NSAutomaticFocusRing _clearOldFocusRing] -> -[NSWindow _setNeedsDisplayInRegion:] producing an EXC_BAD_ACCESS use-after-free (observed in v3.1.1 crash logs on macOS 26.5). Keep the splash window alive on close by setting releasedWhenClosed to NO, mirroring the main window, and resign first responder before closing so the focus ring is torn down while the window is still a valid object. Co-Authored-By: Claude Opus 4.8 (1M context) --- SplashWindowController.m | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/SplashWindowController.m b/SplashWindowController.m index 61684c7..7e260d4 100644 --- a/SplashWindowController.m +++ b/SplashWindowController.m @@ -49,6 +49,20 @@ - ( void ) windowDidLoad { [ super windowDidLoad ]; + /* The main window's NIB sets "released when closed" to NO, but the splash + * window's NIB does not, so the splash window defaults to releasing itself + * on close. On modern macOS that is fatal: when the splash window is the + * key window and is closed, it is deallocated, yet AppKit's automatic + * focus-ring machinery still references it when first-responder status + * moves back to the main window. The result is a use-after-free crash in + * +[_NSAutomaticFocusRing _clearOldFocusRing] -> -[NSWindow + * _setNeedsDisplayInRegion:]. This controller owns the window for the + * lifetime of the application, so keep it alive on close, matching the + * behaviour already configured for the main window. + */ + + [ [ self window ] setReleasedWhenClosed: NO ]; + [ [ self window ] center ]; [ [ self window ] makeKeyAndOrderFront: nil ]; } @@ -65,7 +79,13 @@ - ( void ) windowDidLoad - ( IBAction ) closeWindow: ( NSButton * ) sender { ( void ) sender; - [ self close ]; + + /* Resign first responder before the window goes away so that AppKit tears + * down any focus ring while the window is still a valid object. + */ + + [ [ self window ] makeFirstResponder: nil ]; + [ self close ]; } @end From 3baa743ac8cce41daedada394d627f99e3ff225b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gruber=20Kristo=CC=81f?= Date: Sat, 30 May 2026 23:02:23 +0200 Subject: [PATCH 2/2] Also set releasedWhenClosed=NO on the splash window in its NIB Belt-and-braces, nib-level counterpart to the SplashWindowController code fix: mirror MainWindow.xib so the splash window is not released on close even independently of -windowDidLoad. Prevents the use-after-free crash in AppKit's automatic focus ring on macOS 26 when the splash window is closed. Co-Authored-By: Claude Opus 4.8 (1M context) --- Base.lproj/SplashWindow.xib | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Base.lproj/SplashWindow.xib b/Base.lproj/SplashWindow.xib index dc2a318..39a70a6 100644 --- a/Base.lproj/SplashWindow.xib +++ b/Base.lproj/SplashWindow.xib @@ -14,7 +14,7 @@ - +