mirror of
https://github.com/Ranchero-Software/NetNewsWire
synced 2026-11-29 08:42:51 +00:00
Recover from WebKit content-process termination — refresh the preloaded web view pool on foreground, and never render into a web view whose process died. Fixes #5310.
This commit is contained in:
1 parent
7e5e630a4b
commit
e99f23d07e
2 files changed
+18
-1
No files matched your search
@@ -37,6 +37,8 @@ final class WebViewController: UIViewController {
|
||||
return view.subviews[0] as? PreloadedWebView
|
||||
}
|
||||
|
||||
private var webViewProcessDidTerminate = false
|
||||
|
||||
private lazy var contextMenuInteraction = UIContextMenuInteraction(delegate: self)
|
||||
private var isFullScreenAvailable: Bool {
|
||||
return AppDefaults.shared.articleFullscreenAvailable && traitCollection.userInterfaceIdiom == .phone
|
||||
@@ -454,6 +456,7 @@ extension WebViewController: WKNavigationDelegate {
|
||||
}
|
||||
|
||||
func webViewWebContentProcessDidTerminate(_ webView: WKWebView) {
|
||||
webViewProcessDidTerminate = true
|
||||
fullReload()
|
||||
}
|
||||
|
||||
@@ -554,11 +557,15 @@ private extension WebViewController {
|
||||
func loadWebView(replaceExistingWebView: Bool = false) {
|
||||
guard isViewLoaded else { return }
|
||||
|
||||
if !replaceExistingWebView, let webView = webView {
|
||||
// Never render into a web view whose content process died — the load
|
||||
// can fail silently, leaving the article view blank.
|
||||
if !replaceExistingWebView, !webViewProcessDidTerminate, let webView = webView {
|
||||
self.renderPage(webView)
|
||||
return
|
||||
}
|
||||
|
||||
webViewProcessDidTerminate = false
|
||||
|
||||
coordinator.webViewProvider.dequeueWebView { webView in
|
||||
|
||||
webView.ready {
|
||||
|
||||
@@ -7,6 +7,7 @@
|
||||
//
|
||||
|
||||
import Foundation
|
||||
import UIKit
|
||||
import RSCore
|
||||
import WebKit
|
||||
|
||||
@@ -21,12 +22,21 @@ import WebKit
|
||||
articleIconSchemeHandler = ArticleIconSchemeHandler(coordinator: coordinator)
|
||||
super.init()
|
||||
replenishQueueIfNeeded()
|
||||
NotificationCenter.default.addObserver(self, selector: #selector(handleWillEnterForeground(_:)), name: UIApplication.willEnterForegroundNotification, object: nil)
|
||||
}
|
||||
|
||||
func replenishQueueIfNeeded() {
|
||||
operationQueue.add(WebViewProviderReplenishQueueOperation(queue: queue, articleIconSchemeHandler: articleIconSchemeHandler))
|
||||
}
|
||||
|
||||
// Pooled web views can lose their content process while the app is in the
|
||||
// background. A load into a dead web view can fail silently, showing blank —
|
||||
// so start over with fresh web views.
|
||||
@objc func handleWillEnterForeground(_ note: Notification) {
|
||||
queue.removeAllObjects()
|
||||
replenishQueueIfNeeded()
|
||||
}
|
||||
|
||||
func dequeueWebView(completion: @escaping (PreloadedWebView) -> Void) {
|
||||
operationQueue.add(WebViewProviderDequeueOperation(queue: queue, articleIconSchemeHandler: articleIconSchemeHandler, completion: completion))
|
||||
operationQueue.add(WebViewProviderReplenishQueueOperation(queue: queue, articleIconSchemeHandler: articleIconSchemeHandler))
|
||||
|
||||
Reference in new issue
Block a user