Commit 09e31113 authored by Mohamed Heikal's avatar Mohamed Heikal Committed by Commit Bot

[Android] Fix crash if OmniboxStartupMetrics destroyed before delayed task is run

ToolbarManager#onDeferredStartup may post a delayed task to the UI thread that
calls itself. If the activity that owns the ToolbarManager is destroyed before
the task is run (and ToolbarManager#destroy is called) then the
mOmniboxStartupMetrics could be a null pointer. This cl adds a check to see if
the activity is finishing when the delayed task is run and noops out if it has.

Bug: 860449
Change-Id: Iac8333d26311142ce8e130b42aa5c7c551b844ca
Reviewed-on: https://chromium-review.googlesource.com/1127304Reviewed-by: default avatarYusuf Ozuysal <yusufo@chromium.org>
Commit-Queue: Mohamed Heikal <mheikal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573386}
parent 5ca5adc6
......@@ -1223,6 +1223,7 @@ public class ToolbarManager implements ToolbarTabController, UrlFocusChangeListe
long elapsedTime = SystemClock.elapsedRealtime() - activityCreationTimeMs;
if (elapsedTime < RECORD_UMA_PERFORMANCE_METRICS_DELAY_MS) {
ThreadUtils.postOnUiThreadDelayed(() -> {
if (mActivity.isActivityFinishing()) return;
onDeferredStartup(activityCreationTimeMs, activityName);
}, RECORD_UMA_PERFORMANCE_METRICS_DELAY_MS - elapsedTime);
return;
......
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