From f84fd4c25526a1ce27d1af050c924a130afeb968 Mon Sep 17 00:00:00 2001 From: Bas Schouten Date: Mon, 6 Nov 2023 20:32:44 +0000 Subject: [PATCH] Bug 1862939 - Part 2: Add LCP information to the Pageload Event. r=dpalmeiro Differential Revision: https://phabricator.services.mozilla.com/D192695 --- dom/base/Document.cpp | 8 ++++++++ dom/ipc/PageLoadEventUtils.h | 2 ++ dom/metrics.yaml | 7 +++++++ 3 files changed, 17 insertions(+) diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index e17d0f6d0e41..81b578d58743 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -2174,6 +2174,14 @@ void Document::AccumulatePageLoadTelemetry( } } + // Report the most up to date LCP time. For our histogram we actually report + // this on page unload. + if (TimeStamp lcpTime = + GetNavigationTiming()->GetLargestContentfulRenderTimeStamp()) { + aEventTelemetryDataOut.lcpTime = mozilla::Some( + static_cast((lcpTime - navigationStart).ToMilliseconds())); + } + // DOM Content Loaded event if (TimeStamp dclEventStart = GetNavigationTiming()->GetDOMContentLoadedEventStartTimeStamp()) { diff --git a/dom/ipc/PageLoadEventUtils.h b/dom/ipc/PageLoadEventUtils.h index 6a49e4b66036..243386ca6c52 100644 --- a/dom/ipc/PageLoadEventUtils.h +++ b/dom/ipc/PageLoadEventUtils.h @@ -18,6 +18,7 @@ struct ParamTraits { static void Write(MessageWriter* aWriter, const paramType& aParam) { WriteParam(aWriter, aParam.fcpTime); + WriteParam(aWriter, aParam.lcpTime); WriteParam(aWriter, aParam.jsExecTime); WriteParam(aWriter, aParam.loadTime); WriteParam(aWriter, aParam.loadType); @@ -32,6 +33,7 @@ struct ParamTraits { static bool Read(MessageReader* aReader, paramType* aResult) { return ReadParam(aReader, &aResult->fcpTime) && + ReadParam(aReader, &aResult->lcpTime) && ReadParam(aReader, &aResult->jsExecTime) && ReadParam(aReader, &aResult->loadTime) && ReadParam(aReader, &aResult->loadType) && diff --git a/dom/metrics.yaml b/dom/metrics.yaml index 0bbd56aa8cf5..8a3ab9469a44 100644 --- a/dom/metrics.yaml +++ b/dom/metrics.yaml @@ -19,10 +19,12 @@ perf: - https://bugzilla.mozilla.org/show_bug.cgi?id=1759744 - https://bugzilla.mozilla.org/show_bug.cgi?id=1799727 - https://bugzilla.mozilla.org/show_bug.cgi?id=1834774 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1862939 data_reviews: - https://bugzilla.mozilla.org/show_bug.cgi?id=1759744#c5 - https://bugzilla.mozilla.org/show_bug.cgi?id=1799727#c4 - https://bugzilla.mozilla.org/show_bug.cgi?id=1834774#c3 + - https://bugzilla.mozilla.org/show_bug.cgi?id=1862939#c5 notification_emails: - perf-telemetry-alerts@mozilla.com - dpalmeiro@mozilla.com @@ -48,6 +50,11 @@ perf: "Time between firstContentfulPaint and navigationStart, in ms." type: quantity unit: ms + lcp_time: + description: + "Time between largestContentfulPaint and navigationStart, at the point of onLoad firing, in ms. This may differ from the final LCP value as reported through the LCP histogram." + type: quantity + unit: ms js_exec_time: description: "Time spent executing JS during page load, in ms."