Skip to content

Fix crash on macOS 26 when closing the splash window - #13

Open
gklka wants to merge 2 commits into
pond:masterfrom
gklka:fix/splash-window-crash
Open

Fix crash on macOS 26 when closing the splash window#13
gklka wants to merge 2 commits into
pond:masterfrom
gklka:fix/splash-window-crash

Conversation

@gklka

@gklka gklka commented May 30, 2026

Copy link
Copy Markdown

Problem

On macOS 26, Add Folder Icons (v3.1.1) crashes a few seconds after launch with EXC_BAD_ACCESS on the main thread. The faulting stack is:

+[_NSAutomaticFocusRing setActiveFirstResponderChanged]
  -> +[_NSAutomaticFocusRing _clearOldFocusRing]
  -> -[NSWindow _setNeedsDisplayInRegion:]   // on a freed NSWindow

Cause

SplashWindow.xib never set the window's Release When Closed flag to NO (unlike MainWindow.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 NSWindow is deallocated — but SplashWindowController (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 — set releasedWhenClosed = NO in -windowDidLoad, and resign first responder before -close so the focus ring is torn down while the window is still a valid object.
  • SplashWindow.xib — set releasedWhenClosed="NO" on the window to match MainWindow.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

gklka and others added 2 commits May 30, 2026 22:56
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>
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