Skip to content

Commit

Permalink
Fix for deeplink crash when preparing webview preview (#2116)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/414709148257752/1205793869765618/f
Tech Design URL:
CC:

Description:
When launching the app from deeplink the webView size can be 0,0 causing UIGraphicsBeginImageContextWithOptions to crash
  • Loading branch information
amddg44 authored Oct 31, 2023
1 parent 784f05a commit ce8ce75
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion DuckDuckGo/TabViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -1094,7 +1094,8 @@ extension TabViewController: WKNavigationDelegate {

func preparePreview(completion: @escaping (UIImage?) -> Void) {
DispatchQueue.main.async { [weak self] in
guard let webView = self?.webView else { completion(nil); return }
guard let webView = self?.webView,
webView.bounds.height > 0 && webView.bounds.width > 0 else { completion(nil); return }
UIGraphicsBeginImageContextWithOptions(webView.bounds.size, false, UIScreen.main.scale)
webView.drawHierarchy(in: webView.bounds, afterScreenUpdates: true)
if let jsAlertController = self?.jsAlertController {
Expand Down

0 comments on commit ce8ce75

Please sign in to comment.