Skip to content

Commit

Permalink
Add more Blink.VisibleLoadTime.LazyLoadImages metrics
Browse files Browse the repository at this point in the history
This patch adds the following new metrics:
  Blink.VisibleLoadTime.LazyLoadImages
  Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3
  Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.{2G, ...and 5 more}
  Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3
  Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.{2G, ...and 5 more}

There are four changes in this patch:
1) Added a base metric for all Blink.VisibleLoadTime.LazyLoadImages.
2) Added base metrics for AboveTheFold3 and BelowTheFold3.
3) Added Unknown and Offline connection type suffixes for completeness.
4) Updated metrics names to "3". These new metrics replace the existing:
  Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2.{2G, ...and 3 more}
  Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2.{2G, ...and 3 more}

DelayOutOfViewportLazyImages is an experiment that impacts above- and
below-fold lazy loaded images differently. The new base metrics will
show the overall impact of this experiment aggregated over above- and
below- fold variants (1), as well as aggregated over all connection
types (2). This is needed demonstrate the tradeoff between above-fold
progressions vs below-fold regressions.

Loading images with offline/unknown connections is rare. Recording data
for these connection types (3) just ensures the base metrics add up.

OBSOLETE_HISTOGRAM[Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2{BlinkVisibleLoadTimeSuffixes}]=Replaced by AboveTheFold3
OBSOLETE_HISTOGRAM[Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2{BlinkVisibleLoadTimeSuffixes}]=Replaced by BelowTheFold3

Bug: 1394025
Change-Id: Ifb060c701d499ee23df8085b34b6646bb8f222f1
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4544051
Reviewed-by: Ian Clelland <iclelland@chromium.org>
Reviewed-by: Stefan Zager <szager@chromium.org>
Commit-Queue: Philip Rogers <pdr@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1146950}
  • Loading branch information
progers authored and Chromium LUCI CQ committed May 21, 2023
1 parent 6804e80 commit ed33d7a
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 36 deletions.
56 changes: 45 additions & 11 deletions third_party/blink/renderer/core/html/lazy_load_image_observer.cc
Expand Up @@ -86,60 +86,94 @@ void RecordVisibleLoadTimeForImage(
if (visible_load_delay.is_negative())
visible_load_delay = base::TimeDelta();

UMA_HISTOGRAM_MEDIUM_TIMES("Blink.VisibleLoadTime.LazyLoadImages",
visible_load_delay);

if (visible_load_time_metrics.is_initially_intersecting) {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3",
visible_load_delay);
} else {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3",
visible_load_delay);
}

switch (GetNetworkStateNotifier().EffectiveType()) {
case WebEffectiveConnectionType::kTypeSlow2G:
if (visible_load_time_metrics.is_initially_intersecting) {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2.Slow2G",
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.Slow2G",
visible_load_delay);
} else {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2.Slow2G",
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.Slow2G",
visible_load_delay);
}
break;

case WebEffectiveConnectionType::kType2G:
if (visible_load_time_metrics.is_initially_intersecting) {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2.2G",
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.2G",
visible_load_delay);
} else {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2.2G",
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.2G",
visible_load_delay);
}
break;

case WebEffectiveConnectionType::kType3G:
if (visible_load_time_metrics.is_initially_intersecting) {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2.3G",
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.3G",
visible_load_delay);
} else {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2.3G",
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.3G",
visible_load_delay);
}
break;

case WebEffectiveConnectionType::kType4G:
if (visible_load_time_metrics.is_initially_intersecting) {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2.4G",
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.4G",
visible_load_delay);
} else {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2.4G",
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.4G",
visible_load_delay);
}
break;

case WebEffectiveConnectionType::kTypeUnknown:
case WebEffectiveConnectionType::kTypeOffline:
// No VisibleLoadTime histograms are recorded for these effective
// connection types.
if (visible_load_time_metrics.is_initially_intersecting) {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.Offline",
visible_load_delay);
} else {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.Offline",
visible_load_delay);
}
break;

case WebEffectiveConnectionType::kTypeUnknown:
if (visible_load_time_metrics.is_initially_intersecting) {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.Unknown",
visible_load_delay);
} else {
UMA_HISTOGRAM_MEDIUM_TIMES(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.Unknown",
visible_load_delay);
}
break;

default:
NOTREACHED();
}
}

