Skip to content

Fix/macos idle high gpu usage - #1752

Closed
xianwait wants to merge 3 commits into
vastsa:mainfrom
xianwait:fix/macos-idle-high-gpu-usage
Closed

xianwait wants to merge 3 commits into
vastsa:mainfrom
xianwait:fix/macos-idle-high-gpu-usage

Conversation

@xianwait

Copy link
Copy Markdown

No description provided.

wqx added 3 commits October 19, 2026 10:41
The macOS main window stacked the native `sidebar` vibrancy material behind a
transparent Electron surface. WindowServer recomposites that material on every
frame the window stays dirty, so an idle focused window held GPU near 40% on
Apple Silicon while a minimized one returned to the desktop baseline
(issue #1064). Bounding idle indicator animations reduced the load but could not
remove it, because the material itself kept the window in the compositor's
per-frame path regardless of what the renderer painted.

macOS now paints the same opaque native background the other platforms already
use. The frameless `hiddenInset` titlebar, the inset traffic-light position, and
the renderer's sidebar tint and sheen are unchanged, so the surface still reads
as glass over the host palette. `applyNativeThemeSource` no longer re-applies a
material, and the `window.setBackgroundColor` IPC no longer returns early on
darwin, which means a granted `windowAppearance.backgroundColor` plugin theme is
applied on macOS like everywhere else (ADR 0248).

ADR 0330 records the decision and the measurement; the specs that described the
vibrancy plate are updated in the same change.
Capping the reveal rate alone barely moved GPU usage, which located the cost:
the expense was each render, not how often it ran. Every reveal commit
re-rendered whatever sat in the streaming bubble, so a growing reply re-parsed
its tree and repainted its syntax-colored spans dozens of times a second, and
the work grew with the reply. A 32 KB tail limit was the only guard against it
and no real reply reaches that size.

A reply now shows its raw text while it arrives and swaps in the rendered form
once it settles. The reveal commits half as often as before, and the minimap's
O(markers) remeasure is capped instead of running on every frame the transcript
grows.

The streaming text keeps the Markdown source's newlines, and the cursor still
lands on it because it stays the last child inside `.prose-chat`.
The A/B figures were presented as the baseline, which they were not: they were
taken on a build that already carried the #1064 bounded-animation work. State
the original report — an M5 idling at ~89% with the window focused — alongside
the later measurement, and label each for what it shows.

vastsa commented Oct 19, 2026

Copy link
Copy Markdown
Owner

This PR changes conversation/minimap rendering, text animation, and prose styling, so it has visible UI changes and is outside this pass's no-UI-change merge condition. I’m not merging it in this batch.

The PR description is also empty, so the reported idle-GPU problem and the validation basis are not documented yet. Please add a concise reproduction/environment and evidence for the idle workload when you continue this PR. Thanks for investigating the macOS issue.

@xianwait

Copy link
Copy Markdown
Author

Sustained GPU usage while idle (the root cause)

Original report: ~89% GPU on an M5 Mac with the window focused and idle,
dropping to nothing once the window was minimized.

The macOS main window stacked the native sidebar vibrancy material behind a
transparent Electron surface, so WindowServer recomposited the whole window
whenever it stayed dirty.

A controlled A/B later confirmed it (powermetrics --samplers gpu_power; the
vibrancy path was still in place, and the build already carried the bounded
animation work from #1064):

Scenario GPU
Desktop idle baseline avg 3.6% / max 9.3%
PI-Desktop focused, idle avg 40.9% / max 55.6%
PI-Desktop minimized avg 3.2% / max 6.1%

What matters is that usage tracks whether the window is visible, not what it
is displaying
— that points at window composition rather than rendered content.
While idle, the app's own GPU process used no measurable CPU time and the
renderer submitted no frames of its own.

Note on the numbers: 40.9% is not the original baseline, because it was measured
on a build that already had #1064's animation capping. The 89% figure is the
original report. Both point the same way, and ADR 0332 labels each accordingly.

Fix: macOS paints the same opaque native background the other platforms
already use, keeping the hiddenInset titlebar, the inset traffic-light
position, and the renderer's sidebar tint and sheen — the surface still reads as
glass, but there is no longer a live blur behind it.

This also fixes a latent defect: the window.setBackgroundColor IPC returned
early on darwin (vibrancy used to provide the color), so with an opaque window a
theme change never repainted the native background.

GPU usage while scrolling and while a reply streams

Capping the reveal rate barely helped, and that result located the cost: the
expense is each render, not how often renders run. Every reveal commit repainted
whatever sat in the streaming bubble, so a growing reply re-parsed its tree and
repainted its syntax-colored spans dozens of times a second, with the cost
growing alongside the reply. The only guard was a 32 KB tail threshold, which no
real reply reaches.

Fix: a reply shows its raw text while it arrives and swaps in the rendered
form once it settles.

Supporting changes (helpful, but not sufficient on their own):

  • Reveal commits are capped at 30 Hz instead of following a high-refresh panel
  • The transcript minimap's O(markers) remeasure is throttled instead of running
    on every frame the content grows

Basis

ADR 0332, D665; the specs describing the vibrancy plate were updated in the same
change: ADR 0248 / ADR 0260, 08-component-spec, 07-ui-design-system,
13-plugin-permissions-matrix.

Verification

  • Targeted tests 43/43, including new regression contracts for both fixes
  • Compared against current main entry by entry: the failure set is identical,
    no new failures
  • typecheck / style tokens / agent policy / docs (580 pages) / check:pr-base
    all pass
  • Verified on an arm64 DMG

Impact

  • The macOS sidebar loses the live blur of desktop content (it keeps the tint and
    sheen, so it still reads as glass)
  • A plugin's windowAppearance.backgroundColor now takes effect on macOS
  • A streaming reply renders as plain text and becomes fully formatted when it
    settles

@xianwait

Copy link
Copy Markdown
Author

Hello, the main issue I'm seeing is that on my MacBook Air (M5 10+8), PI-Desktop sits at around 89%GPU usage whenever its window is in the foreground — even when I'm not doing anything in it. I hope this can be fixed in a future release. Thank you.

vastsa commented Oct 19, 2026 •

Copy link
Copy Markdown
Owner

Thanks for adding the controlled A/B measurements; they support the reported visible-window composition issue.

This PR changes the macOS native surface/vibrancy and renderer text/scroll presentation, so it remains outside this batch's no-visible-UI/window-behavior scope. This is a scope deferral, not a finding that the report is false or that the direction is wrong. Please keep the reproduction, environment, and before/after measurements in the PR description, then refresh the branch against current main when this scope is reviewed. Thanks for the investigation.

@vastsa vastsa left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the controlled A/B measurements; they confirm the focused-idle GPU problem is real and points to the native vibrancy surface. My earlier note treated visible UI/window changes as out of scope; that constraint no longer applies, so this review is based on the code and root-cause fit.

The opaque-surface fix is already represented on current main by macosWindowSurfaceOptions and the macosWindowTranslucency setting. The current product default is deliberately translucent when the preference is absent; setting it to false selects the opaque surface on the next launch. The PR's first commit hard-codes opaque as the default, which changes that established default and duplicates the existing opt-out path. Please rebase and narrow this PR to a change that fits the current setting contract, or document a deliberate product decision to change the default before proposing that behavior.

The streaming plain-text/minimap changes in c501f2e02 address a separate active-generation rendering cost and change how replies render while streaming. They are not needed to fix the reported idle composition path; please split them into a separately scoped PR with its own problem statement and evidence. I’m not merging this combined diff as the idle-GPU fix. Thanks for the investigation and measurements.

vastsa commented Oct 28, 2026

Copy link
Copy Markdown
Owner

The focused-idle GPU report and controlled measurements are credible. The current main already exposes macosWindowTranslucency as an opt-out, while this PR changes the established default and also bundles separate streaming-render/minimap behavior. The request to narrow the change or document an intentional default change has had no response since October 22, so I’m closing this stale combined PR. Please reopen a focused change that fits the setting contract, or include the product decision for changing the default. Thanks for the measurements and investigation.

@vastsa vastsa closed this Oct 28, 2026
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.

2 participants