Use the async version of evaluateJavaScript method.#93
Merged
Conversation
Signed-off-by: Takuto NAKAMURA (Kyome) <kyomesuke@gmail.com>
There was a problem hiding this comment.
Pull request overview
This PR updates WebViewProxy to use the async/await variant of WKWebView.evaluateJavaScript(_:), aligning the WebUI implementation with newer Xcode/WebKit behavior and avoiding the “Sending 'result' risks causing data races” compiler error caused by moving an Any? across a Task boundary.
Changes:
- Replaced the continuation + completion-handler wrapper with a direct
try awaitcall toevaluateJavaScript(_:). - Removed the intermediate
Task { @MainActor ... }hop that triggered sendability/data-race diagnostics.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
I think I've just found a duplicate of this issue (#94) |
b1ackturtle
approved these changes
Mar 30, 2026
Collaborator
b1ackturtle
left a comment
There was a problem hiding this comment.
Good catch, thanks!
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When attempting to build the WebUI with Xcode 26.4, it was discovered that passing
Any?as a result within a Task causes a "Sending 'result' risks causing data races" compiler error.At the time of the initial WebUI implementation (March 2024), the async version of
evaluateJavaScript()had the following issue:Because of this, we had been using the closure-based callback version of
evaluateJavaScript().However, this issue was fixed by the WebKit team in December 2024, and it now functions as expected in the latest Xcode.
WebKit/WebKit#37519
For these reasons, we are switching to the async version of
evaluateJavaScript().