Skip to content

Commit

Permalink
Merge pull request #26434 from brave/ios-web-internals-crash
Browse files Browse the repository at this point in the history
[iOS] Fix crash if internal pages are stopped prior to fully loading
  • Loading branch information
kylehickinson authored Nov 7, 2024
2 parents 7208dc3 + 30b35ab commit 6cb2b70
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ public class InternalSchemeHandler: NSObject, WKURLSchemeHandler {

let path = url.path.starts(with: "/") ? String(url.path.dropFirst()) : url.path

if activeTasks.object(forKey: urlSchemeTask) != nil {
// Already a task ongoing, technically this shouldn't happen.
return
}

let task = Task {
// For non-main doc URL, try load it as a resource
if !urlSchemeTask.request.isPrivileged,
Expand Down Expand Up @@ -168,5 +173,7 @@ public class InternalSchemeHandler: NSObject, WKURLSchemeHandler {
activeTasks.setObject(TaskHolder(task: task), forKey: urlSchemeTask)
}

public func webView(_ webView: WKWebView, stop urlSchemeTask: WKURLSchemeTask) {}
public func webView(_ webView: WKWebView, stop urlSchemeTask: WKURLSchemeTask) {
activeTasks.removeObject(forKey: urlSchemeTask)
}
}

0 comments on commit 6cb2b70

Please sign in to comment.