Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug 1194726 - Blank Tabs #967

Merged
merged 1 commit into from Aug 21, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions Client/Frontend/Browser/BrowserViewController.swift
Expand Up @@ -1520,6 +1520,10 @@ extension BrowserViewController: WKUIDelegate {
return
}

if checkIfWebContentProcessHasCrashed(webView, error: error) {
return
}

if let url = error.userInfo?["NSErrorFailingURLKey"] as? NSURL {
ErrorPageHelper().showPage(error, forUrl: url, inWebView: webView)
}
Expand All @@ -1535,6 +1539,10 @@ extension BrowserViewController: WKUIDelegate {
return
}

if checkIfWebContentProcessHasCrashed(webView, error: error) {
return
}

if error.code == Int(CFNetworkErrors.CFURLErrorCancelled.rawValue) {
if let browser = tabManager[webView] where browser === tabManager.selectedTab {
urlBar.currentURL = browser.displayURL
Expand All @@ -1547,6 +1555,16 @@ extension BrowserViewController: WKUIDelegate {
}
}

private func checkIfWebContentProcessHasCrashed(webView: WKWebView, error: NSError) -> Bool {
if error.code == WKErrorCode.WebContentProcessTerminated.rawValue && error.domain == "WebKitErrorDomain" {
log.debug("WebContent process has crashed. Trying to reloadFromOrigin to restart it.")
webView.reloadFromOrigin()
return true
}

return false
}

func webView(webView: WKWebView, decidePolicyForNavigationResponse navigationResponse: WKNavigationResponse, decisionHandler: (WKNavigationResponsePolicy) -> Void) {
if navigationResponse.canShowMIMEType {
decisionHandler(WKNavigationResponsePolicy.Allow)
Expand Down