From d09541a0c09417051f42c853cc6f99f8bec28787 Mon Sep 17 00:00:00 2001 From: Brent Simmons Date: Fri, 1 May 2020 17:35:27 -0700 Subject: [PATCH 1/4] Bump build to 44. --- xcconfig/common/NetNewsWire_ios_target_common.xcconfig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/xcconfig/common/NetNewsWire_ios_target_common.xcconfig b/xcconfig/common/NetNewsWire_ios_target_common.xcconfig index 2b155ae2f..e34f4fec5 100644 --- a/xcconfig/common/NetNewsWire_ios_target_common.xcconfig +++ b/xcconfig/common/NetNewsWire_ios_target_common.xcconfig @@ -1,7 +1,7 @@ // High Level Settings common to both the iOS application and any extensions we bundle with it MARKETING_VERSION = 5.0.1 -CURRENT_PROJECT_VERSION = 43 +CURRENT_PROJECT_VERSION = 44 ALWAYS_EMBED_SWIFT_STANDARD_LIBRARIES = YES ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon From 5f60b84b8b9b48b01f8594550d2d154428c194d6 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 6 May 2020 14:53:09 -0500 Subject: [PATCH 2/4] Reset all the web views when coming back to the foreground incase one of them is unavailable now --- iOS/Article/ArticleViewController.swift | 21 +++++++++++---------- iOS/Article/WebViewController.swift | 13 +++++++------ 2 files changed, 18 insertions(+), 16 deletions(-) diff --git a/iOS/Article/ArticleViewController.swift b/iOS/Article/ArticleViewController.swift index 8b47ffa05..bb839e372 100644 --- a/iOS/Article/ArticleViewController.swift +++ b/iOS/Article/ArticleViewController.swift @@ -202,12 +202,7 @@ class ArticleViewController: UIViewController { } @objc func contentSizeCategoryDidChange(_ note: Notification) { - coordinator.webViewProvider.flushQueue() - coordinator.webViewProvider.replenishQueueIfNeeded() - if let controller = currentWebViewController { - controller.fullReload() - self.pageViewController.setViewControllers([controller], direction: .forward, animated: false, completion: nil) - } + resetWebViewController() } @objc func willEnterForeground(_ note: Notification) { @@ -215,6 +210,7 @@ class ArticleViewController: UIViewController { if AppDefaults.articleFullscreenEnabled { currentWebViewController?.hideBars() } + resetWebViewController() } // MARK: Actions @@ -274,10 +270,6 @@ class ArticleViewController: UIViewController { currentWebViewController?.scrollPageDown() } - func fullReload() { - currentWebViewController?.fullReload() - } - func stopArticleExtractorIfProcessing() { currentWebViewController?.stopArticleExtractorIfProcessing() } @@ -366,4 +358,13 @@ private extension ArticleViewController { return controller } + func resetWebViewController() { + coordinator.webViewProvider.flushQueue() + coordinator.webViewProvider.replenishQueueIfNeeded() + if let controller = currentWebViewController { + controller.fullReload() + self.pageViewController.setViewControllers([controller], direction: .forward, animated: false, completion: nil) + } + } + } diff --git a/iOS/Article/WebViewController.swift b/iOS/Article/WebViewController.swift index d8e59ff05..a0757fcdf 100644 --- a/iOS/Article/WebViewController.swift +++ b/iOS/Article/WebViewController.swift @@ -148,7 +148,8 @@ class WebViewController: UIViewController { } func fullReload() { - self.loadWebView() + view.subviews.first?.removeFromSuperview() + loadWebView() } func showBars() { @@ -288,10 +289,10 @@ extension WebViewController: UIContextMenuInteractionDelegate { // MARK: WKNavigationDelegate extension WebViewController: WKNavigationDelegate { + func webView(_ webView: WKWebView, decidePolicyFor navigationAction: WKNavigationAction, decisionHandler: @escaping (WKNavigationActionPolicy) -> Void) { if navigationAction.navigationType == .linkActivated { - guard let url = navigationAction.request.url else { decisionHandler(.allow) return @@ -313,13 +314,13 @@ extension WebViewController: WKNavigationDelegate { } else { decisionHandler(.allow) } - } else { - decisionHandler(.allow) - } - + } + + func webViewWebContentProcessDidTerminate(_ webView: WKWebView) { + fullReload() } } From 502ff3e0191e41aebedae7ec1ce93f8c5a47e42b Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 6 May 2020 14:55:34 -0500 Subject: [PATCH 3/4] Don't multiply by the device pixel ratio if that will put us over the canvas limit --- iOS/Resources/main_ios.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/iOS/Resources/main_ios.js b/iOS/Resources/main_ios.js index f3cbd712f..885529894 100644 --- a/iOS/Resources/main_ios.js +++ b/iOS/Resources/main_ios.js @@ -35,10 +35,14 @@ class ImageViewer { this.hideLoadingIndicator(); var canvas = document.createElement("canvas"); - canvas.width = this.img.naturalWidth * window.devicePixelRatio; - canvas.height = this.img.naturalHeight * window.devicePixelRatio; + var pixelRatio = window.devicePixelRatio; + do { + canvas.width = this.img.naturalWidth * pixelRatio; + canvas.height = this.img.naturalHeight * pixelRatio; + pixelRatio--; + } while (pixelRatio > 0 && canvas.width * canvas.height > 16777216) canvas.getContext("2d").drawImage(this.img, 0, 0, canvas.width, canvas.height); - + const rect = this.img.getBoundingClientRect(); const message = { x: rect.x, From d4cffa28f2aed3c3d585cb8180f18a1a2208d9b6 Mon Sep 17 00:00:00 2001 From: Maurice Parker Date: Wed, 6 May 2020 14:58:47 -0500 Subject: [PATCH 4/4] Rollback disclosure button reference hold since it does nothing to stop the crash --- iOS/MasterFeed/Cell/MasterFeedTableViewSectionHeader.swift | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/iOS/MasterFeed/Cell/MasterFeedTableViewSectionHeader.swift b/iOS/MasterFeed/Cell/MasterFeedTableViewSectionHeader.swift index d06a33399..3fcf7506f 100644 --- a/iOS/MasterFeed/Cell/MasterFeedTableViewSectionHeader.swift +++ b/iOS/MasterFeed/Cell/MasterFeedTableViewSectionHeader.swift @@ -73,16 +73,13 @@ class MasterFeedTableViewSectionHeader: UITableViewHeaderFooterView { private let unreadCountView = MasterFeedUnreadCountView(frame: CGRect.zero) - @available(iOS 13.4, *) - private(set) lazy var disclosurePointerInteraction = UIPointerInteraction() - private lazy var disclosureButton: UIButton = { let button = NonIntrinsicButton() button.tintColor = UIColor.tertiaryLabel button.setImage(AppAssets.disclosureImage, for: .normal) button.contentMode = .center if #available(iOS 13.4, *) { - button.addInteraction(disclosurePointerInteraction) + button.addInteraction(UIPointerInteraction()) } button.addTarget(self, action: #selector(toggleDisclosure), for: .touchUpInside) return button