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

Merged
KI
8h ago
+0-10

Summary

  • Removes two macOS-only overrides from #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 statePage reportsFrames in 2 s100 ms timer ticks in 2 s
Visible, unfocusedvisible24120
Minimizedhidden03
Restoredvisible24220
App hidden (Cmd+H)hidden03
Unhiddenvisible24020
Covered by another windowvisible24120

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.

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.