Repository navigation
fix: keep notification clearance from freezing the bar - #129
Merged
Seb-GRAF merged 1 commit intoOct 21, 2026
Merged
Conversation
banner(in:) walked Notification Center's Accessibility tree breadth-first without remembering visited elements or bounding the walk. On macOS 26 the walk never finished: the main thread stayed in moveBanners(), most of it shifting the queue in removeFirst(), and memory grew until the bar was force-quit. The walk now looks at each element once, stops after 200 elements and reads its queue by index.
|
🎉 This PR is included in version 0.5.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This was referenced Oct 22, 2026
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
With
bar.keepNotificationsClearon, StableBar stops responding after a while and has to be force-quit. Its main thread never leavesWindowClearance.moveBanners(), CPU stays between 50% and 75%, and memory keeps growing.On 0.5.0-beta.123 and 0.5.0-beta.20261020113356.133 (macOS 26.6.2, M4 Pro,
keepWindowsClearandkeepNotificationsClearon), macOS wrote fourcpu_resourcereports in one day, for four separate processes. Each was force-quit, and each report has the same heaviest stack:A 3-second
sampleof a frozen bar put all 2255 main-thread samples inmoveBanners(): 1586 in_platform_memmove, the rest inAXUIElementCopyAttributeValuecalls to Notification Center. Its physical footprint was 825 MB. In the release binary,banner(in:) + 444callsreplaceSubrange(0..<1, with: EmptyCollection), so the memmove iselements.removeFirst().banner(in:)walks Notification Center's Accessibility tree breadth-first, with no record of visited elements and no bound. Shifting the queue only outweighs the three Accessibility round trips made for each element when the queue holds hundreds of thousands of elements. That is far more than Notification Center shows, so the children it reads either lead back to elements already queued or keep producing new ones, and the walk never finishes. Memory grows with the queue.Changes
firstBanner(in:limit:kind:children:). It looks at each element once, stops after 200 elements, and reads its queue by index instead ofremoveFirst().banner(in:)keeps its checks: the notification list ends the search, and the firstAXNotificationCenter*subrole is the banner.Testing
swift test(Xcode 26.1.1, Swift 6.2.1): 245 XCTest tests and 355 Swift Testing tests passed.Merging
Rebase or squash merge; this is one Conventional Commit.
Claude Opus 5.5 via Claude Code