Menu bar: poll stats continuously from launch (real fix for stuck spinner)#84
Open
iliyami wants to merge 1 commit into
Open
Menu bar: poll stats continuously from launch (real fix for stuck spinner)#84iliyami wants to merge 1 commit into
iliyami wants to merge 1 commit into
Conversation
The live-stats popover stayed stuck on its loading spinner for a reporter even on the 1.11.5 beta (which already had the statfs/timeout fix). The cause was not the disk read: polling was started ONLY from the MenuBarExtra(.window) popover content's .onAppear and torn down on .onDisappear. That hook only fires when the popover opens and is unreliable across macOS versions, so collection often never ran and stats stayed nil. Move polling into a @mainactor @observable MenuStatsModel started at launch from the app delegate (applicationDidFinishLaunching), decoupled from the popover: - Stats are gathered from launch, so the popover shows data instantly and the menu-bar label is populated immediately (previously blank until first open). - @mainactor model means UI updates happen on the main actor. - Per-metric withTimeout retained so one slow syscall degrades to last-known instead of blanking the panel; timeouts log at .error for field diagnosis. Verified locally: launching the bundled helper runs collection and populates stats within ~2s without ever opening the popover. Bump version to 1.11.6.
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.
Follow-up to #78/#79. A reporter confirmed the menu-bar "Live system stats" popover still stuck on its loading spinner on the 1.11.5 beta, which already had the statfs + timeout fix. So that fix targeted the wrong layer.
Real root cause
Polling was started only from the
MenuBarExtra(.window)popover content's.onAppearand stopped on.onDisappear. That hook only fires when the popover opens, and is unreliable across macOS versions, so on the reporter's Mac collection never ran andstatsstayed nil → permanent spinner. Changing whatcollect()does internally (the 1.11.5 fix) couldn't help if polling never starts.Evidence: a
sampleof his helper showed it alive but completely idle (no collection threads); locally, wrapping the helper in a.appand launching it produced no stats activity until the popover was opened.Fix
Move polling into a
@MainActor @Observable MenuStatsModelstarted at launch fromMenuAppDelegate.applicationDidFinishLaunching(@NSApplicationDelegateAdaptor), decoupled from the popover lifecycle:@MainActormodel → UI updates on the main actor.withTimeoutretained; timeouts log at.errorso a remaining slow syscall (if any) is pinpointable from Console.Verified locally: launching the bundled helper runs collection and sets stats within ~2s without opening the popover (confirmed via a file-write probe; note
os_log.infois not retrievable vialog show, so don't rely on it).Notes
@preconcurrency NSApplicationDelegateconformance to keep CI's older SDK building.v1.11.6-beta.1for the reporter to confirm; if it still spins, the.error"exceeded its budget" log will identify a per-syscall stall.