Skip to content

perf(desktop): let a minimized or hidden macOS window stop rendering - #10168

Merged
Kitenite merged 1 commit into
mainfrom
remove-occlusion-opt-out
Nov 23, 2026
Merged

Kitenite merged 1 commit into
mainfrom
remove-occlusion-opt-out

Conversation

@Kitenite

@Kitenite Kitenite commented Nov 22, 2026 •

Copy link
Copy Markdown
Member

Summary

  • Removes two macOS-only overrides from fix(desktop): harden renderer boot to avoid white screens #1190: webContents.setBackgroundThrottling(false) on the main window and the disable-backgrounding-occluded-windows switch.
  • A minimized or hidden macOS window now reports hidden to the page and stops drawing frames, as it already does on Windows and Linux.
  • The repaint on restore and show stays.

Why / Context

With background throttling off, a minimized window still reported visible and kept rendering at 120 Hz, spinners included. #1190 added both overrides as a guard against GPU layer corruption on macOS Sequoia; its description says testing was not run, and no issue is linked. Electron has gone from 39 to 44 since.

setBackgroundThrottling(false) is the override that matters. Removing only the switch changed nothing in my test.

Manual QA

Dev app from this branch on macOS (M5 Max, 120 Hz), driven over CDP.

Window state Page reports Frames in 2 s 100 ms timer ticks in 2 s
Visible, unfocused visible 241 20
Minimized hidden 0 3
Restored visible 242 20
App hidden (Cmd+H) hidden 0 3
Unhidden visible 240 20
Covered by another window visible 241 20

Background work while minimized:

  • Agent events: Start and Stop hooks reached the renderer's event bus with the same delay as when visible.
  • Main-process calls: IPC queries and the notifications.showNative mutation returned in 1 ms from the hidden renderer.
  • Terminal output, 12 MB burst: every byte reached the terminal (12,389,776 bytes hidden against 12,389,717 visible), no dropped-output notice, socket stayed open.
  • Restore: the page came back visible with content rendered, and no GPU or renderer crash in the log.

CPU for the whole app while minimized with spinners running was 3.5% of one core in one 15 s sample, against 5.1% on main.

Behavior change to know about

Terminal output is written once per animation frame. A hidden window draws no frames, so output waits until 1 MB has built up or the window is shown again. In the burst test the last 0.8 MB arrived on restore; a small command's output did not reach the terminal buffer at all until restore. Nothing was lost in either case. Windows and Linux already work this way; this is new only for macOS.

Testing

  • bun run typecheck in apps/desktop
  • biome check on the changed files

Known Limitations

  • macOS did not record a notification for this dev build, so the banner itself was not confirmed; the test stops at the main process accepting the call.
  • The original GPU corruption has no repro, so a clean restore here does not prove it cannot return.
  • A window covered by another window still renders. I am not certain my covering window fully hid the app.
  • Restore was checked through CDP, not by eye.

Rollback

Revert this PR; both overrides are self-contained.


Summary by cubic

Lets a minimized or hidden macOS window stop rendering by removing the background-throttling overrides added in #1190. A minimized or hidden macOS window now reports hidden to the page and draws no frames, matching Windows and Linux behavior, while the repaint on restore and show is preserved.

  • Removes setBackgroundThrottling(false) from the main window and the disable-backgrounding-occluded-windows switch.
  • CPU while minimized with spinners running dropped from 5.1% to 3.5% of one core in testing.

Behavior change to know about

  • Terminal output is written once per animation frame, so with a hidden window it buffers until 1 MB accumulates or the window is shown again; nothing is lost.

Written for commit 1053486. Summary will update on new commits.

View guided diff Turn on auto-fix

Summary by CodeRabbit

  • Behavior Changes
    • On macOS, windows now follow the platform’s standard background throttling behavior when occluded or inactive. The app no longer prevents backgrounding or disables throttling for individual windows. As a result, background activity may be throttled, which can reduce resource use while a window is obscured. Other desktop platforms’ window identification behavior is unchanged.

#1190 turned background throttling off for the macOS window and added
the disable-backgrounding-occluded-windows switch as an untested guard
against GPU layer corruption. With throttling off, a minimized or hidden
window still reported visible to the page and kept rendering at the
display rate.

Both overrides are removed, so macOS now behaves like Windows and Linux:
a minimized or hidden window reports hidden, draws no frames, and has
its timers throttled. The repaint on restore and show stays.
@github-actions

github-actions Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ✅ Neon database branch

Thank you for your contribution! 🎉

@coderabbitai

coderabbitai Bot commented Nov 22, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The macOS-specific app setup no longer adds the disable-backgrounding-occluded-windows switch. Window setup no longer calls setBackgroundThrottling(false).

Changes: macOS Background Throttling

Layer / File(s) Summary
Remove macOS throttling overrides
apps/desktop/src/lib/electron-app/factories/app/setup.ts, apps/desktop/src/main/windows/main.ts
App setup no longer adds the backgrounding command-line switch. Window setup no longer disables background throttling.

Estimated code review effort: 1 (Trivial) | ~3 minutes

Change: Bug fix

Merge Risk: Minimal · up to 10534

On macOS, a minimized or hidden window will now stop rendering and report itself hidden, which reduces idle CPU and GPU use. Terminal output may be deferred while the window is hidden and appears when it is restored, as the author noted. No concrete merge-blocking defect was identified, and the change is easy to revert if the earlier GPU-corruption problem reappears.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: it removes the macOS-only overrides (background throttling disabled on the main window and the disable-backgrounding-occluded-windows switch), so a minimized or hidden…
Description check Passed The description covers the required template sections. 'What & why' explains the change, the problem, and the origin in #1190, though it does not link an issue (the template allows this). 'How I teste…
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

The title names the main change: it removes the macOS-only overrides (background throttling disabled on the main window and the disable-backgrounding-occluded-windows switch), so a minimized or hidden macOS window stops rendering. It follows conventional commit format with the desktop scope and the perf type, and the 68-character length is within normal limits.

Full details: Description check

Explanation

The description covers the required template sections. 'What & why' explains the change, the problem, and the origin in #1190, though it does not link an issue (the template allows this). 'How I tested it' gives detailed manual QA with a results table, background-work checks, and a behavior-change note. The checklist items are not ticked, and the description does not state that the conventional commit title or lint check was verified. The author did list typecheck and biome checks, but the template asks for 'bun run lint' and 'bun run typecheck', so lint was not clearly run. Screenshots were not included, though the template prefers them for user-visible changes; this change is user-visible (rendering and throttling), so the author should add before/after screenshots or state why they were not captured.

Resolution

Optional improvements: tick the checklist items after confirming them, state that 'bun run lint' passed (the author only listed typecheck and biome check), and add before/after screenshots or a short note on why they were not captured. Also link the related issue if one exists.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

Recent review info

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8390aa5d-8be7-4d1f-831d-aa2d2871554e
Commits

Reviewing files that changed from the base of the PR and between 889716d and 1053486.

Files selected for processing: 2

  • apps/desktop/src/lib/electron-app/factories/app/setup.ts
  • apps/desktop/src/main/windows/main.ts
Files with no reviewable changes: 2

  • apps/desktop/src/lib/electron-app/factories/app/setup.ts
  • apps/desktop/src/main/windows/main.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 6 remain after this review.

@Kitenite
Kitenite merged commit 12d8282 into main Nov 23, 2026
20 checks passed

This branch was previously deployed

1 inactive deployment
preview — 1053486f Deployed Nov 23, 2026 by Kitenite via Cleanup Preview Resources #5987
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