Expand Down
Expand Up @@ -670,7 +670,7 @@ TEST_F(LazyLoadImagesTest, AboveTheFoldImageLoadedBeforeVisible) {
// VisibleLoadTime should not have been recorded yet, since the image is not
// visible yet.
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2.4G", 0);
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.4G", 0);

Compositor().BeginFrame();
test::RunPendingTasks();
Expand All @@ -680,9 +680,15 @@ TEST_F(LazyLoadImagesTest, AboveTheFoldImageLoadedBeforeVisible) {
histogram_tester.ExpectTotalCount(
"Blink.VisibleBeforeLoaded.LazyLoadImages.BelowTheFold2", 0);
histogram_tester.ExpectUniqueSample(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2.4G", 0, 1);
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.4G", 0, 1);
histogram_tester.ExpectUniqueSample("Blink.VisibleLoadTime.LazyLoadImages", 0,
1);
histogram_tester.ExpectUniqueSample(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3", 0, 1);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.4G", 0);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2.4G", 0);
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3", 0);
}

// A fully above-the-fold cached image should not report below-the-fold metrics.
Expand Down Expand Up @@ -733,7 +739,7 @@ TEST_F(LazyLoadImagesTest, AboveTheFoldCachedImageMetrics) {
histogram_tester.ExpectTotalCount(
"Blink.VisibleBeforeLoaded.LazyLoadImages.BelowTheFold2", 0);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2.4G", 0);
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.4G", 0);
}

// An image that loads immediately due to being cached should not report
Expand Down Expand Up @@ -811,7 +817,7 @@ TEST_F(LazyLoadImagesTest, AboveTheFoldImageVisibleBeforeLoaded) {
// VisibleLoadTime should not have been recorded yet, since the image is not
// finished loading yet.
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2.4G", 0);
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.4G", 0);

image_resource.Complete(TestImage());

Expand All @@ -823,10 +829,15 @@ TEST_F(LazyLoadImagesTest, AboveTheFoldImageVisibleBeforeLoaded) {
static_cast<int>(WebEffectiveConnectionType::kType4G), 1);
histogram_tester.ExpectTotalCount(
"Blink.VisibleBeforeLoaded.LazyLoadImages.BelowTheFold2", 0);
histogram_tester.ExpectTotalCount("Blink.VisibleLoadTime.LazyLoadImages", 1);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3", 1);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3", 0);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2.4G", 1);
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.4G", 1);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2.4G", 0);
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.4G", 0);
}

