Skip to content

fix(app): stop drawing windows that are closed or hidden - #102

Merged
yogeshprasad098 merged 1 commit into
mainfrom
perf/stop-hidden-drawing
Nov 26, 2026
Merged

yogeshprasad098 merged 1 commit into
mainfrom
perf/stop-hidden-drawing

Conversation

@yogeshprasad098

@yogeshprasad098 yogeshprasad098 commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

A closed dashboard kept its views alive, and their looping animations and rolling numbers went on drawing it off screen. The installed 0.3.0 sat at 45–55% CPU with no window open, and the same work on the main thread made scrolling lag. This drops a closed window's contents, pauses the looping animations while a window is hidden, covered or behind another app, stops the menu bar item redrawing every second, and keeps the cards' pointer light from redrawing their contents.

Review focus

WindowContent decides when a window counts as open: willClose drops the contents, and an occlusion change on a visible window brings them back. The menu bar panel keeps its contents (it sizes itself to them) and only gets isOnScreen. The power lines' glow is now a soft static line under the dashes instead of a shadow that was blurred again every frame.

Testing

Tested: ./scripts/check.sh passes except lint, which is off. I measured debug builds started with --demo using top, before and after, sampling for 8 s after letting each state settle:

Dashboard Before After
In front 21% 3%
Behind another app 21% 4.5%
Closed 22% 0–2%

Memory with the window closed went from 87 MB to 61 MB. I closed and reopened the dashboard and it came back with its contents. Design renders of Overview in light and dark look the same apart from the wire glow.
Not tested: the release build with live readings. Demo mode has no once-a-second updates, so the real app's numbers need checking after an update. I didn't measure scrolling frame times; Instruments isn't scriptable here.

  • CHANGELOG.md has an entry under Unreleased, or nothing user-visible changed.
  • Docs are updated, or the change needs none.
  • A breaking change has ! in the title and the migration above.
Notes

sample on the installed app showed the main thread about 80% busy in CA::Transaction::flush: an interpolated (animating) display list drawn in software through CGDrawingLayer, plus NSHostingView.layout every frame. OverviewPage.body and ChargerStrip.body were in the stacks with no window on screen.

A closed dashboard kept its views alive, and their looping animations
(pulsing dots, moving power lines) and rolling numbers went on drawing
it off screen. The app sat at around half a CPU core with no window
open, and the same work on the main thread made scrolling lag.

Closing the dashboard or the setup window now drops its contents. The
looping animations run from a 30 fps clock that pauses while the window
is hidden, covered or behind another app, and numbers roll only while
the window is on screen. The menu bar item reads a small value that
changes only when its ring or percentage does, instead of redrawing
every second, and pointing at a card redraws only its light.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@github-actions github-actions Bot added area: dashboard The Chargectl window and the setup window area: menu bar The menu bar icon and its panel area: ci CI, the check scripts and the build setup labels Nov 26, 2026
@yogeshprasad098
yogeshprasad098 merged commit b1b087a into main Nov 26, 2026
9 checks passed
@yogeshprasad098
yogeshprasad098 deleted the perf/stop-hidden-drawing branch November 26, 2026 02:28
@yogeshprasad098 yogeshprasad098 mentioned this pull request Nov 26, 2026
3 tasks done
yogeshprasad098 added a commit that referenced this pull request Nov 27, 2026
A closed dashboard kept its views alive, and their looping animations
(pulsing dots, moving power lines) and rolling numbers went on drawing
it off screen. The app sat at around half a CPU core with no window
open, and the same work on the main thread made scrolling lag.

Closing the dashboard or the setup window now drops its contents. The
looping animations run from a 30 fps clock that pauses while the window
is hidden, covered or behind another app, and numbers roll only while
the window is on screen. The menu bar item reads a small value that
changes only when its ring or percentage does, instead of redrawing
every second, and pointing at a card redraws only its light.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: ci CI, the check scripts and the build setup area: dashboard The Chargectl window and the setup window area: menu bar The menu bar icon and its panel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant