Skip to content

Stop rendering hidden windows; log Docker outages once - #5

Merged
MarkRWatts merged 2 commits into
mainfrom
fix/hidden-window-cpu
Sep 27, 2026
Merged

MarkRWatts merged 2 commits into
mainfrom
fix/hidden-window-cpu

Conversation

@MarkRWatts

Copy link
Copy Markdown
Owner

Problem

Argus climbed from ~2–3% CPU at launch to 44–50%. Profiling showed the per-poll detection cost was flat (confirmed across week-long runs in the heartbeat log); the time was all main-thread SwiftUI/Core Animation rendering of windows that weren't on screen:

  • Closing the dashboard only hides it, and the menu-bar flyout is dismissed with orderOut, so both kept re-evaluating, animating, and committing frames on every poll — the gauge's shadowed conic gradient was the largest single cost.
  • riskScore decays exponentially and never reached exactly 0, so the gauge's score-keyed animation re-ran every tick indefinitely.

Changes

  • WindowVisibility.swift (new): WindowVisibilityReader tracks the hosting window's occlusionState; renderedOnlyWhenVisible swaps in a placeholder while hidden. Applied to the dashboard body and the flyout's gauge.
  • ProcessMonitor: riskScore snaps to 0 once below 0.5 (where the gauge already displays 0), and is only reassigned when it changes.
  • DockerWatcher: hasLoggedExit was reset on every successful spawn of docker events, but the CLI spawns fine with no daemon and exits immediately — so "docker events exited" was logged every 60s while Docker was down (~12.6k lines). It now resets only once the daemon actually produces output.

Verification

  • Before: 21–28% CPU with dashboard and flyout both hidden, ~5 min after launch.
  • After (same state, patched build): steady ~1% over 3 minutes.
  • swift test: 213 tests, 0 failures.
  • Not yet verified: multi-day CPU trend; Docker change not exercised against a live daemon.

🤖 Generated with Claude Code

MarkRWatts and others added 2 commits September 27, 2026 19:19
Closing the dashboard only hides it, and the menu-bar flyout is dismissed
with orderOut, so SwiftUI kept re-evaluating, animating, and committing
frames for both off-screen on every poll — measured at 21-28% CPU with
neither window visible, dominated by the gauge's shadowed conic gradient.

WindowVisibilityReader tracks the hosting window's occlusion state; the
dashboard and the flyout's gauge render a placeholder while hidden.
riskScore now snaps to 0 below 0.5 (where the gauge already shows 0):
pure exponential decay never reached 0, so the gauge re-animated every
tick indefinitely. Hidden-window CPU drops to ~1%.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
hasLoggedExit was reset on every successful spawn of `docker events`, but
the CLI spawns fine with no daemon and exits immediately, so the "exited"
line was written every 60s for as long as Docker was down (~12.6k lines).
Reset it only once the daemon actually produces output.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@MarkRWatts
MarkRWatts merged commit 5a5c15e into main Sep 27, 2026
2 checks passed
@MarkRWatts
MarkRWatts deleted the fix/hidden-window-cpu branch September 27, 2026 18:47
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