[go: up one dir, main page]

Don't tell |frame_evictor_| about empty frames.

Extensions can create empty frames by loading generated_background_page.html,
which count against the number of saved frames FrameEvictionManager will
hold onto. This causes minimized/occluded windows to have their foreground
tab frame evicted, which leads to empty tab previews.

(cherry picked from commit 868f600d9dbb0c7458a2129e96708cdc64006172)

Bug: 969031
Change-Id: Ieb420cc33d0ac70a2df125b8627124edb0233ee0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1651613
Commit-Queue: David Bienvenu <davidbienvenu@chromium.org>
Reviewed-by: Saman Sami <samans@chromium.org>
Cr-Original-Commit-Position: refs/heads/master@{#667699}
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1658628
Reviewed-by: David Bienvenu <davidbienvenu@chromium.org>
Cr-Commit-Position: refs/branch-heads/3809@{#288}
Cr-Branched-From: d82dec1a818f378c464ba307ddd9c92133eac355-refs/heads/master@{#665002}
diff --git a/content/browser/renderer_host/delegated_frame_host.cc b/content/browser/renderer_host/delegated_frame_host.cc
index cd3f355..3a5efa97 100644
--- a/content/browser/renderer_host/delegated_frame_host.cc
+++ b/content/browser/renderer_host/delegated_frame_host.cc
@@ -282,7 +282,10 @@
   if (seen_first_activation_)
     frame_evictor_->OnNewSurfaceEmbedded();
 #else
-  frame_evictor_->OnNewSurfaceEmbedded();
+  // Ignore empty frames. Extensions often create empty background page frames
+  // which shouldn't count against the saved frames.
+  if (!new_dip_size.IsEmpty())
+    frame_evictor_->OnNewSurfaceEmbedded();
 #endif
 
   if (!primary_surface_id ||
diff --git a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
index 9e8e7a40..1d12735e 100644
--- a/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
+++ b/content/browser/renderer_host/render_widget_host_view_aura_unittest.cc
@@ -5740,6 +5740,8 @@
 TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
        AllocateLocalSurfaceIdOnEviction) {
   view_->InitAsChild(nullptr);
+  // View has to not be empty in order for frame eviction to be invoked.
+  view_->SetSize(gfx::Size(54, 32));
   aura::client::ParentWindowWithContext(
       view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
       gfx::Rect());