Skip to content

Commit 29c63f1

Browse files
author
Fady Samuel
committed
RELAND Surface synchronization: Don't evict surface on DelegatedFrameHost::WasResized
If we evict a surface before the previous CompositorFrame activates with it as a fallback, then we will attempt to add an invalid reference and we may end up with missing surfaces in surface aggregator. This CL combats the issue by avoiding evicting frames during resize. We will still only update the primary surface ID if the tab is not hidden, and we will clear the fallback surface ID if the tab is hidden. [email protected] (cherry picked from commit eb8dd47) Bug: 813157, 672962 TBR: [email protected] Change-Id: I9f35ef24597f0bc88e139b23a2994e8b32abbc70 Reviewed-on: https://chromium-review.googlesource.com/938678 Reviewed-by: Saman Sami <[email protected]> Commit-Queue: Fady Samuel <[email protected]> Cr-Original-Original-Commit-Position: refs/heads/master@{#539639} Reviewed-on: https://chromium-review.googlesource.com/943725 Reviewed-by: Fady Samuel <[email protected]> Cr-Original-Commit-Position: refs/heads/master@{#540333} Reviewed-on: https://chromium-review.googlesource.com/953126 Cr-Commit-Position: refs/branch-heads/3359@{#61} Cr-Branched-From: 66afc5e-refs/heads/master@{#540276}
1 parent 7edb197 commit 29c63f1

File tree

1 file changed

+27
-17
lines changed

1 file changed

+27
-17
lines changed

content/browser/renderer_host/delegated_frame_host.cc

Lines changed: 27 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -272,20 +272,29 @@ void DelegatedFrameHost::WasResized(
272272
pending_local_surface_id_ = new_pending_local_surface_id;
273273
pending_surface_dip_size_ = new_pending_dip_size;
274274

275-
if (enable_surface_synchronization_ &&
276-
client_->DelegatedFrameHostIsVisible() &&
277-
(!primary_surface_id ||
278-
primary_surface_id->local_surface_id() != pending_local_surface_id_)) {
279-
current_frame_size_in_dip_ = pending_surface_dip_size_;
275+
if (enable_surface_synchronization_) {
276+
if (!client_->DelegatedFrameHostIsVisible()) {
277+
if (HasFallbackSurface()) {
278+
client_->DelegatedFrameHostGetLayer()->SetFallbackSurfaceId(
279+
viz::SurfaceId());
280+
}
281+
return;
282+
}
280283

281-
viz::SurfaceId surface_id(frame_sink_id_, pending_local_surface_id_);
282-
client_->DelegatedFrameHostGetLayer()->SetShowPrimarySurface(
283-
surface_id, current_frame_size_in_dip_, GetGutterColor(),
284-
deadline_policy);
285-
if (compositor_ && !base::CommandLine::ForCurrentProcess()->HasSwitch(
286-
switches::kDisableResizeLock)) {
287-
compositor_->OnChildResizing();
284+
if (!primary_surface_id ||
285+
primary_surface_id->local_surface_id() != pending_local_surface_id_) {
286+
current_frame_size_in_dip_ = pending_surface_dip_size_;
287+
288+
viz::SurfaceId surface_id(frame_sink_id_, pending_local_surface_id_);
289+
client_->DelegatedFrameHostGetLayer()->SetShowPrimarySurface(
290+
surface_id, current_frame_size_in_dip_, GetGutterColor(),
291+
deadline_policy);
292+
if (compositor_ && !base::CommandLine::ForCurrentProcess()->HasSwitch(
293+
switches::kDisableResizeLock)) {
294+
compositor_->OnChildResizing();
295+
}
288296
}
297+
289298
// Input throttling and guttering are handled differently when surface
290299
// synchronization is enabled so exit early here.
291300
return;
@@ -547,17 +556,18 @@ void DelegatedFrameHost::OnBeginFrame(const viz::BeginFrameArgs& args) {
547556
}
548557

549558
void DelegatedFrameHost::EvictDelegatedFrame() {
550-
if (!HasFallbackSurface())
559+
if (!HasSavedFrame())
551560
return;
552561

553-
std::vector<viz::SurfaceId> surface_ids = {
554-
*client_->DelegatedFrameHostGetLayer()->GetFallbackSurfaceId()};
562+
std::vector<viz::SurfaceId> surface_ids = {GetCurrentSurfaceId()};
555563

556564
GetHostFrameSinkManager()->EvictSurfaces(surface_ids);
557565

558566
if (enable_surface_synchronization_) {
559-
client_->DelegatedFrameHostGetLayer()->SetFallbackSurfaceId(
560-
viz::SurfaceId());
567+
if (HasFallbackSurface()) {
568+
client_->DelegatedFrameHostGetLayer()->SetFallbackSurfaceId(
569+
viz::SurfaceId());
570+
}
561571
} else {
562572
client_->DelegatedFrameHostGetLayer()->SetShowSolidColorContent();
563573
resize_lock_.reset();

0 commit comments

Comments
 (0)