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
…(uplift to 1.74.x) (#26439)

Uplift of #26434 (squashed) to beta
  • Loading branch information
brave-builds authored Nov 8, 2024
1 parent 6244f6a commit 4928d7d
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 4928d7d

Please sign in to comment.