Commit 14c585ae authored by Hailey Wang's avatar Hailey Wang Committed by Commit Bot

Add tracing event for long navigation to first contentful paint

A trace is uploaded via "slow reports" when a long navigation to first contentful paint is detected (for opted-in clients). This trace event will make it easier to identify the location of the long delay when analyzing the trace.

Bug: 1055890
Change-Id: I8e58ada28976fcea2bd2a799021e90ddd0231567
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2076279Reviewed-by: default avatarFrançois Doray <fdoray@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Commit-Queue: Hailey Wang <haileywang@google.com>
Cr-Commit-Position: refs/heads/master@{#745647}
parent 07139604
...@@ -20,6 +20,16 @@ ...@@ -20,6 +20,16 @@
#include "ui/events/blink/blink_features.h" #include "ui/events/blink/blink_features.h"
namespace { namespace {
// Used to generate a unique id when emitting the "Long Navigation to First
// Contentful Paint" trace event.
int g_num_trace_events_in_process = 0;
// The threshold to emit a trace event is the 99th percentile
// of the histogram on Windows Stable as of Feb 26th, 2020.
constexpr base::TimeDelta kFirstContentfulPaintTraceThreshold =
base::TimeDelta::FromMilliseconds(12388);
// TODO(bmcquade): If other observers want to log histograms based on load type, // TODO(bmcquade): If other observers want to log histograms based on load type,
// promote this enum to page_load_metrics_observer.h. // promote this enum to page_load_metrics_observer.h.
enum PageLoadType { enum PageLoadType {
...@@ -373,6 +383,23 @@ void CorePageLoadMetricsObserver::OnFirstContentfulPaintInPage( ...@@ -373,6 +383,23 @@ void CorePageLoadMetricsObserver::OnFirstContentfulPaintInPage(
PAGE_LOAD_HISTOGRAM(internal::kHistogramParseStartToFirstContentfulPaint, PAGE_LOAD_HISTOGRAM(internal::kHistogramParseStartToFirstContentfulPaint,
timing.paint_timing->first_contentful_paint.value() - timing.paint_timing->first_contentful_paint.value() -
timing.parse_timing->parse_start.value()); timing.parse_timing->parse_start.value());
// Emit a trace event to highlight a long navigation to first contentful
// paint.
if (timing.paint_timing->first_contentful_paint >
kFirstContentfulPaintTraceThreshold) {
base::TimeTicks navigation_start = GetDelegate().GetNavigationStart();
TRACE_EVENT_ASYNC_BEGIN_WITH_TIMESTAMP0(
"latency", "Long Navigation to First Contentful Paint",
TRACE_ID_LOCAL(g_num_trace_events_in_process), navigation_start);
TRACE_EVENT_ASYNC_END_WITH_TIMESTAMP0(
"latency", "Long Navigation to First Contentful Paint",
TRACE_ID_LOCAL(g_num_trace_events_in_process),
navigation_start +
timing.paint_timing->first_contentful_paint.value());
g_num_trace_events_in_process++;
}
UMA_HISTOGRAM_ENUMERATION( UMA_HISTOGRAM_ENUMERATION(
internal::kHistogramFirstContentfulPaintInitiatingProcess, internal::kHistogramFirstContentfulPaintInitiatingProcess,
GetDelegate().GetUserInitiatedInfo().browser_initiated GetDelegate().GetUserInitiatedInfo().browser_initiated
......
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