TEST_F(LazyLoadImagesTest, BelowTheFoldImageLoadedBeforeVisible) {
Expand Down Expand Up @@ -864,7 +875,7 @@ TEST_F(LazyLoadImagesTest, BelowTheFoldImageLoadedBeforeVisible) {
// VisibleLoadTime should not have been recorded yet, since the image is not
// visible yet.
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2.4G", 0);
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.4G", 0);

// Scroll down such that the image is visible.
GetDocument().View()->LayoutViewport()->SetScrollOffset(
Expand All @@ -878,10 +889,16 @@ TEST_F(LazyLoadImagesTest, BelowTheFoldImageLoadedBeforeVisible) {
"Blink.VisibleBeforeLoaded.LazyLoadImages.AboveTheFold2", 0);
histogram_tester.ExpectTotalCount(
"Blink.VisibleBeforeLoaded.LazyLoadImages.BelowTheFold2", 0);
histogram_tester.ExpectUniqueSample("Blink.VisibleLoadTime.LazyLoadImages", 0,
1);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2.4G", 0);
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3", 0);
histogram_tester.ExpectUniqueSample(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2.4G", 0, 1);
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3", 0, 1);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.4G", 0);
histogram_tester.ExpectUniqueSample(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.4G", 0, 1);
}

TEST_F(LazyLoadImagesTest, BelowTheFoldImageVisibleBeforeLoaded) {
Expand Down Expand Up @@ -920,7 +937,7 @@ TEST_F(LazyLoadImagesTest, BelowTheFoldImageVisibleBeforeLoaded) {
// VisibleLoadTime should not have been recorded yet, since the image is not
// finished loading yet.
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2.4G", 0);
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.4G", 0);

image_resource.Complete(TestImage());

Expand All @@ -932,10 +949,15 @@ TEST_F(LazyLoadImagesTest, BelowTheFoldImageVisibleBeforeLoaded) {
histogram_tester.ExpectUniqueSample(
"Blink.VisibleBeforeLoaded.LazyLoadImages.BelowTheFold2",
static_cast<int>(WebEffectiveConnectionType::kType4G), 1);
histogram_tester.ExpectTotalCount("Blink.VisibleLoadTime.LazyLoadImages", 1);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3", 0);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3", 1);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2.4G", 0);
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.4G", 0);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2.4G", 1);
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.4G", 1);
}

// LazyLoadImages metrics should not be recorded for non-lazy image loads.
Expand Down Expand Up @@ -963,9 +985,9 @@ TEST_F(LazyLoadImagesTest, NonLazyIgnoredForLazyLoadImagesMetrics) {
histogram_tester.ExpectTotalCount(
"Blink.VisibleBeforeLoaded.LazyLoadImages.BelowTheFold2", 0);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2.4G", 0);
"Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3.4G", 0);
histogram_tester.ExpectTotalCount(
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2.4G", 0);
"Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3.4G", 0);
}

// Allow lazy loading of file:/// urls.
Expand Down
36 changes: 26 additions & 10 deletions tools/metrics/histograms/metadata/blink/histograms.xml
Expand Up @@ -33,7 +33,9 @@ chromium-metrics-reviews@google.com.
<variant name=".2G" summary="2G effective connection type"/>
<variant name=".3G" summary="3G effective connection type"/>
<variant name=".4G" summary="4G effective connection type"/>
<variant name=".Offline" summary="Offline effective connection type"/>
<variant name=".Slow2G" summary="Slow-2G effective connection type"/>
<variant name=".Unknown" summary="Unknown effective connection type"/>
</variants>

<variants name="ResourceCacheLifecycleState">
Expand Down Expand Up @@ -3619,31 +3621,45 @@ chromium-metrics-reviews@google.com.
</summary>
</histogram>

<histogram name="Blink.VisibleLoadTime.LazyLoadImages" units="ms"
expires_after="2023-09-01">
<owner>pdr@chromium.org</owner>
<owner>paint-dev@chromium.org</owner>
<summary>
Milliseconds spent waiting for a lazily loaded image to load. 0ms is
recorded if the image is already loaded by the time it is visible.

See also the AboveTheFold3 and BelowTheFold3 versions of this metric.
</summary>
</histogram>

<histogram
name="Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold2{BlinkVisibleLoadTimeSuffixes}"
name="Blink.VisibleLoadTime.LazyLoadImages.AboveTheFold3{BlinkVisibleLoadTimeSuffixes}"
units="ms" expires_after="2023-09-01">
<owner>pdr@chromium.org</owner>
<owner>paint-dev@chromium.org</owner>
<summary>
Milliseconds spent waiting for an above-the-fold lazily loaded image to
load. 0ms is recorded if the image is already loaded by the time user
scrolls to it. EffectiveConnectionType (2G, 3G, etc) is recorded as suffix
to this histogram. {BlinkVisibleLoadTimeSuffixes}
Milliseconds spent waiting for an initially above-the-fold lazily loaded
image to load. 0ms is recorded if the image is already loaded by the time it
is visible. EffectiveConnectionType (2G, 3G, etc) is recorded as suffix to
this histogram. View the base histogram to see results aggregated across all
connection types. {BlinkVisibleLoadTimeSuffixes}
</summary>
<token key="BlinkVisibleLoadTimeSuffixes"
variants="BlinkVisibleLoadTimeSuffixes"/>
</histogram>

<histogram
name="Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold2{BlinkVisibleLoadTimeSuffixes}"
name="Blink.VisibleLoadTime.LazyLoadImages.BelowTheFold3{BlinkVisibleLoadTimeSuffixes}"
units="ms" expires_after="2023-09-01">
<owner>pdr@chromium.org</owner>
<owner>paint-dev@chromium.org</owner>
<summary>
Milliseconds spent waiting for a below-the-fold lazily loaded image to load.
0ms is recorded if the image is already loaded by the time user scrolls to
it. EffectiveConnectionType (2G, 3G, etc) is recorded as suffix to this
histogram. {BlinkVisibleLoadTimeSuffixes}
Milliseconds spent waiting for an initially below-the-fold lazily loaded
image to load. 0ms is recorded if the image is already loaded by the it is
visible. EffectiveConnectionType (2G, 3G, etc) is recorded as suffix to this
histogram. View the base histogram to see results aggregated across all
connection types. {BlinkVisibleLoadTimeSuffixes}
</summary>
<token key="BlinkVisibleLoadTimeSuffixes"
variants="BlinkVisibleLoadTimeSuffixes"/>
Expand Down

0 comments on commit ed33d7a

Please sign in to comment.