Commit 99cb63f5 authored by ckitagawa's avatar ckitagawa Committed by Commit Bot

[Paint Preview] Remove more outliers on TimeToFirstBitmap

Making a change to the TimeToFirstBitmap to more closely align with
registerFinishNavigation() which should hopefully eliminate some
outliers.

Change-Id: Iddd8ad2b62d8b5344040e130e62910840458c873
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2416669Reviewed-by: default avatarMehran Mahmoudi <mahmoudi@chromium.org>
Commit-Queue: Mehran Mahmoudi <mahmoudi@chromium.org>
Commit-Queue: Calder Kitagawa <ckitagawa@chromium.org>
Cr-Commit-Position: refs/heads/master@{#807977}
parent 2b79fc40
...@@ -94,7 +94,9 @@ public class PaintPreviewHelper { ...@@ -94,7 +94,9 @@ public class PaintPreviewHelper {
if (!player.maybeShow(onShown, () -> { if (!player.maybeShow(onShown, () -> {
onDismissed.run(); onDismissed.run();
PageLoadMetrics.removeObserver(observer); PageLoadMetrics.removeObserver(observer);
}, sActivityCreationTimeMs, UmaUtils::hasComeToBackground)) { }, sActivityCreationTimeMs, () -> {
return UmaUtils.hasComeToForeground() && !UmaUtils.hasComeToBackground();
})) {
return false; return false;
} }
......
...@@ -58,11 +58,11 @@ public class TabbedPaintPreviewMetricsHelper { ...@@ -58,11 +58,11 @@ public class TabbedPaintPreviewMetricsHelper {
mShownTime = System.currentTimeMillis(); mShownTime = System.currentTimeMillis();
} }
void onFirstPaint(long activityOnCreateTimestamp, Callable<Boolean> wasBackgrounded) { void onFirstPaint(long activityOnCreateTimestamp, Callable<Boolean> recordFirstPaint) {
mFirstPaintHappened = true; mFirstPaintHappened = true;
boolean shouldRecordHistogram = false; boolean shouldRecordHistogram = false;
try { try {
shouldRecordHistogram = !wasBackgrounded.call(); shouldRecordHistogram = recordFirstPaint.call();
} catch (Exception e) { } catch (Exception e) {
// no-op just proceed. // no-op just proceed.
} }
......
...@@ -140,13 +140,13 @@ public class TabbedPaintPreviewPlayer implements TabViewProvider, UserData { ...@@ -140,13 +140,13 @@ public class TabbedPaintPreviewPlayer implements TabViewProvider, UserData {
* @param onShown The callback for when the Paint Preview is shown. * @param onShown The callback for when the Paint Preview is shown.
* @param onDismissed The callback for when the Paint Preview is dismissed. * @param onDismissed The callback for when the Paint Preview is dismissed.
* @param activityCreationTimestampMs The hosting activity's creation time in ms from * @param activityCreationTimestampMs The hosting activity's creation time in ms from
* @param wasBackgrounded Callable to determine if the activity was backgrounded. * @param recordFirstPaint Callable to determine if first paint should be recorded.
* {@link SystemClock#elapsedRealtime}. * {@link SystemClock#elapsedRealtime}.
* @return Whether the Paint Preview started to initialize or is already initializating. * @return Whether the Paint Preview started to initialize or is already initializating.
* Note that if the Paint Preview is already showing, this will return false. * Note that if the Paint Preview is already showing, this will return false.
*/ */
public boolean maybeShow(@Nullable Runnable onShown, @Nullable Runnable onDismissed, public boolean maybeShow(@Nullable Runnable onShown, @Nullable Runnable onDismissed,
long activityCreationTimestampMs, Callable<Boolean> wasBackgrounded) { long activityCreationTimestampMs, Callable<Boolean> recordFirstPaint) {
if (mInitializing != null) return mInitializing; if (mInitializing != null) return mInitializing;
// Check if a capture exists. This is a quick check using a cache. // Check if a capture exists. This is a quick check using a cache.
...@@ -170,7 +170,11 @@ public class TabbedPaintPreviewPlayer implements TabViewProvider, UserData { ...@@ -170,7 +170,11 @@ public class TabbedPaintPreviewPlayer implements TabViewProvider, UserData {
onShown.run(); onShown.run();
mMetricsHelper.onShown(); mMetricsHelper.onShown();
}, },
() -> mMetricsHelper.onFirstPaint(activityCreationTimestampMs, wasBackgrounded), () -> {
if (!isShowingAndNeedsBadge()) return;
mMetricsHelper.onFirstPaint(activityCreationTimestampMs, recordFirstPaint);
},
() -> mHasUserInteraction = true, () -> mHasUserInteraction = true,
ChromeColors.getPrimaryBackgroundColor(mTab.getContext().getResources(), false), ChromeColors.getPrimaryBackgroundColor(mTab.getContext().getResources(), false),
(status) -> { (status) -> {
......
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