Commit 76dcf31e authored by Steve Kobes's avatar Steve Kobes Committed by Chromium LUCI CQ

Don't call RecordTimingMetrics in UKM observer's OnHidden.

Instead wait until OnComplete or app background to report these metrics,
to capture LCP reports that arrive after tab hide due to buffering
(go/plm-flushing).  The UMA observer already does this.

Bug: 1069023
Change-Id: Idfc061eb0b9e1694443b3468da927211e47110c4
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2575002
Commit-Queue: Steve Kobes <skobes@chromium.org>
Reviewed-by: default avatarNicolás Peña Moreno <npm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#836176}
parent 4d40bc76
...@@ -141,9 +141,7 @@ class UkmPageLoadMetricsObserver ...@@ -141,9 +141,7 @@ class UkmPageLoadMetricsObserver
void RecordRendererUsageMetrics(); void RecordRendererUsageMetrics();
// Adds main resource timing metrics to |builder|. // Adds main resource timing metrics to |builder|.
void ReportMainResourceTimingMetrics( void ReportMainResourceTimingMetrics(ukm::builders::PageLoad& builder);
const page_load_metrics::mojom::PageLoadTiming& timing,
ukm::builders::PageLoad* builder);
void ReportLayoutStability(); void ReportLayoutStability();
...@@ -185,6 +183,10 @@ class UkmPageLoadMetricsObserver ...@@ -185,6 +183,10 @@ class UkmPageLoadMetricsObserver
const page_load_metrics::mojom::PageLoadTiming* timing, const page_load_metrics::mojom::PageLoadTiming* timing,
base::TimeTicks page_end_time); base::TimeTicks page_end_time);
// Records a score from the SiteEngagementService. Called when the page
// becomes hidden, or at the end of the session if the page is never hidden.
void RecordSiteEngagement() const;
// Guaranteed to be non-null during the lifetime of |this|. // Guaranteed to be non-null during the lifetime of |this|.
network::NetworkQualityTracker* network_quality_tracker_; network::NetworkQualityTracker* network_quality_tracker_;
......
...@@ -1839,6 +1839,34 @@ TEST_F(UkmPageLoadMetricsObserverTest, FCPHiddenWhileFlushing) { ...@@ -1839,6 +1839,34 @@ TEST_F(UkmPageLoadMetricsObserverTest, FCPHiddenWhileFlushing) {
} }
} }
TEST_F(UkmPageLoadMetricsObserverTest, LCPHiddenWhileFlushing) {
NavigateAndCommit(GURL(kTestUrl1));
// Simulate hiding the tab.
web_contents()->WasHidden();
base::TimeDelta background_time =
*tester()->GetDelegateForCommittedLoad().GetFirstBackgroundTime();
page_load_metrics::mojom::PageLoadTiming timing;
page_load_metrics::InitPageLoadTimingForTest(&timing);
timing.navigation_start = base::Time::FromDoubleT(1);
timing.paint_timing->largest_contentful_paint->largest_image_paint =
background_time;
timing.paint_timing->largest_contentful_paint->largest_image_paint_size = 50u;
PopulateExperimentalLCP(timing.paint_timing);
PopulateRequiredTimingFields(&timing);
// Simulate LCP at the same time as the hide (but reported after).
tester()->SimulateTimingUpdate(timing);
// Simulate closing the tab.
DeleteContents();
// Check that we reported the LCP UKM.
TestLCP(background_time.InMilliseconds(), LargestContentType::kImage,
true /* test_main_frame */);
}
class TestOfflinePreviewsUkmPageLoadMetricsObserver class TestOfflinePreviewsUkmPageLoadMetricsObserver
: public UkmPageLoadMetricsObserver { : public UkmPageLoadMetricsObserver {
public: public:
......
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