Commit be98b1c3 authored by Bryan McQuade's avatar Bryan McQuade Committed by Commit Bot

Add an AMP LayoutInstability BeforeInputOrScroll metric

If we decide that the non-AMP BeforeInputOrScroll variant is useful,
we'll want an AMP version to compare it to.

This change also cleans up metric descriptions in ukm.xml to no
longer refer to 'jank'.

Change-Id: Iee0f25b3ded5ce4667cd6c231acf9e7ea2b65515
Bug: 987652
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1717123Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Commit-Queue: Bryan McQuade <bmcquade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#681373}
parent caa66379
......@@ -192,6 +192,8 @@ void AMPPageLoadMetricsObserver::OnSubFrameRenderDataUpdate(
return;
it->second.render_data.layout_shift_score += render_data.layout_shift_delta;
it->second.render_data.layout_shift_score_before_input_or_scroll +=
render_data.layout_shift_delta_before_input_or_scroll;
}
void AMPPageLoadMetricsObserver::OnComplete(
......@@ -420,10 +422,17 @@ void AMPPageLoadMetricsObserver::MaybeRecordAmpDocumentMetrics() {
// full-frame layout shifts.
float clamped_shift_score =
std::min(subframe_info.render_data.layout_shift_score, 10.0f);
float clamped_shift_score_before_input_or_scroll = std::min(
subframe_info.render_data.layout_shift_score_before_input_or_scroll,
10.0f);
// For UKM, report (shift_score * 100) as an int in the range [0, 1000].
builder.SetSubFrame_LayoutInstability_CumulativeShiftScore(
static_cast<int>(roundf(clamped_shift_score * 100.0f)));
builder
.SetSubFrame_LayoutInstability_CumulativeShiftScore(
static_cast<int>(roundf(clamped_shift_score * 100.0f)))
.SetSubFrame_LayoutInstability_CumulativeShiftScore_BeforeInputOrScroll(
static_cast<int>(
roundf(clamped_shift_score_before_input_or_scroll * 100.0f)));
// For UMA, report (shift_score * 10) an an int in the range [0,100].
int32_t uma_value = static_cast<int>(roundf(clamped_shift_score * 10.0f));
......
......@@ -373,7 +373,7 @@ TEST_F(AMPPageLoadMetricsObserverTest, SubFrameMetrics_LayoutInstability) {
blink::WebLoadingBehaviorFlag::kWebLoadingBehaviorAmpDocumentLoaded;
SimulateMetadataUpdate(metadata, subframe);
page_load_metrics::mojom::FrameRenderDataUpdate render_data(1.0, 1.0);
page_load_metrics::mojom::FrameRenderDataUpdate render_data(1.0, 0.5);
SimulateRenderDataUpdate(render_data, subframe);
// Navigate the main frame to trigger metrics recording.
......@@ -390,6 +390,10 @@ TEST_F(AMPPageLoadMetricsObserverTest, SubFrameMetrics_LayoutInstability) {
test_ukm_recorder().ExpectEntrySourceHasUrl(entry.get(), amp_url);
test_ukm_recorder().ExpectEntryMetric(
entry.get(), "SubFrame.LayoutInstability.CumulativeShiftScore", 100);
test_ukm_recorder().ExpectEntryMetric(
entry.get(),
"SubFrame.LayoutInstability.CumulativeShiftScore.BeforeInputOrScroll",
50);
}
TEST_F(AMPPageLoadMetricsObserverTest, SubFrameMetricsFullNavigation) {
......
......@@ -296,9 +296,19 @@ be describing additional metrics about the same event.
</metric>
<metric name="SubFrame.LayoutInstability.CumulativeShiftScore">
<summary>
Measures the amount of layout jank (bit.ly/lsm-explainer) that has
Measures the cumulative layout shift (bit.ly/lsm-explainer) that has
occurred during the session, in the AMP subframe. This metric's integral
value is 100x the fractional jank score described in the explainer.
value is 100x the fractional cumulative layout shift score described in
the explainer.
</summary>
</metric>
<metric
name="SubFrame.LayoutInstability.CumulativeShiftScore.BeforeInputOrScroll">
<summary>
Measures the cumulative layout shift (bit.ly/lsm-explainer) that has
occurred in the AMP subframe, before any user input or document scroll.
This metric's integral value is 100x the fractional cumulative layout
shift score described in the explainer.
</summary>
</metric>
<metric name="SubFrame.LayoutStability.JankScore">
......@@ -5377,26 +5387,27 @@ be describing additional metrics about the same event.
</metric>
<metric name="LayoutInstability.CumulativeShiftScore">
<summary>
Measures the amount of layout jank (bit.ly/lsm-explainer) that has
Measures the cumulative layout shift (bit.ly/lsm-explainer) that has
occurred on the page (including all subframes) during the session. This
metric's integral value is 100x the fractional jank score described in the
explainer.
metric's integral value is 100x the fractional cumulative layout shift
score described in the explainer.
</summary>
</metric>
<metric name="LayoutInstability.CumulativeShiftScore.MainFrame">
<summary>
Measures the amount of layout jank (bit.ly/lsm-explainer) that has
Measures the cumulative layout shift (bit.ly/lsm-explainer) that has
occurred in the main frame during the session. This metric's integral
value is 100x the fractional jank score described in the explainer.
value is 100x the fractional cumulative layout shift score described in
the explainer.
</summary>
</metric>
<metric
name="LayoutInstability.CumulativeShiftScore.MainFrame.BeforeInputOrScroll">
<summary>
Measures the amount of layout jank (bit.ly/lsm-explainer) that has
Measures the cumulative layout shift (bit.ly/lsm-explainer) that has
occurred in the main frame during the session, before any user input or
document scroll. This metric's integral value is 100x the fractional jank
score described in the explainer.
document scroll. This metric's integral value is 100x the fractional
cumulative layout shift score described in the explainer.
</summary>
</metric>
<metric name="LayoutStability.JankScore">
......
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