Bug 1745996 - Send a memory pressure event when deactivating sessions. r=jnicol,calu

WebRender retains about 50MBs of memory for every window. When switching
between lots of tabs on Android (where 1 tab = 1 window), this can cause
problems as the app will consume a significant amount of memory.

To avoid this problem, we send a memory pressure event whenever a session is
deactivated, which signals to WebRender that it should deallocate the memory.

This message is sent on a delay of 10s to avoid interfering with tab switching,
and we cancel the message if the tab becomes active again before we fire the
memory pressure event.

Co-Authored-By: Cathy Lu <calu@mozilla.com>
Co-Authored-By: Jonathan Almeida [:jonalmeida] <jonalmeida942@gmail.com>

Differential Revision: https://phabricator.services.mozilla.com/D136965
This commit is contained in:
Agi Sferro
2022-01-26 16:40:56 +00:00
parent b03fd23eeb
commit 6197f3de01
8 changed files with 60 additions and 0 deletions

View File

@@ -1117,6 +1117,21 @@ class LayerViewSupport final
gkWindow->Resize(aLeft, aTop, aWidth, aHeight, /* repaint */ false);
}
void NotifyMemoryPressure() {
MOZ_ASSERT(NS_IsMainThread());
auto acc = mWindow.Access();
if (!acc) {
return; // Already shut down.
}
nsWindow* gkWindow = acc->GetNsWindow();
if (!gkWindow) {
return;
}
gkWindow->mCompositorBridgeChild->SendNotifyMemoryPressure();
}
void SetDynamicToolbarMaxHeight(int32_t aHeight) {
MOZ_ASSERT(NS_IsMainThread());
auto acc = mWindow.Access();