Commit 8b1dc2e1 authored by Xianzhu Wang's avatar Xianzhu Wang Committed by Commit Bot

Re-collect graphics layers on change of frame throttling

Bug: 963782
Change-Id: I8c6faf984321c38765357bf613bdb27a71c282bb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1616445Reviewed-by: default avatarPhilip Rogers <pdr@chromium.org>
Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#660846}
parent 4ee4c0fb
......@@ -2357,7 +2357,7 @@ bool LocalFrameView::RunPrePaintLifecyclePhase(
frame_view.SetNeedsPaintPropertyUpdate();
// We may record more foreign layers under the frame.
if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled())
frame_view.SetPaintArtifactCompositorNeedsUpdate();
frame_view.GraphicsLayersDidChange();
if (auto* owner = frame_view.GetLayoutEmbeddedContent())
owner->SetShouldCheckForPaintInvalidation();
}
......@@ -4016,6 +4016,10 @@ void LocalFrameView::RenderThrottlingStatusChanged() {
DCHECK(!IsInPerformLayout());
DCHECK(!frame_->GetDocument() || !frame_->GetDocument()->InStyleRecalc());
// We may record more/less foreign layers under the frame.
if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled())
GraphicsLayersDidChange();
ScrollingCoordinator* scrolling_coordinator = this->GetScrollingCoordinator();
if (!CanThrottleRendering()) {
// ScrollingCoordinator needs to update according to the new throttling
......@@ -4036,9 +4040,6 @@ void LocalFrameView::RenderThrottlingStatusChanged() {
layout_view->AddSubtreePaintPropertyUpdateReason(
SubtreePaintPropertyUpdateReason::kPreviouslySkipped);
}
// We may record more foreign layers under the frame.
if (RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled())
SetPaintArtifactCompositorNeedsUpdate();
}
if (scrolling_coordinator) {
......
......@@ -991,6 +991,7 @@ class CORE_EXPORT LocalFrameView final
#endif
FRIEND_TEST_ALL_PREFIXES(WebViewTest, DeviceEmulationResetScrollbars);
FRIEND_TEST_ALL_PREFIXES(FrameThrottlingTest, GraphicsLayerCollection);
};
inline void LocalFrameView::IncrementVisuallyNonEmptyCharacterCount(
......
......@@ -26,6 +26,7 @@
#include "third_party/blink/renderer/core/testing/sim/sim_compositor.h"
#include "third_party/blink/renderer/core/testing/sim/sim_request.h"
#include "third_party/blink/renderer/core/testing/sim/sim_test.h"
#include "third_party/blink/renderer/platform/graphics/paint/paint_controller.h"
#include "third_party/blink/renderer/platform/graphics/paint/transform_paint_property_node.h"
#include "third_party/blink/renderer/platform/testing/paint_test_configurations.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
......@@ -1392,4 +1393,71 @@ TEST_P(FrameThrottlingTest, LifecycleUpdateAfterUnthrottledCompositingUpdate) {
}
}
TEST_P(FrameThrottlingTest, GraphicsLayerCollection) {
// This test is for BlinkGenPropertyTrees only.
if (!RuntimeEnabledFeatures::BlinkGenPropertyTreesEnabled() ||
RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
return;
SimRequest main_resource("https://example.com/", "text/html");
SimRequest frame_resource("https://example.com/iframe.html", "text/html");
LoadURL("https://example.com/");
// The frame is initially throttled.
main_resource.Complete(
"<iframe id='frame' sandbox src='iframe.html'></iframe>");
frame_resource.Complete(
"<div id='div' style='will-change: transform'>Foo</div>");
DocumentLifecycle::AllowThrottlingScope throttling_scope(
GetDocument().Lifecycle());
CompositeFrame();
auto* frame_element =
ToHTMLIFrameElement(GetDocument().getElementById("frame"));
auto* frame_document = frame_element->contentDocument();
EXPECT_FALSE(frame_document->View()->ShouldThrottleRendering());
auto* paint_controller = GetDocument().View()->GetPaintController();
ASSERT_NE(nullptr, paint_controller);
auto display_item_count = paint_controller->GetDisplayItemList().size();
// Moving the child fully outside the parent makes it invisible.
frame_element->setAttribute(kStyleAttr, "transform: translateY(480px)");
CompositeFrame();
EXPECT_TRUE(frame_document->View()->ShouldThrottleRendering());
// Change of throttling clears paint controller, to force re-collection of
// graphics layers in the next frame.
EXPECT_EQ(nullptr, GetDocument().View()->GetPaintController());
// Force a frame update. We should re-collect the graphics layers.
GetDocument().GetPage()->Animator().ScheduleVisualUpdate(
GetDocument().GetFrame());
CompositeFrame();
EXPECT_TRUE(frame_document->View()->ShouldThrottleRendering());
paint_controller = GetDocument().View()->GetPaintController();
ASSERT_NE(nullptr, paint_controller);
// We no longer collect the graphics layers of the iframe and the composited
// content.
EXPECT_EQ(display_item_count - 2,
paint_controller->GetDisplayItemList().size());
// Move the child back to the visible viewport.
frame_element->setAttribute(kStyleAttr,
"transform: translate(-50px, 0px, 0px)");
// Update throttling, which will schedule visual update on unthrottling of the
// frame.
CompositeFrame();
EXPECT_FALSE(frame_document->View()->ShouldThrottleRendering());
// Change of throttling clears paint controller, to force re-collection of
// graphics layers in the next frame.
EXPECT_EQ(nullptr, GetDocument().View()->GetPaintController());
CompositeFrame();
EXPECT_FALSE(frame_document->View()->ShouldThrottleRendering());
paint_controller = GetDocument().View()->GetPaintController();
ASSERT_NE(nullptr, paint_controller);
// Now we should collect all graphics layers again.
EXPECT_EQ(display_item_count, paint_controller->GetDisplayItemList().size());
}
} // namespace blink
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