Commit 517ce639 authored by Gauthier Ambard's avatar Gauthier Ambard Committed by Commit Bot

[iOS] Early return if the navigation context is nil during error

When failing a provisional navigation, the context might be nil
(probably a race condition in the callbacks of the WKWebView).
This issue was handled in handleCancelledError:forNavigation:
provisionalLoad: but wasn't in the other callbacks.
This CL makes sure that we handle it.
The workaround in crrev.com/c/1700054 was probably preventing the
crash from happening.

Bug: 1004634
Change-Id: I1f94812617c908a63124c16a18a3ca71d9902d8d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1816575
Commit-Queue: Gauthier Ambard <gambard@chromium.org>
Reviewed-by: default avatarAli Juma <ajuma@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#699741}
parent 1cc6e6b0
......@@ -1636,6 +1636,22 @@ void ReportOutOfSyncURLInDidStartProvisionalNavigation(
web::NavigationContextImpl* navigationContext =
[self.navigationStates contextForNavigation:navigation];
if (@available(iOS 13, *)) {
} else {
if (provisionalLoad && !navigationContext &&
web::RequiresProvisionalNavigationFailureWorkaround()) {
// It is likely that |navigationContext| is null because
// didStartProvisionalNavigation: was not called with this WKNavigation
// object. Log UMA to know when this workaround can be removed and
// do not call OnNavigationFinished() to avoid crash on null pointer
// dereferencing. See crbug.com/973653 and crbug.com/1004634 for details.
UMA_HISTOGRAM_BOOLEAN(
"Navigation.IOSNullContextInDidFailProvisionalNavigation", true);
return;
}
}
navigationContext->SetError(error);
navigationContext->SetIsPost([self isCurrentNavigationItemPOST]);
// TODO(crbug.com/803631) DCHECK that self.currentNavItem is the navigation
......
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