-
Notifications
You must be signed in to change notification settings - Fork 6.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Exclude initially out-of-view frames for paint timing (behind feature)
Behind kPaintTimingNoOutOfViewFrames feature (disabled by default for now), paint timing is excluded for frames that are initially out-of-view, to make related metrics reflect the performance, instead of depending on paint implementation (e.g. how we paint out-of-view contents) and arbitrary user actions (e.g. when the user scrolls out-of-view contents near/into view). Bug: 1236136 Change-Id: I316f0d0c7e8f77545fe564570d21f37e272f7660 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3072009 Commit-Queue: Xianzhu Wang <wangxianzhu@chromium.org> Reviewed-by: Nicolás Peña Moreno <npm@chromium.org> Reviewed-by: Philip Rogers <pdr@chromium.org> Cr-Commit-Position: refs/heads/master@{#908961}
- Loading branch information
1 parent
23ac3ba
commit f07b976
Showing
8 changed files
with
145 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
third_party/blink/renderer/core/paint/paint_timing_test.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
// Copyright 2021 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#include "third_party/blink/renderer/core/paint/paint_timing.h" | ||
|
||
#include "base/test/scoped_feature_list.h" | ||
#include "third_party/blink/public/common/features.h" | ||
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h" | ||
|
||
namespace blink { | ||
|
||
class PaintTimingTest : public RenderingTest { | ||
public: | ||
PaintTimingTest() | ||
: RenderingTest(MakeGarbageCollected<SingleChildLocalFrameClient>()) {} | ||
}; | ||
|
||
TEST_F(PaintTimingTest, InViewFrame) { | ||
base::test::ScopedFeatureList features; | ||
features.InitWithFeatureState(features::kPaintTimingNoOutOfViewFrames, true); | ||
|
||
SetBodyInnerHTML("<iframe></iframe>"); | ||
SetChildFrameHTML("ABC"); | ||
UpdateAllLifecyclePhasesForTest(); | ||
|
||
PaintTiming& paint_timing = PaintTiming::From(ChildDocument()); | ||
paint_timing.ReportPresentationTime(PaintEvent::kFirstContentfulPaint, | ||
WebSwapResult::kDidSwap, | ||
base::TimeTicks::Now()); | ||
EXPECT_FALSE(paint_timing.FirstContentfulPaint().is_null()); | ||
} | ||
|
||
TEST_F(PaintTimingTest, ExcludeOutOfViewFrame) { | ||
base::test::ScopedFeatureList features; | ||
features.InitWithFeatureState(features::kPaintTimingNoOutOfViewFrames, true); | ||
|
||
SetBodyInnerHTML( | ||
"<iframe style='position: absolute; top: 20000px'></iframe>"); | ||
SetChildFrameHTML("ABC"); | ||
UpdateAllLifecyclePhasesForTest(); | ||
|
||
// Should not report FCP for the out-of-view frame. | ||
PaintTiming& paint_timing = PaintTiming::From(ChildDocument()); | ||
paint_timing.ReportPresentationTime(PaintEvent::kFirstContentfulPaint, | ||
WebSwapResult::kDidSwap, | ||
base::TimeTicks::Now()); | ||
EXPECT_TRUE(paint_timing.FirstContentfulPaint().is_null()); | ||
} | ||
|
||
TEST_F(PaintTimingTest, ExcludeOutOfViewFrameScrolledIntoView) { | ||
base::test::ScopedFeatureList features; | ||
features.InitWithFeatureState(features::kPaintTimingNoOutOfViewFrames, true); | ||
|
||
SetBodyInnerHTML( | ||
"<iframe style='position: absolute; top: 20000px'></iframe>"); | ||
SetChildFrameHTML("ABC"); | ||
UpdateAllLifecyclePhasesForTest(); | ||
|
||
// Should not report FCP even if the iframe scrolls into view and get painted | ||
// because the iframe is initially out-of-view. | ||
GetDocument().View()->LayoutViewport()->SetScrollOffset( | ||
ScrollOffset(0, 20000), mojom::blink::ScrollType::kProgrammatic); | ||
UpdateAllLifecyclePhasesForTest(); | ||
PaintTiming& paint_timing = PaintTiming::From(ChildDocument()); | ||
paint_timing.ReportPresentationTime(PaintEvent::kFirstContentfulPaint, | ||
WebSwapResult::kDidSwap, | ||
base::TimeTicks::Now()); | ||
EXPECT_TRUE(paint_timing.FirstContentfulPaint().is_null()); | ||
} | ||
|
||
TEST_F(PaintTimingTest, IncludeOutOfViewFrame) { | ||
base::test::ScopedFeatureList features; | ||
features.InitWithFeatureState(features::kPaintTimingNoOutOfViewFrames, false); | ||
|
||
SetBodyInnerHTML( | ||
"<iframe style='position: absolute; top: 20000px'></iframe>"); | ||
SetChildFrameHTML("ABC"); | ||
UpdateAllLifecyclePhasesForTest(); | ||
|
||
PaintTiming& paint_timing = PaintTiming::From(ChildDocument()); | ||
paint_timing.ReportPresentationTime(PaintEvent::kFirstContentfulPaint, | ||
WebSwapResult::kDidSwap, | ||
base::TimeTicks::Now()); | ||
EXPECT_FALSE(paint_timing.FirstContentfulPaint().is_null()); | ||
} | ||
|
||
} // namespace blink |