Commit 13c92a34 authored by Fady Samuel's avatar Fady Samuel Committed by Commit Bot

Surface synchronization: Update primary surface on Show

If a view is shown then it should have a primary surface. Today,
the primary surface may be lost due to frame eviction but we don't
re-set it on showing a view and so it was possible to end up with
an empty tab.

Bug: 672962, 791342
Change-Id: I0ade2a58e9b78e82011e81af441a406b872b7710
Reviewed-on: https://chromium-review.googlesource.com/809935Reviewed-by: default avatarSaman Sami <samans@chromium.org>
Commit-Queue: Fady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#522100}
parent bb9c79a7
...@@ -91,9 +91,10 @@ void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { ...@@ -91,9 +91,10 @@ void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) {
released_front_lock_ = compositor_->GetCompositorLock(nullptr); released_front_lock_ = compositor_->GetCompositorLock(nullptr);
} }
if (compositor_) { if (compositor_)
compositor_->SetLatencyInfo(latency_info); compositor_->SetLatencyInfo(latency_info);
}
WasResized();
} }
bool DelegatedFrameHost::HasSavedFrame() { bool DelegatedFrameHost::HasSavedFrame() {
......
...@@ -410,6 +410,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura ...@@ -410,6 +410,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
SurfaceChanges); SurfaceChanges);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraSurfaceSynchronizationTest, FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
DeviceScaleFactorChanges); DeviceScaleFactorChanges);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
HideThenShow);
FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest, PopupMenuTest); FRIEND_TEST_ALL_PREFIXES(SitePerProcessBrowserTest, PopupMenuTest);
FRIEND_TEST_ALL_PREFIXES(WebContentsViewAuraTest, FRIEND_TEST_ALL_PREFIXES(WebContentsViewAuraTest,
WebContentsViewReparent); WebContentsViewReparent);
......
...@@ -3135,6 +3135,31 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, SurfaceChanges) { ...@@ -3135,6 +3135,31 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, SurfaceChanges) {
EXPECT_EQ(gfx::Size(400, 400), view_->window_->layer()->size()); EXPECT_EQ(gfx::Size(400, 400), view_->window_->layer()->size());
} }
// This test verifies that even if the primary surface is evicted after
// the view is hidden, when it is shown again, the layer is repopulated.
TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, HideThenShow) {
view_->InitAsChild(nullptr);
aura::client::ParentWindowWithContext(
view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
gfx::Rect());
EXPECT_FALSE(view_->HasPrimarySurface());
ASSERT_TRUE(view_->delegated_frame_host_);
view_->SetSize(gfx::Size(300, 300));
ASSERT_TRUE(view_->HasPrimarySurface());
EXPECT_EQ(gfx::Size(300, 300), view_->window_->layer()->size());
EXPECT_EQ(gfx::Size(300, 300),
view_->delegated_frame_host_->CurrentFrameSizeInDipForTesting());
view_->Hide();
view_->delegated_frame_host_->ClearDelegatedFrame();
ASSERT_FALSE(view_->HasPrimarySurface());
view_->Show();
ASSERT_TRUE(view_->HasPrimarySurface());
}
// This test verifies that the primary SurfaceInfo is updated on device scale // This test verifies that the primary SurfaceInfo is updated on device scale
// factor changes. // factor changes.
TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
...@@ -3245,8 +3270,8 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, ...@@ -3245,8 +3270,8 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
// LRU renderer is [0], make it visible, it shouldn't evict anything yet. // LRU renderer is [0], make it visible, it shouldn't evict anything yet.
views[0]->Show(); views[0]->Show();
EXPECT_FALSE(views[0]->HasPrimarySurface()); EXPECT_TRUE(views[0]->HasPrimarySurface());
EXPECT_TRUE(views[1]->HasPrimarySurface()); EXPECT_FALSE(views[1]->HasPrimarySurface());
// Resize [0], it should evict the next LRU [1]. // Resize [0], it should evict the next LRU [1].
views[0]->SetSize(gfx::Size(300, 300)); views[0]->SetSize(gfx::Size(300, 300));
...@@ -3269,11 +3294,6 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, ...@@ -3269,11 +3294,6 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
// hidden, it becomes the LRU. // hidden, it becomes the LRU.
for (size_t i = 1; i < renderer_count; ++i) { for (size_t i = 1; i < renderer_count; ++i) {
views[i]->Show(); views[i]->Show();
// The renderers who don't have a frame should be waiting. The ones that
// have a frame should not.
// In practice, [1] has a frame, but anything after has its frame evicted.
EXPECT_EQ(!views[i]->HasPrimarySurface(),
views[i]->released_front_lock_active());
views[i]->SetSize(gfx::Size(300, 300)); views[i]->SetSize(gfx::Size(300, 300));
EXPECT_TRUE(views[i]->HasPrimarySurface()); EXPECT_TRUE(views[i]->HasPrimarySurface());
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment