Commit 27ac690d authored by Saman Sami's avatar Saman Sami Committed by Commit Bot

Hack for demo screensaver disappearing momentarily after login

There is an existing bug in Chrome OS where the screensaver is told to
hide even though it's still visible. Before crrev.com/c/1277826 this
used to only cause a freeze, but since then the screensaver disappears
altogether. The reason is that during the first 10-20 seconds after
logging into Chrome OS, there are 30+ renderers spawned in the
background that don't actually draw anything. These renderers overwhelm
FrameEvictionManager such that any renderer that goes hidden (e.g. the
screensaver) will have its surface immediately evicted. This used to
work fine before because notifying FrameEvictionManager used to happen
in OnFirstSurfaceActivation as opposed to EmbedSurface, and therefore
these useless renderers would not interfere with frame eviction. The
Chrome OS team is worried they won't have a proper fix in time, so for
the time being implement a behaviour similar to what we had before: only
report DelegatedFrameHosts to FrameEvictionManager that have seen their
first surface activation.

Bug: 900373
Change-Id: Ic98929f8e1c834de2af22aa299805395be6a9072
Reviewed-on: https://chromium-review.googlesource.com/c/1334590
Commit-Queue: Saman Sami <samans@chromium.org>
Reviewed-by: default avatarFady Samuel <fsamuel@chromium.org>
Cr-Commit-Position: refs/heads/master@{#608041}
parent e8fcf79a
......@@ -50,8 +50,14 @@ DelegatedFrameHost::DelegatedFrameHost(const viz::FrameSinkId& frame_sink_id,
ImageTransportFactory* factory = ImageTransportFactory::GetInstance();
factory->GetContextFactory()->AddObserver(this);
DCHECK(host_frame_sink_manager_);
viz::ReportFirstSurfaceActivation should_report_first_surface_activation =
viz::ReportFirstSurfaceActivation::kNo;
#ifdef CHROME_OS
should_report_first_surface_activation =
viz::ReportFirstSurfaceActivation::kYes;
#endif
host_frame_sink_manager_->RegisterFrameSinkId(
frame_sink_id_, this, viz::ReportFirstSurfaceActivation::kNo);
frame_sink_id_, this, should_report_first_surface_activation);
host_frame_sink_manager_->EnableSynchronizationReporting(
frame_sink_id_, "Compositing.MainFrameSynchronization.Duration");
host_frame_sink_manager_->SetFrameSinkDebugLabel(frame_sink_id_,
......@@ -222,7 +228,12 @@ void DelegatedFrameHost::EmbedSurface(
return;
}
#ifdef OS_CHROMEOS
if (seen_first_activation_)
frame_evictor_->OnNewSurfaceEmbedded();
#else
frame_evictor_->OnNewSurfaceEmbedded();
#endif
if (!primary_surface_id ||
primary_surface_id->local_surface_id() != local_surface_id_) {
......@@ -295,7 +306,13 @@ void DelegatedFrameHost::OnBeginFramePausedChanged(bool paused) {
void DelegatedFrameHost::OnFirstSurfaceActivation(
const viz::SurfaceInfo& surface_info) {
#ifdef OS_CHROMEOS
if (!seen_first_activation_)
frame_evictor_->OnNewSurfaceEmbedded();
seen_first_activation_ = true;
#else
NOTREACHED();
#endif
}
void DelegatedFrameHost::OnFrameTokenChanged(uint32_t frame_token) {
......
......@@ -222,6 +222,10 @@ class CONTENT_EXPORT DelegatedFrameHost
viz::LocalSurfaceId first_local_surface_id_after_navigation_;
#ifdef OS_CHROMEOS
bool seen_first_activation_ = false;
#endif
base::WeakPtrFactory<DelegatedFrameHost> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(DelegatedFrameHost);
......
......@@ -3502,6 +3502,13 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
views[i]->GetNativeView(),
parent_view_->GetNativeView()->GetRootWindow(), gfx::Rect());
views[i]->SetSize(view_rect.size());
#ifdef OS_CHROMEOS
viz::SurfaceId surface_id(
views[i]->GetFrameSinkId(),
views[i]->GetLocalSurfaceIdAllocation().local_surface_id());
views[i]->delegated_frame_host_->OnFirstSurfaceActivation(
viz::SurfaceInfo(surface_id, 1.f, view_rect.size()));
#endif
EXPECT_HAS_FRAME(views[i]);
}
......@@ -3618,6 +3625,13 @@ TEST_F(RenderWidgetHostViewAuraTest, DiscardDelegatedFramesWithMemoryPressure) {
gfx::Rect());
views[i]->SetSize(view_rect.size());
views[i]->Show();
#ifdef OS_CHROMEOS
viz::SurfaceId surface_id(
views[i]->GetFrameSinkId(),
views[i]->GetLocalSurfaceIdAllocation().local_surface_id());
views[i]->delegated_frame_host_->OnFirstSurfaceActivation(
viz::SurfaceInfo(surface_id, 1.f, view_rect.size()));
#endif
EXPECT_HAS_FRAME(views[i]);
}
......@@ -5817,6 +5831,13 @@ TEST_F(RenderWidgetHostViewAuraSurfaceSynchronizationTest,
viz::LocalSurfaceId id1 =
view_->GetLocalSurfaceIdAllocation().local_surface_id();
view_->Hide();
#ifdef OS_CHROMEOS
viz::SurfaceId surface_id(
view_->GetFrameSinkId(),
view_->GetLocalSurfaceIdAllocation().local_surface_id());
view_->delegated_frame_host_->OnFirstSurfaceActivation(
viz::SurfaceInfo(surface_id, 1.f, gfx::Size(10, 10)));
#endif
static_cast<viz::FrameEvictorClient*>(view_->delegated_frame_host_.get())
->EvictDelegatedFrame();
view_->Show();
......
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