Fix crash on macOS 26 when closing the splash window - #13
Open
gklka wants to merge 2 commits into
Open
Conversation
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) <noreply@anthropic.com>
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) <noreply@anthropic.com>
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.
Problem
On macOS 26, Add Folder Icons (v3.1.1) crashes a few seconds after launch with
EXC_BAD_ACCESSon the main thread. The faulting stack is:Cause
SplashWindow.xibnever set the window's Release When Closed flag toNO(unlikeMainWindow.xib, which does), so the splash window defaulted to releasing itself on close.The splash window is made key at launch. When it is closed, the
NSWindowis deallocated — butSplashWindowController(retained for the lifetime of the app by the app delegate) still references it. When first-responder status returns to the main window, AppKit's automatic focus-ring teardown messages the now-freed window, which is a use-after-free. Older macOS releases did not touch the just-closed window during that teardown, which is why this only started crashing on recent macOS.Fix
SplashWindowController.m— setreleasedWhenClosed = NOin-windowDidLoad, and resign first responder before-closeso the focus ring is torn down while the window is still a valid object.SplashWindow.xib— setreleasedWhenClosed="NO"on the window to matchMainWindow.xib(belt-and-braces, nib level).Testing
Builds cleanly against the macOS 26.5 SDK (Xcode 26.5) with no errors, and the rebuilt app launches and runs without the crash.
🤖 Generated with Claude Code