Bug 285167
Summary: | [GTK] Monitor window surfaces obscured by other windows (to suspend tabs, stop the frame clock and tell web apps to throttle themselves) | ||
---|---|---|---|
Product: | WebKit | Reporter: | Jeff Fortin <nekohayo> |
Component: | WebKitGTK | Assignee: | Carlos Garcia Campos <cgarcia> |
Status: | RESOLVED FIXED | ||
Severity: | Enhancement | CC: | bugs-noreply |
Priority: | P2 | Keywords: | Performance |
Version: | WebKit Nightly Build | ||
Hardware: | PC | ||
OS: | Linux | ||
See Also: |
https://bugs.webkit.org/show_bug.cgi?id=207756 https://bugs.webkit.org/show_bug.cgi?id=259227 |
||
Bug Depends on: | |||
Bug Blocks: | 245783 |
Jeff Fortin
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 | ||
---|---|---|
Add attachment proposed patch, testcase, etc. |
Jeff Fortin
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
Pull request: https://github.com/WebKit/WebKit/pull/38717
EWS
Committed 288685@main (8d7385fad3ff): <https://commits.webkit.org/288685@main>
Reviewed commits have been landed. Closing PR #38717 and removing active labels.