fix_disabling_compositor_recycling.patch 1.7 KB

12345678910111213141516171819202122232425
  1. From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
  2. From: Samuel Attard <[email protected]>
  3. Date: Thu, 22 Aug 2019 15:26:31 -0700
  4. Subject: fix: disabling compositor recycling
  5. Compositor recycling is useful for Chrome because there can be many tabs and spinning up a compositor for each one would be costly. In practice, Chrome uses the parent compositor code path of browser_compositor_view_mac.mm; the NSView of each tab is detached when it's hidden and attached when it's shown. For Electron, there is no parent compositor, so we're forced into the "own compositor" code path, which seems to be non-optimal and pretty ruthless in terms of the release of resources. Electron has no real concept of multiple tabs per window, so it should be okay to disable this ruthless recycling altogether in Electron.
  6. diff --git a/content/browser/renderer_host/render_widget_host_view_mac.mm b/content/browser/renderer_host/render_widget_host_view_mac.mm
  7. index 2b10c5b8f6d4a7a091ef3dd9d8ff324e5663f768..477cef4973bc4f2d50aa173571fc1d2bcd0a6469 100644
  8. --- a/content/browser/renderer_host/render_widget_host_view_mac.mm
  9. +++ b/content/browser/renderer_host/render_widget_host_view_mac.mm
  10. @@ -485,7 +485,12 @@ void RenderWidgetHostViewMac::WasUnOccluded() {
  11. void RenderWidgetHostViewMac::WasOccluded() {
  12. host()->WasHidden();
  13. - browser_compositor_->SetRenderWidgetHostIsHidden(true);
  14. +
  15. + // Consider the RWHV occluded only if it is not attached to a window
  16. + // (e.g. unattached BrowserView). Otherwise we treat it as visible to
  17. + // prevent unnecessary compositor recycling.
  18. + const bool unattached = ![cocoa_view() window];
  19. + browser_compositor_->SetRenderWidgetHostIsHidden(unattached);
  20. }
  21. void RenderWidgetHostViewMac::SetSize(const gfx::Size& size) {