Commit 1a9a5862 authored by Stephen Chenney's avatar Stephen Chenney Committed by Commit Bot

[Paint Holding] Only defer commits once per document

Add a flag to LocalFrameView to prevent multiple lifecycle starts
causing multiple commit deferrals.

Bug: 974280
Change-Id: Id70132f9b8ff528d96be110c4e383b3054befa55
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1663252Reviewed-by: default avatarvmpstr <vmpstr@chromium.org>
Commit-Queue: Stephen Chenney <schenney@chromium.org>
Auto-Submit: Stephen Chenney <schenney@chromium.org>
Cr-Commit-Position: refs/heads/master@{#670181}
parent a11f4f77
...@@ -1913,6 +1913,9 @@ void LocalFrameView::DidAttachDocument() { ...@@ -1913,6 +1913,9 @@ void LocalFrameView::DidAttachDocument() {
page->GlobalRootScrollerController().InitializeViewportScrollCallback( page->GlobalRootScrollerController().InitializeViewportScrollCallback(
*root_frame_viewport, *frame_->GetDocument()); *root_frame_viewport, *frame_->GetDocument());
// Allow for commits to be deferred because this is a new document.
have_deferred_commits_ = false;
} }
} }
...@@ -4146,8 +4149,17 @@ void LocalFrameView::BeginLifecycleUpdates() { ...@@ -4146,8 +4149,17 @@ void LocalFrameView::BeginLifecycleUpdates() {
if (document && base::FeatureList::IsEnabled( if (document && base::FeatureList::IsEnabled(
blink::features::kAvoidFlashBetweenNavigation)) { blink::features::kAvoidFlashBetweenNavigation)) {
if (document->DeferredCompositorCommitIsAllowed()) { if (document->DeferredCompositorCommitIsAllowed()) {
chrome_client.StartDeferringCommits( // Only defer commits once. This method gets called multiple times,
GetCommitDelayForAvoidFlashBetweenNavigation()); // and we do not want to defer a second time if we have already done
// so once and resumed commits already.
if (!have_deferred_commits_) {
chrome_client.StartDeferringCommits(
GetCommitDelayForAvoidFlashBetweenNavigation());
have_deferred_commits_ = true;
}
// We do not StopDeferringCommits in cases where we have already started.
// A previously started deferral may not have completed yet, and we do
// not want to stop it prematurely.
} else { } else {
chrome_client.StopDeferringCommits( chrome_client.StopDeferringCommits(
cc::PaintHoldingCommitTrigger::kDisallowed); cc::PaintHoldingCommitTrigger::kDisallowed);
......
...@@ -957,6 +957,10 @@ class CORE_EXPORT LocalFrameView final ...@@ -957,6 +957,10 @@ class CORE_EXPORT LocalFrameView final
bool needs_focus_on_fragment_; bool needs_focus_on_fragment_;
bool in_lifecycle_update_; bool in_lifecycle_update_;
// True if the frame has deferred commits at least once per document load.
// We won't defer again for the same document.
bool have_deferred_commits_ = false;
LifecycleData lifecycle_data_; LifecycleData lifecycle_data_;
IntRect remote_viewport_intersection_; IntRect remote_viewport_intersection_;
......
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