Commit 7de3a34e authored by Saman Sami's avatar Saman Sami Committed by Commit Bot

Surface synchronization: Allocate new LocalSurfaceId on eviction

By allocating a new LocalSurfaceId on eviction, we can mitigate the
flash that's seen by the user when switching to an evicted tab. This CL
also fixes the race with enable-viz where the renderer submits to a
surface that is getting destroyed and we end up not showing anything.

Bug: 777881
Change-Id: I5d8ec017ea6a305607664a0f542f5b3abcf4f17f
Reviewed-on: https://chromium-review.googlesource.com/897997
Commit-Queue: Saman Sami <samans@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534481}
parent 600dc0db
...@@ -100,7 +100,7 @@ void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) { ...@@ -100,7 +100,7 @@ void DelegatedFrameHost::WasShown(const ui::LatencyInfo& latency_info) {
WasResized(cc::DeadlinePolicy::UseDefaultDeadline()); WasResized(cc::DeadlinePolicy::UseDefaultDeadline());
} }
bool DelegatedFrameHost::HasSavedFrame() { bool DelegatedFrameHost::HasSavedFrame() const {
return frame_evictor_->HasFrame(); return frame_evictor_->HasFrame();
} }
...@@ -979,4 +979,8 @@ void DelegatedFrameHost::DidNavigate() { ...@@ -979,4 +979,8 @@ void DelegatedFrameHost::DidNavigate() {
received_frame_after_navigation_ = false; received_frame_after_navigation_ = false;
} }
bool DelegatedFrameHost::IsPrimarySurfaceEvicted() const {
return local_surface_id_ == client_->GetLocalSurfaceId() && !HasSavedFrame();
}
} // namespace content } // namespace content
...@@ -145,7 +145,7 @@ class CONTENT_EXPORT DelegatedFrameHost ...@@ -145,7 +145,7 @@ class CONTENT_EXPORT DelegatedFrameHost
void WasHidden(); void WasHidden();
void WasShown(const ui::LatencyInfo& latency_info); void WasShown(const ui::LatencyInfo& latency_info);
void WasResized(const cc::DeadlinePolicy& deadline_policy); void WasResized(const cc::DeadlinePolicy& deadline_policy);
bool HasSavedFrame(); bool HasSavedFrame() const;
gfx::Size GetRequestedRendererSize() const; gfx::Size GetRequestedRendererSize() const;
void SetCompositor(ui::Compositor* compositor); void SetCompositor(ui::Compositor* compositor);
void ResetCompositor(); void ResetCompositor();
...@@ -216,6 +216,8 @@ class CONTENT_EXPORT DelegatedFrameHost ...@@ -216,6 +216,8 @@ class CONTENT_EXPORT DelegatedFrameHost
void DidNavigate(); void DidNavigate();
bool IsPrimarySurfaceEvicted() const;
private: private:
friend class DelegatedFrameHostClient; friend class DelegatedFrameHostClient;
friend class RenderWidgetHostViewAuraCopyRequestTest; friend class RenderWidgetHostViewAuraCopyRequestTest;
......
...@@ -712,6 +712,13 @@ void RenderWidgetHostViewAura::WasUnOccluded() { ...@@ -712,6 +712,13 @@ void RenderWidgetHostViewAura::WasUnOccluded() {
host_->GetLatencyComponentId(), 0); host_->GetLatencyComponentId(), 0);
renderer_latency_info.set_trace_id(++tab_show_sequence_); renderer_latency_info.set_trace_id(++tab_show_sequence_);
} }
// If the primary surface was evicted, we should create a new primary.
if (features::IsSurfaceSynchronizationEnabled() && delegated_frame_host_ &&
delegated_frame_host_->IsPrimarySurfaceEvicted()) {
WasResized(cc::DeadlinePolicy::UseDefaultDeadline());
}
TRACE_EVENT_ASYNC_BEGIN0("latency", "TabSwitching::Latency", TRACE_EVENT_ASYNC_BEGIN0("latency", "TabSwitching::Latency",
tab_show_sequence_); tab_show_sequence_);
host_->WasShown(renderer_latency_info); host_->WasShown(renderer_latency_info);
......
...@@ -409,6 +409,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura ...@@ -409,6 +409,8 @@ class CONTENT_EXPORT RenderWidgetHostViewAura
FRIEND_TEST_ALL_PREFIXES(SitePerProcessHitTestBrowserTest, PopupMenuTest); FRIEND_TEST_ALL_PREFIXES(SitePerProcessHitTestBrowserTest, PopupMenuTest);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraSurfaceSynchronizationTest, FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
NewContentRenderingTimeout); NewContentRenderingTimeout);
FRIEND_TEST_ALL_PREFIXES(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
AllocateLocalSurfaceIdOnEviction);
FRIEND_TEST_ALL_PREFIXES(WebContentsViewAuraTest, FRIEND_TEST_ALL_PREFIXES(WebContentsViewAuraTest,
WebContentsViewReparent); WebContentsViewReparent);
......
...@@ -6236,6 +6236,24 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, ...@@ -6236,6 +6236,24 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
EXPECT_FALSE(widget_host_->new_content_rendering_timeout_fired()); EXPECT_FALSE(widget_host_->new_content_rendering_timeout_fired());
} }
// If a tab is evicted, allocate a new LocalSurfaceId next time it's shown.
TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
AllocateLocalSurfaceIdOnEviction) {
view_->InitAsChild(nullptr);
aura::client::ParentWindowWithContext(
view_->GetNativeView(), parent_view_->GetNativeView()->GetRootWindow(),
gfx::Rect());
view_->Show();
viz::LocalSurfaceId id1 = view_->GetLocalSurfaceId();
view_->Hide();
view_->delegated_frame_host_->OnFirstSurfaceActivation(viz::SurfaceInfo(
viz::SurfaceId(view_->GetFrameSinkId(), id1), 1, gfx::Size(20, 20)));
view_->ClearCompositorFrame();
view_->Show();
viz::LocalSurfaceId id2 = view_->GetLocalSurfaceId();
EXPECT_NE(id1, id2);
}
// This class provides functionality to test a RenderWidgetHostViewAura // This class provides functionality to test a RenderWidgetHostViewAura
// instance which has been hooked up to a test RenderViewHost instance and // instance which has been hooked up to a test RenderViewHost instance and
// a WebContents instance. // a WebContents instance.
......
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