When Chrome fails a primary-main-frame load with
net::ERR_INTERNET_DISCONNECTED for an installed web app,
ChromeContentBrowserClient::GetAlternativeErrorPageOverrideInfo
registers a DefaultOfflineWebContentsObserver that is supposed
to log how long the offline error page is visible. The observer is attached
before the alternative error-page navigation commits in the
renderer. If the WebContents is torn down, or the navigation is
aborted, between registration and commit,
DidFinishNavigation fires for a navigation whose
IsErrorPage() is false, tripping
CHECK(navigation_handle->IsErrorPage()) at
chrome/browser/webapps/web_app_offline.cc:78.
WebContentsDestroyed hits the same window and logs an
uninitialized duration metric on the way out.
The observer tracks exactly one error-page navigation, but
DidFinishNavigation runs for every finished primary-main-frame
navigation on the WebContents, including the aborted ones.
TrackOfflinePageVisibility now takes the
NavigationHandle& and stashes its
GetNavigationId() on the observer. The new
DidFinishNavigation contract:
delete this, no metricCHECK(navigation_handle->IsErrorPage()), start the timer
WebContentsDestroyed mirrors the same rule: if the error page
never committed, delete silently instead of logging a bogus duration from an
uninitialized timer_start_.
| phase | build | test | result |
|---|---|---|---|
| red | fix cherry-picked, pre-commit guard removed | WebContentsDestroyedBeforeOfflinePageCommitsDoesNotCrashOrLog/0 |
CRASHED |
| green | full fix applied | All/WebAppOfflinePageTest.* (18 cases) |
18 / 18 PASS |
| cq | patchset 3 (BUILD.gn dep added) | chromium CQ dry run | 32 / 32 PASS |
// chrome/browser/webapps/web_app_offline.cc (pre-fix)
if (!error_page_url_.is_empty()) {
// ... first navigation has already committed, log + exit
}
// TODO(crbug.com/575489700): CHECK-exclusion: Convert to a CHECK once we
// are confident it won't be triggered.
DCHECK(navigation_handle->IsErrorPage()); // <-- trips when aborted
CHECK(error_page_url_.is_empty(), base::NotFatalUntil::M162);
error_page_url_ = navigation_handle->GetURL();
timer_start_ = base::TimeTicks::Now();
CL 8746501 · Issue 575489700 · Parent revert #575489604 · web_app_offline.cc · Prior WIP CL 8710314