Skip to content

Commit

Permalink
Moves evaluateJS methods to main thread (#908)
Browse files Browse the repository at this point in the history
Task/Issue URL: https://app.asana.com/0/1204099484721401/1207878727316917/f
iOS PR: duckduckgo/iOS#3132
macOS PR: duckduckgo/macos-browser#3013
What kind of version bump will this require?: Patch

Description:

Moves Message broker methods to main thread
  • Loading branch information
afterxleep authored Jul 24, 2024
1 parent 4245888 commit 6c095d0
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions Sources/UserScript/UserScriptMessaging.swift
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ public final class UserScriptMessageBroker: NSObject {
return
}
if #available(macOS 11.0, iOS 14.0, *) {
if !self.requiresRunInPageContentWorld {
webView.evaluateJavaScript(js, in: nil, in: WKContentWorld.defaultClient)
} else {
webView.evaluateJavaScript(js)
DispatchQueue.main.async {
if !self.requiresRunInPageContentWorld {
webView.evaluateJavaScript(js, in: nil, in: WKContentWorld.defaultClient)
} else {
webView.evaluateJavaScript(js)
}
}
}
}
Expand Down

0 comments on commit 6c095d0

Please sign in to comment.