MarshallOfSound

#54311: fix: stop a hidden page rendering after setBackgroundThrottling is re-enabled

Merged
Created: Sep 24, 2026, 1:55:20 PM
Merged: Sep 24, 2026, 8:58:49 PM
5 comments
Target: main

Description of Change

Before: calling webContents.setBackgroundThrottling(false) and then setBackgroundThrottling(true) on a page nobody can see (window hidden, minimized or occluded) left the page producing frames at full rate, reporting document.visibilityState === 'visible' and running unthrottled timers until the window's visibility next changed. The same happened if throttling was disabled first and the window hidden afterwards.

After: re-enabling throttling puts the page straight back into its real visibility state, so it stops rendering and throttles like any other hidden page.

How:

  • WebContents::SetBackgroundThrottling(true) now re-hides the RenderWidgetHosts (via the view, mirroring WebContentsImpl::SetPrimaryMainFrameViewVisibility, including cross-process iframe widgets) when the page's computed visibility is hidden. Previously only the false direction touched the widget, and content only re-hides on a visibility transition, which never comes for an already-hidden page. Captured / picture-in-picture pages are left painting. The setting is applied to every frame's widget and RenderView, as HandleNewRenderFrame already does, and the false direction shows the child-frame widgets too.
  • allow_disabling_blink_scheduler_throttling_per_renderview.patch: WebViewImpl remembers the visibility the browser last asked for and re-applies it when SetSchedulerThrottling flips, instead of waiting for the next lifecycle update; the forced-visible state is also reported to WebViewObservers so media is not left background-paused.
  • Specs: hide then toggle off/on; toggle off, hide, toggle on, show; a cross-site iframe; and a muted looping video, asserting frames stop/resume and document.visibilityState follows.

Follow-up to #52844, which fixed the false direction.

Checklist

Release Notes

Notes: Fixed hidden windows continuing to render at full frame rate after setBackgroundThrottling(false) followed by setBackgroundThrottling(true).

Backports

44-x-y
Merged
PR Number
#54341
Merged At
Sep 25, 2026, 4:07:32 AM
Released In
v44.5.0
Release Date
Sep 29, 2026, 11:00:24 AM
45-x-y
Merged
PR Number
#54339
Merged At
Sep 25, 2026, 4:08:27 AM
Released In
v45.0.0-alpha.13
Release Date
Sep 28, 2026, 3:00:19 PM

Semver Impact

Major
Breaking changes
Minor
New features
Patch
Bug fixes
None
Docs, tests, etc.

Semantic Versioning helps users understand the impact of updates:

  • Major (X.y.z): Breaking changes that may require code modifications
  • Minor (x.Y.z): New features that maintain backward compatibility
  • Patch (x.y.Z): Bug fixes that don't change the API
  • None: Changes that don't affect using facing parts of Electron