Commit 00808efe authored by Chris Harrelson's avatar Chris Harrelson Committed by Commit Bot

Skip throttled documents entirely for servicing scripted animations

It should be ok to let animation timings go stale for such documents.
This has a significant performance impact in the presence of many
lazy-loaded iframes.

Bug: 1137931

Change-Id: I394ae63ea2c220b175fd7724ff915c2786046a76
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2536811Reviewed-by: default avatarOlga Gerchikov <gerchiko@microsoft.com>
Reviewed-by: default avatarRobert Flack <flackr@chromium.org>
Commit-Queue: Chris Harrelson <chrishtr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#828006}
parent bdef670b
...@@ -22,12 +22,19 @@ namespace { ...@@ -22,12 +22,19 @@ namespace {
typedef HeapVector<Member<Document>, 32> DocumentsVector; typedef HeapVector<Member<Document>, 32> DocumentsVector;
enum OnlyThrottledOrNot { OnlyNonThrottled, AllDocuments };
// We walk through all the frames in DOM tree order and get all the documents // We walk through all the frames in DOM tree order and get all the documents
DocumentsVector GetAllDocuments(Frame* main_frame) { DocumentsVector GetAllDocuments(Frame* main_frame,
OnlyThrottledOrNot which_documents) {
DocumentsVector documents; DocumentsVector documents;
for (Frame* frame = main_frame; frame; frame = frame->Tree().TraverseNext()) { for (Frame* frame = main_frame; frame; frame = frame->Tree().TraverseNext()) {
if (auto* local_frame = DynamicTo<LocalFrame>(frame)) if (auto* local_frame = DynamicTo<LocalFrame>(frame)) {
documents.push_back(local_frame->GetDocument()); Document* document = local_frame->GetDocument();
if (which_documents == AllDocuments || !document->View() ||
!document->View()->CanThrottleRendering())
documents.push_back(document);
}
} }
return documents; return documents;
} }
...@@ -52,16 +59,18 @@ void PageAnimator::ServiceScriptedAnimations( ...@@ -52,16 +59,18 @@ void PageAnimator::ServiceScriptedAnimations(
Clock().SetAllowedToDynamicallyUpdateTime(false); Clock().SetAllowedToDynamicallyUpdateTime(false);
Clock().UpdateTime(monotonic_animation_start_time); Clock().UpdateTime(monotonic_animation_start_time);
DocumentsVector documents = GetAllDocuments(page_->MainFrame()); DocumentsVector documents =
GetAllDocuments(page_->MainFrame(), OnlyNonThrottled);
for (auto& document : documents) { for (auto& document : documents) {
ScopedFrameBlamer frame_blamer(document->GetFrame()); ScopedFrameBlamer frame_blamer(document->GetFrame());
TRACE_EVENT0("blink,rail", "PageAnimator::serviceScriptedAnimations"); TRACE_EVENT0("blink,rail", "PageAnimator::serviceScriptedAnimations");
if (!document->View() || document->View()->CanThrottleRendering()) { if (!document->View()) {
document->GetDocumentAnimations() document->GetDocumentAnimations()
.UpdateAnimationTimingForAnimationFrame(); .UpdateAnimationTimingForAnimationFrame();
continue; continue;
} }
DCHECK(!document->View()->CanThrottleRendering());
document->View()->ServiceScriptedAnimations(monotonic_animation_start_time); document->View()->ServiceScriptedAnimations(monotonic_animation_start_time);
} }
...@@ -151,7 +160,7 @@ void PageAnimator::UpdateLifecycleToLayoutClean(LocalFrame& root_frame, ...@@ -151,7 +160,7 @@ void PageAnimator::UpdateLifecycleToLayoutClean(LocalFrame& root_frame,
HeapVector<Member<Animation>> PageAnimator::GetAnimations( HeapVector<Member<Animation>> PageAnimator::GetAnimations(
const TreeScope& tree_scope) { const TreeScope& tree_scope) {
HeapVector<Member<Animation>> animations; HeapVector<Member<Animation>> animations;
DocumentsVector documents = GetAllDocuments(page_->MainFrame()); DocumentsVector documents = GetAllDocuments(page_->MainFrame(), AllDocuments);
for (auto& document : documents) { for (auto& document : documents) {
document->GetDocumentAnimations().GetAnimationsTargetingTreeScope( document->GetDocumentAnimations().GetAnimationsTargetingTreeScope(
animations, tree_scope); animations, tree_scope);
......
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