Commit 08eb43ca authored by Robert Ogden's avatar Robert Ogden Committed by Commit Bot

Fix IsolatedPrerender crash

This crash is caused by the callback being run after the original SRP
has been navigated away from, causing the metrics collector to be null.

This CL adds a check to skip the callback if the url isn't in the set
of predicted urls, and also adds an additional guard to check that the
metrics collector is not null.

Bug: 1141319,1136174
Change-Id: Ia8a8542cf5c6833abdd1e88d5c2317966ebf4cb7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2490211
Auto-Submit: Robert Ogden <robertogden@chromium.org>
Commit-Queue: Ryan Sturm <ryansturm@chromium.org>
Reviewed-by: default avatarRyan Sturm <ryansturm@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819865}
parent 007b046a
...@@ -1217,13 +1217,23 @@ void IsolatedPrerenderTabHelper::OnGotEligibilityResult( ...@@ -1217,13 +1217,23 @@ void IsolatedPrerenderTabHelper::OnGotEligibilityResult(
base::Optional<IsolatedPrerenderPrefetchStatus> status) { base::Optional<IsolatedPrerenderPrefetchStatus> status) {
DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_); DCHECK_CALLED_ON_VALID_SEQUENCE(sequence_checker_);
// It is possible that this callback is being run late. That is, after the
// user has navigated away from the origin SRP. To detect this, check if the
// url exists in the set of predicted urls. If it doesn't, do nothing.
if (page_->original_prediction_ordering_.find(url) ==
page_->original_prediction_ordering_.end()) {
return;
}
if (!eligible) { if (!eligible) {
if (status) { if (status) {
OnPrefetchStatusUpdate(url, status.value()); OnPrefetchStatusUpdate(url, status.value());
DCHECK(page_->prefetch_metrics_collector_); if (page_->prefetch_metrics_collector_) {
page_->prefetch_metrics_collector_->OnMainframeResourceNotEligible( page_->prefetch_metrics_collector_->OnMainframeResourceNotEligible(
url, page_->original_prediction_ordering_.find(url)->second, *status); url, page_->original_prediction_ordering_.find(url)->second,
*status);
}
} }
return; 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