Commit 636e47da authored by Nicolás Peña Moreno's avatar Nicolás Peña Moreno Committed by Chromium LUCI CQ

[Abandonment] Flush metrics on FCP

This CL adds a method that gets called when a frame reaches FCP. This
allows us to aggressively flush the metrics from the renderer process
to the browser process, which in turn means that our abandonment rates
would be more accurate as a result, since the abandonment metric relies
on whether FCP has been reached.

Bug: 1048691
Change-Id: I7d0a4e2886a41f5eb007c0eed3b19e59df4917f7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2642993Reviewed-by: default avatarSteve Kobes <skobes@chromium.org>
Commit-Queue: Nicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#846376}
parent 06c54669
......@@ -280,9 +280,22 @@ void PageTimingMetricsSender::Update(
return;
}
// We want to force sending the metrics immediately when FCP is reached
// instead of using a timer. SendLatest() will force sending now since we
// already called EnsureSendTimer().
bool force_send_metrics =
(!last_timing_->paint_timing ||
!last_timing_->paint_timing->first_contentful_paint.has_value()) &&
timing->paint_timing &&
timing->paint_timing->first_contentful_paint.has_value();
last_timing_ = std::move(timing);
metadata_recorder_.UpdateMetadata(monotonic_timing);
EnsureSendTimer();
if (force_send_metrics) {
SendLatest();
}
}
void PageTimingMetricsSender::SendLatest() {
......
......@@ -448,4 +448,16 @@ TEST_F(PageTimingMetricsSenderTest, SendFrameIntersectionUpdate) {
validator_.VerifyExpectedFrameIntersectionUpdate();
}
TEST_F(PageTimingMetricsSenderTest, FirstContentfulPaintForcesSend) {
mojom::PageLoadTiming timing;
InitPageLoadTimingForTest(&timing);
timing.paint_timing->first_contentful_paint = base::TimeDelta::FromSeconds(1);
validator_.ExpectPageLoadTiming(timing);
// Updating when |timing| has FCP will cause the metrics to be sent right
// away.
metrics_sender_->Update(timing.Clone(),
PageTimingMetadataRecorder::MonotonicTiming());
EXPECT_FALSE(metrics_sender_->mock_timer()->IsRunning());
}
} // namespace page_load_metrics
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