Commit 98844764 authored by jonross's avatar jonross Committed by Commit Bot

Invalidate LocalSurfaceId on Hidden Navigation

Currently RenderWidgetHostViewAura allocates a new LocalSurfaceId upon
Navigation. However if this navigation is for a hidden view, then we are
allocating very early. This has skewed the statistics for embedding times.

This updates RenderWidgetHostViewAura::DidNavigate to Invalidate the
LocalSurfaceId if hidden. A new one will be allocated once the view is shown.

Bug: 655231
Change-Id: I86cc4efade8b927149f57323281a87b0dcd1aac3
Reviewed-on: https://chromium-review.googlesource.com/c/1347446
Commit-Queue: Jonathan Ross <jonross@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#611319}
parent 337f4112
...@@ -356,14 +356,23 @@ BrowserCompositorMac::CollectSurfaceIdsForEviction() { ...@@ -356,14 +356,23 @@ BrowserCompositorMac::CollectSurfaceIdsForEviction() {
} }
void BrowserCompositorMac::DidNavigate() { void BrowserCompositorMac::DidNavigate() {
if (render_widget_host_is_hidden_) {
// Navigating while hidden should not allocate a new LocalSurfaceID. Once
// sizes are ready, or we begin to Show, we can then allocate the new
// LocalSurfaceId.
dfh_local_surface_id_allocator_.Invalidate();
} else {
// The first navigation does not need a new LocalSurfaceID. The renderer can // The first navigation does not need a new LocalSurfaceID. The renderer can
// use the ID that was already provided. // use the ID that was already provided.
if (!is_first_navigation_) if (!is_first_navigation_) {
dfh_local_surface_id_allocator_.GenerateId(); dfh_local_surface_id_allocator_.GenerateId();
}
delegated_frame_host_->EmbedSurface( delegated_frame_host_->EmbedSurface(
dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceId(), dfh_size_dip_, dfh_local_surface_id_allocator_.GetCurrentLocalSurfaceId(),
cc::DeadlinePolicy::UseExistingDeadline()); dfh_size_dip_, cc::DeadlinePolicy::UseExistingDeadline());
client_->OnBrowserCompositorSurfaceIdChanged(); client_->OnBrowserCompositorSurfaceIdChanged();
}
delegated_frame_host_->DidNavigate(); delegated_frame_host_->DidNavigate();
is_first_navigation_ = false; is_first_navigation_ = false;
} }
......
...@@ -2374,7 +2374,12 @@ void RenderWidgetHostViewAndroid::DidNavigate() { ...@@ -2374,7 +2374,12 @@ void RenderWidgetHostViewAndroid::DidNavigate() {
RenderWidgetHostViewBase::DidNavigate(); RenderWidgetHostViewBase::DidNavigate();
return; return;
} }
if (!is_showing_) {
// Navigating while hidden should not allocate a new LocalSurfaceID. Once
// sizes are ready, or we begin to Show, we can then allocate the new
// LocalSurfaceId.
local_surface_id_allocator_.Invalidate();
} else {
if (is_first_navigation_) { if (is_first_navigation_) {
SynchronizeVisualProperties( SynchronizeVisualProperties(
cc::DeadlinePolicy::UseExistingDeadline(), cc::DeadlinePolicy::UseExistingDeadline(),
...@@ -2383,6 +2388,7 @@ void RenderWidgetHostViewAndroid::DidNavigate() { ...@@ -2383,6 +2388,7 @@ void RenderWidgetHostViewAndroid::DidNavigate() {
SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(), SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(),
base::nullopt); base::nullopt);
} }
}
delegated_frame_host_->DidNavigate(); delegated_frame_host_->DidNavigate();
is_first_navigation_ = false; is_first_navigation_ = false;
} }
......
...@@ -2249,6 +2249,9 @@ void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { ...@@ -2249,6 +2249,9 @@ void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
if (!in_bounds_changed_) if (!in_bounds_changed_)
window_->SetBounds(rect); window_->SetBounds(rect);
// Even if not showing yet, we need to synchronize on size. As the renderer
// needs to begin layout. Waiting until we show to start layout leads to
// significant delays in embedding the first shown surface (500+ ms.)
SynchronizeVisualProperties(cc::DeadlinePolicy::UseDefaultDeadline(), SynchronizeVisualProperties(cc::DeadlinePolicy::UseDefaultDeadline(),
window_->GetLocalSurfaceIdAllocation()); window_->GetLocalSurfaceIdAllocation());
...@@ -2557,15 +2560,22 @@ RenderWidgetHostViewAura::DidUpdateVisualProperties( ...@@ -2557,15 +2560,22 @@ RenderWidgetHostViewAura::DidUpdateVisualProperties(
} }
void RenderWidgetHostViewAura::DidNavigate() { void RenderWidgetHostViewAura::DidNavigate() {
// The first navigation does not need a new LocalSurfaceID. The renderer can if (!IsShowing()) {
// use the ID that was already provided. // Navigating while hidden should not allocate a new LocalSurfaceID. Once
// sizes are ready, or we begin to Show, we can then allocate the new
// LocalSurfaceId.
window_->InvalidateLocalSurfaceId();
} else {
if (is_first_navigation_) { if (is_first_navigation_) {
// The first navigation does not need a new LocalSurfaceID. The renderer
// can use the ID that was already provided.
SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(), SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(),
window_->GetLocalSurfaceIdAllocation()); window_->GetLocalSurfaceIdAllocation());
} else { } else {
SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(), SynchronizeVisualProperties(cc::DeadlinePolicy::UseExistingDeadline(),
base::nullopt); base::nullopt);
} }
}
if (delegated_frame_host_) if (delegated_frame_host_)
delegated_frame_host_->DidNavigate(); delegated_frame_host_->DidNavigate();
is_first_navigation_ = false; is_first_navigation_ = false;
......
...@@ -5781,6 +5781,9 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest, ...@@ -5781,6 +5781,9 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
view_->GetLocalSurfaceIdAllocation().local_surface_id(); view_->GetLocalSurfaceIdAllocation().local_surface_id();
EXPECT_TRUE(id0.is_valid()); EXPECT_TRUE(id0.is_valid());
// No LocalSurfaceId will be allocated if the view is hidden during
// naviagtion.
view_->Show();
// No new LocalSurfaceId should be allocated for the first navigation and the // No new LocalSurfaceId should be allocated for the first navigation and the
// timer should not fire. // timer should not fire.
widget_host_->DidNavigate(1); widget_host_->DidNavigate(1);
......
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