Skip to content

Fix app freeze caused by nested CFRunLoopRun() on main thread#120

Open
cmeinerd wants to merge 1 commit intomilgra:masterfrom
cmeinerd:fix/cfrunloop-main-thread-freeze
Open

Fix app freeze caused by nested CFRunLoopRun() on main thread#120
cmeinerd wants to merge 1 commit intomilgra:masterfrom
cmeinerd:fix/cfrunloop-main-thread-freeze

Conversation

@cmeinerd
Copy link
Copy Markdown

Summary

  • Removes CFRunLoopRun() from startEventSession and CFRunLoopStop() from stopEventSession — the nested run loop blocked the main thread, causing the app to become unresponsive ("Not Responding") after a few seconds
  • Adds disableAutomaticTermination / disableSuddenTermination to prevent macOS from killing this windowless menu bar app

Fixes #119

Explanation

In a Cocoa app, the main run loop is already running via [NSApp run]. Calling CFRunLoopRun() inside applicationDidFinishLaunching: creates a nested run loop that blocks NSApplication from processing UI events. The fix is to only add/remove the event tap source — the existing main run loop picks it up automatically.

🤖 Generated with Claude Code

The app became unresponsive ("Not Responding") because startEventSession
called CFRunLoopRun() which blocked the main thread in a nested run loop,
preventing NSApplication from processing UI events. In a Cocoa app the
main run loop is already running via [NSApp run], so only adding/removing
the event tap source is needed.

Also adds disableAutomaticTermination/disableSuddenTermination to prevent
macOS from killing this windowless menu bar app.

Co-Authored-By: Claude Opus 4.6 <[email protected]>
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.

macOS Tahoe support

1 participant