RESOLVED FIXED 285167
[GTK] Monitor window surfaces obscured by other windows (to suspend tabs, stop the frame clock and tell web apps to throttle themselves)
https://bugs.webkit.org/show_bug.cgi?id=285167
Summary [GTK] Monitor window surfaces obscured by other windows (to suspend tabs, sto...
Jeff Fortin
Reported 2024-12-26 09:16:37 PST
Context: https://bugs.webkit.org/show_bug.cgi?id=207756#c46 Symptoms: currently, if you have a website doing constant animations (or anything that uses the CPU), it will keep using CPU even if the window/surface is obscured by another. The goal is for it to stop wasting CPU/GPU/battery power when the user does not have the web view (and tab) focused at the forefront, by stopping the frame clock and telling web apps to throttle themselves, by propagating `document.visibilityState` and `visibilitychange`, as per: * https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilitychange_event * https://developer.mozilla.org/en-US/docs/Web/API/Document/visibilityState I would want this to happen when the window is: * hidden in part or whole by another window (whether maximized or not) * on another virtual workspace * minimized (or in hidden state) We originally thought it was a Mutter window management bug, but it seems to be a case where WebKitGTK is not actually using the Mutter/Wayland APIs to achieve this. Among the things I heard: > It's the owner of the `xdg_toplevel` that receives the suspended event. > GTK4 for example plumbs this to `GDK_TOPLEVEL_STATE_SUSPENDED`. > For WebKitGTK to make use of it, it needs to check for `GDK_TOPLEVEL_STATE_SUSPENDED`. > In GTK3, it's exposed as `GDK_VISIBILITY_FULLY_OBSCURED`. Please see https://gitlab.gnome.org/GNOME/mutter/-/issues/3634 for the detailed discussion around this, as reference.
Attachments
Jeff Fortin
Comment 1 2024-12-28 17:05:35 PST
In case it makes it easier to test one of the scenarios, in a similar issue in Firefox (https://bugzilla.mozilla.org/show_bug.cgi?id=1771902), I have discovered this handy CSS animations bench test: https://fqueze.github.io/tests/test-background-anim.html With that test, Epiphany TP (Skia) uses CPU even if the browser window is partially or fully occluded by another app's window. CPU usage falls to zero if switching to another tab, minimizing the window, or switching to another workspace.
Carlos Garcia Campos
Comment 2 2025-01-08 05:11:10 PST
EWS
Comment 3 2025-01-10 00:30:57 PST
Committed 288685@main (8d7385fad3ff): <https://commits.webkit.org/288685@main> Reviewed commits have been landed. Closing PR #38717 and removing active labels.
Note You need to log in before you can comment on or make changes to this bug.