Skip to content

Commit

Permalink
[iOS] Fix crash if internal pages are stopped prior to fully loading
Browse files Browse the repository at this point in the history
  • Loading branch information
kylehickinson committed Nov 7, 2024
1 parent 7208dc3 commit 30b35ab
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 30b35ab

Please sign in to comment.