Reduce CPU use and main-thread IPCs in bar updates, app switching and polling
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 15/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Stale
- Tech stack
- macos, swift
- Domain
- desktop, performance
Research direction
Start by reviewing the linked pull request #996 and the issue’s proposed hot-path changes. The work spans many components, including BarPresentation, WindowClearance, MenuBarItemMirror, Spaces, QuickToggles, and AudioMonitor; follow the relevant paths and tests from there. Done means reducing the listed redundant work and IPCs without changing user-facing behavior or configuration format.
Written by the indexing model from the issue text.
Description
Problem
Several hot paths in StableBar do redundant work or synchronous IPCs on @MainActor:
BarPresentation.updatePresentations()re-walksconfiguration.needsModeConnection, rebuilds per-screen widget lookups and re-resolves every widget's style across every screen whenever any single script or provider updates.WidgetConfiguration.label(output:activeApp:date:)allocates a newDateFormatterand recompiles three ICU patterns on every clock render.HexColor.colorallocates a fresh dynamicNSColorclosure on every SwiftUIbodypass, defeatingColor == Colordiffing, andStyledShadowruns a shadow pass even when no shadow color is set.WindowClearancere-registersAXObserverAddNotificationand schedules all running apps on every activation/unhide, making 5 sequential AX IPCs per window on@MainActor.MenuBarItemMirrorruns cropping and per-pixel array-allocating image processing on@MainActorevery 2 seconds.Spaces.currentSpaces()queriesSLSCopySpacesForWindowsfor all windows before filtering to layer-0 regular apps and round-trips through binary plist serialization.QuickTogglesreads fullAudioMonitor(input: true).read()(~30+ CoreAudio IPCs) every second while open just for mic mute, duplicatesSCDynamicStoreIPv4 and Finder preference syncs, and writesbluetoothAccessunconditionally.MenuBarStrip,BarView,MenuBarAppearance,WorkspaceStore,DockBadges,NativeMetrics,AppMenuandConfigurationLoaderperform avoidable main-thread work or unconditional@Observablewrites.
Proposal
Optimize these hot paths without changing any user-facing behavior or configuration format:
- Precompute static
BarPresentationmetadata and run incremental per-script updates (falling back to a full pass when cross-widgetwidgetStyles,barStyleor mode-state demand changes). - Cache clock
DateFormatters (invalidated on locale/timezone changes) and adaptiveHexColorNSColorinstances; skip uncolored shadow passes while keeping zero-radius hard shadows. - Batch
WindowClearancewindow attributes into oneAXUIElementCopyMultipleAttributeValuesIPC, scope activation/unhide to the activated app, and retry notification registration only until it succeeds. - Move
MenuBarItemMirrorcropping/pixel work off@MainActorwith zero-allocation pixel loops, filterSpaceswindows before SkyLight IPCs, addAudioMonitor.isMuted(input:), and guard no-op@Observable/@Statewrites.
Possible today
None of these are configurable; they happen automatically in normal use.
Related
Continues earlier performance work in #161, #174, #246, #353 and #377.
Triaged by Antigravity (Gemini 4 Neon).
- Dominant language
- Swift
- Stars
- 184
- Forks
- 12
- PR merge metrics
- No merged PRs in 30d
Getting set up
- No Dockerfile or Docker Compose file
- Has a pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Seb-GRAF/StableBar
-
A second click on the Control Center widget doesn't close Control CenterPossibly taken @MaHofseth claimed this today. Openneeds-triage
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement P3
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement P3
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
enhancement P3
Difficulty 5/5 Over a week Newbie friendliness 42/100
-
enhancement P3
Difficulty 4/5 3-5 days Newbie friendliness 53/100
All issues in Seb-GRAF/StableBar
Similar issues
-
area: models enhancement needs-triage
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
rexmhall09/TUFF#69 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
nikitabobko/AeroSpace#2427 · 1 comment ·
Maintainers usually reply within 8 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 63/100
Maintainers usually reply within 1 day
-
documentation good first issue
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
android bug
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
Maintainers usually reply within 1 day