Skip to content

Commit 3cb6d2a

Browse files
Nafis AbedinChromium LUCI CQ
authored andcommitted
[Startup] Remove V1 Metric; Update TimeToVisibleContent
TimeToVisibleContent is still relevant for low-end devices, but it loses samples with native being loaded faster/earlier so update it to use TimeToFirstContentfulPaint3 as a sub-metric which uses ColdStartTracker to determine cold starts instead. OBSOLETE_HISTOGRAM[Startup.Android.Cold.TimeToFirstVisibleContent]= The original TimeToFirstVisibleContent metric has been superseded by newer iterations so deprecate it. Bug: 452618727 Change-Id: I1f0f64aa0299ec3c2c5c65696133d0f33821cb33 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/7055842 Commit-Queue: Nafis Abedin <[email protected]> Reviewed-by: Calder Kitagawa <[email protected]> Reviewed-by: Francois Pierre Doray <[email protected]> Reviewed-by: Egor Pasko <[email protected]> Cr-Commit-Position: refs/heads/main@{#1532386}
1 parent a419da7 commit 3cb6d2a

File tree

4 files changed

+49
-56
lines changed

4 files changed

+49
-56
lines changed

chrome/android/java/src/org/chromium/chrome/browser/metrics/LegacyTabStartupMetricsTracker.java

Lines changed: 1 addition & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,6 @@ public void onFirstContentfulPaint(
7373
private @Nullable TabModelSelectorTabObserver mTabModelSelectorTabObserver;
7474
private @Nullable PageLoadMetricsObserverImpl mPageLoadMetricsObserver;
7575
private boolean mShouldTrackStartupMetrics;
76-
private boolean mFirstVisibleContentRecorded;
7776
private boolean mFirstVisibleContent2Recorded;
7877
private boolean mVisibleContentRecorded;
7978
private boolean mBackPressOccurred;
@@ -163,7 +162,6 @@ public void registerPaintPreviewObserver(StartupPaintPreviewHelper startupPaintP
163162
public void onFirstPaint(long durationMs) {
164163
RecordHistogram.recordBooleanHistogram(
165164
FIRST_PAINT_OCCURRED_PRE_FOREGROUND_HISTOGRAM, false);
166-
recordFirstVisibleContent(durationMs);
167165
recordFirstVisibleContent2(durationMs);
168166
recordVisibleContent(durationMs);
169167
}
@@ -241,9 +239,6 @@ private void registerFinishNavigation(boolean isTrackedPage) {
241239
"Startup.Android.Cold.TimeToFirstNavigationCommit"
242240
+ activityTypeToSuffix(mHistogramSuffix),
243241
mFirstCommitTimeMs);
244-
if (mHistogramSuffix == ActivityType.TABBED) {
245-
recordFirstVisibleContent(mFirstCommitTimeMs);
246-
}
247242
}
248243

249244
if (mHistogramSuffix == ActivityType.TABBED
@@ -289,30 +284,10 @@ private void recordFirstContentfulPaint(long firstContentfulPaintMs) {
289284
clearNavigationObservers();
290285
}
291286

292-
/**
293-
* Records the legacy version of the time to first visible content.
294-
*
295-
* This metric acts as the Clank cold start guardian metric.
296-
*
297-
* Reports the minimum value of Startup.Android.Cold.TimeToFirstNavigationCommit.Tabbed and
298-
* Browser.PaintPreview.TabbedPlayer.TimeToFirstBitmap.
299-
*
300-
* @param durationMs duration in millis.
301-
*/
302-
private void recordFirstVisibleContent(long durationMs) {
303-
if (mFirstVisibleContentRecorded) return;
304-
305-
mFirstVisibleContentRecorded = true;
306-
RecordHistogram.deprecatedRecordMediumTimesHistogram(
307-
"Startup.Android.Cold.TimeToFirstVisibleContent", durationMs);
308-
}
309-
310287
/**
311288
* Records the time to first visible content.
312289
*
313-
* This metric aims to become the new the Clank cold start guardian metric.
314-
*
315-
* Reports the minimum value of Startup.Android.Cold.TimeToFirstNavigationCommit2.Tabbed and
290+
* <p>Reports the minimum value of Startup.Android.Cold.TimeToFirstNavigationCommit2.Tabbed and
316291
* Browser.PaintPreview.TabbedPlayer.TimeToFirstBitmap.
317292
*
318293
* @param durationMs duration in millis.

chrome/android/java/src/org/chromium/chrome/browser/metrics/StartupMetricsTracker.java

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ public class StartupMetricsTracker {
4242
private static final long TIME_TO_DRAW_METRIC_RECORDING_DELAY_MS = 2500;
4343
private static final String NTP_COLD_START_HISTOGRAM =
4444
"Startup.Android.Cold.NewTabPage.TimeToFirstDraw";
45+
private static final String TIME_TO_STARTUP_FCP_OR_PAINT_PREVIEW_HISTOGRAM =
46+
"Startup.Android.Cold.TimeToStartupFcpOrPaintPreview";
4547
private boolean mFirstNavigationCommitted;
4648

4749
private class TabObserver extends TabModelSelectorTabObserver {
@@ -130,6 +132,7 @@ private void recordFcpMetricsIfNeeded(
130132
// reported in uptimeMillis relative to this value.
131133
private final long mActivityStartTimeMs;
132134
private boolean mFirstVisibleContentRecorded;
135+
private boolean mTimeToStartupFcpOrPaintPreviewRecorded;
133136

134137
private @Nullable TabModelSelectorTabObserver mTabObserver;
135138
private @Nullable PageObserver mPageObserver;
@@ -185,6 +188,7 @@ public void registerPaintPreviewObserver(StartupPaintPreviewHelper startupPaintP
185188
@Override
186189
public void onFirstPaint(long durationMs) {
187190
recordTimeToFirstVisibleContent(durationMs);
191+
recordTimeToStartupFcpOrPaintPreview(durationMs);
188192
}
189193

190194
@Override
@@ -295,6 +299,7 @@ private void recordFcpMetrics(long firstFcpMs) {
295299
recordExperimentalHistogram("FirstContentfulPaint", firstFcpMs);
296300
RecordHistogram.deprecatedRecordMediumTimesHistogram(
297301
"Startup.Android.Cold.TimeToFirstContentfulPaint3.Tabbed", firstFcpMs);
302+
recordTimeToStartupFcpOrPaintPreview(firstFcpMs);
298303
}
299304
}
300305

@@ -332,4 +337,21 @@ private void recordTimeToFirstDraw(String histogramName, long timeToFirstDrawMs)
332337
|| !ColdStartTracker.wasColdOnFirstActivityCreationOrNow()) return;
333338
RecordHistogram.recordMediumTimesHistogram(histogramName, timeToFirstDrawMs);
334339
}
340+
341+
/**
342+
* Records a histogram capturing TimeToStartupFcpOrPaintPreview.
343+
*
344+
* <p>This metric reports the minimum value of
345+
* Startup.Android.Cold.TimeToFirstContentfulPaint3.Tabbed and
346+
* Browser.PaintPreview.TabbedPlayer.TimeToFirstBitmap.
347+
*
348+
* @param durationMs duration in millis.
349+
*/
350+
private void recordTimeToStartupFcpOrPaintPreview(long durationMs) {
351+
if (mTimeToStartupFcpOrPaintPreviewRecorded) return;
352+
353+
mTimeToStartupFcpOrPaintPreviewRecorded = true;
354+
RecordHistogram.recordMediumTimesHistogram(
355+
TIME_TO_STARTUP_FCP_OR_PAINT_PREVIEW_HISTOGRAM, durationMs);
356+
}
335357
}

chrome/android/javatests/src/org/chromium/chrome/browser/metrics/StartupLoadingMetricsTest.java

Lines changed: 6 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,14 @@ public class StartupLoadingMetricsTest {
6767
"Startup.Android.Cold.TimeToFirstContentfulPaint";
6868
private static final String FIRST_CONTENTFUL_PAINT_HISTOGRAM3 =
6969
"Startup.Android.Cold.TimeToFirstContentfulPaint3";
70-
private static final String FIRST_VISIBLE_CONTENT_HISTOGRAM =
71-
"Startup.Android.Cold.TimeToFirstVisibleContent";
7270
private static final String FIRST_VISIBLE_CONTENT_HISTOGRAM2 =
7371
"Startup.Android.Cold.TimeToFirstVisibleContent2";
7472
private static final String FIRST_VISIBLE_CONTENT_COLD_HISTOGRAM4 =
7573
"Startup.Android.Cold.TimeToFirstVisibleContent4";
7674
private static final String VISIBLE_CONTENT_HISTOGRAM =
7775
"Startup.Android.Cold.TimeToVisibleContent";
76+
private static final String TIME_TO_STARTUP_FCP_OR_PAINT_PREVIEW_HISTOGRAM =
77+
"Startup.Android.Cold.TimeToStartupFcpOrPaintPreview";
7878
private static final String FIRST_COMMIT_COLD_HISTOGRAM3 =
7979
"Startup.Android.Cold.TimeToFirstNavigationCommit3";
8080
private static final String MAIN_INTENT_COLD_START_HISTOGRAM =
@@ -209,7 +209,11 @@ private void assertHistogramsRecordedAsExpected(int expectedCount, String histog
209209

210210
int visibleContentSamples =
211211
RecordHistogram.getHistogramTotalCountForTesting(VISIBLE_CONTENT_HISTOGRAM);
212+
int timeToStartupFcpOrPaintPreviewSamples =
213+
RecordHistogram.getHistogramTotalCountForTesting(
214+
TIME_TO_STARTUP_FCP_OR_PAINT_PREVIEW_HISTOGRAM);
212215
Assert.assertTrue(visibleContentSamples < 2);
216+
Assert.assertTrue(timeToStartupFcpOrPaintPreviewSamples < 2);
213217

214218
if (expectedCount == 1 && firstCommitSamples == 0) {
215219
// The startup FCP and 'visible content' also record their samples depending on how fast
@@ -229,10 +233,6 @@ private void assertHistogramsRecordedAsExpected(int expectedCount, String histog
229233
if (isTabbedSuffix) {
230234
// These tests only exercise the cases when the first visible content is calculated as
231235
// the first navigation commit.
232-
Assert.assertEquals(
233-
firstCommitSamples,
234-
RecordHistogram.getHistogramTotalCountForTesting(
235-
FIRST_VISIBLE_CONTENT_HISTOGRAM));
236236
Assert.assertEquals(
237237
expectedCount,
238238
RecordHistogram.getHistogramTotalCountForTesting(
@@ -537,9 +537,6 @@ public void testRecordingOfFirstNavigationCommitPreForeground() throws Exception
537537
0,
538538
RecordHistogram.getHistogramTotalCountForTesting(
539539
FIRST_COMMIT_HISTOGRAM + TABBED_SUFFIX));
540-
Assert.assertEquals(
541-
0,
542-
RecordHistogram.getHistogramTotalCountForTesting(FIRST_VISIBLE_CONTENT_HISTOGRAM));
543540
assertMainIntentLaunchColdStartHistogramRecorded(0);
544541

545542
// The metric based on early foreground notification should be recorded.
@@ -565,9 +562,6 @@ public void testRecordingOfFirstNavigationCommitPreForeground() throws Exception
565562
0,
566563
RecordHistogram.getHistogramTotalCountForTesting(
567564
FIRST_COMMIT_HISTOGRAM + TABBED_SUFFIX));
568-
Assert.assertEquals(
569-
0,
570-
RecordHistogram.getHistogramTotalCountForTesting(FIRST_VISIBLE_CONTENT_HISTOGRAM));
571565
}
572566

573567
@Test

tools/metrics/histograms/metadata/startup/histograms.xml

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -245,24 +245,6 @@ [email protected].
245245
</summary>
246246
</histogram>
247247

248-
<histogram name="Startup.Android.Cold.TimeToFirstVisibleContent" units="ms"
249-
expires_after="2026-03-08">
250-
<owner>[email protected]</owner>
251-
<owner>[email protected]</owner>
252-
<owner>[email protected]</owner>
253-
<improvement direction="LOWER_IS_BETTER"/>
254-
<summary>
255-
This histogram (the v1) will soon stop being recorded. It was replaced by
256-
the v2 (Startup.Android.Cold.TimeToFirstVisibleContent2), which was then
257-
superceded by the v4 (Startup.Android.Cold.TimeToFirstVisibleContent4).
258-
259-
Bug fixed by the v2:
260-
261-
- The v2 metric does not get recorded when the first navigation commit
262-
happens before post-native initialization. See crbug.com/1273097.
263-
</summary>
264-
</histogram>
265-
266248
<histogram name="Startup.Android.Cold.TimeToFirstVisibleContent2" units="ms"
267249
expires_after="2026-03-08">
268250
<owner>[email protected]</owner>
@@ -359,6 +341,26 @@ [email protected].
359341
</summary>
360342
</histogram>
361343

344+
<histogram name="Startup.Android.Cold.TimeToStartupFcpOrPaintPreview"
345+
units="ms" expires_after="2026-04-22">
346+
<owner>[email protected]</owner>
347+
<owner>[email protected]</owner>
348+
<improvement direction="LOWER_IS_BETTER"/>
349+
<summary>
350+
Android: The time from the activity creation point to the moment the content
351+
may first appear ready to a user. The intent is to capture readiness of
352+
Chrome regardless of whether Chrome is launched into native UI or a web
353+
page. The recorded value is the minimum of
354+
'Startup.Android.Cold.TimeToFirstContentfulPaint3.Tabbed'
355+
'Browser.PaintPreview.TabbedPlayer.TimeToFirstBitmap' metric values.
356+
357+
This metric is only recorded once per application lifetime, and only for
358+
cold starts. TimeToFirstContentfulPaint3.Tabbed utilizes ColdStartTracker
359+
which is only reliable starting with Android P as ProcessCreationReason is
360+
used to determine cold starts.
361+
</summary>
362+
</histogram>
363+
362364
<histogram name="Startup.Android.Cold.TimeToVisibleContent" units="ms"
363365
expires_after="2026-03-22">
364366
<owner>[email protected]</owner>

0 commit comments

Comments
 (0)