We should measure and report the peak gpu memory usage during particular interactions (e.g. switching tabs, resizing windows, navigations etc.). Ideally, the API would allow the browser to measure this relatively easily (e.g. https://chromium-review.googlesource.com/c/chromium/src/+/1213309/2/content/browser/web_contents/web_contents_impl.cc#5488)
From ericrk@:
"""I think managing this via the host GMB manager is limited. Android and Windows don't use GMBs for GPU raster tiles, meaning we'd have to hook other areas as well. In non-GMB based cases, there are a lot of allocations (prepaint tiles, etc...) that the browser process doesn't have knowledge of.
The most accurate way to measure memory would be via a start/stop IPCs to the GPU proc (the stop IPC could return the peak usage async). The GPU proc should have the most accurate knowledge of outstanding GPU allocations.
Due to changes in OOP-R, it may be tricky to get a 100% accurate peak memory usage including Skia intermediates (we can poll Skia for size, but getting a real "peak" value would probably involve Skia changes). If we're OK with just counting tile/quad resources, this should be pretty achievable. We'd likely want to update the MemoryTracker class (see here https://cs.chromium.org/chromium/src/gpu/command_buffer/service/memory_tracking.h?rcl=a9970a077fe564166b92de0692d794353ffabcba&l=22) to have some sort of scoped peak tracking. We'd then tunnel into all the various trackers from GpuChannelManager to start the range, and again to stop the range and collect results. It should be pretty easy to get the various GpuChannels to expose their trackers (GpuChannelManager owns Channels which own stubs which each have a tracker, need to iterate these).
"""