`#SendingRisksDataRace` errors calling async transpiled bridged `@MainActor` methods in a `Task`
Nobody has claimed this yet.
- Dominant language
- Swift
- Stars
- 3.2k
- Forks
- 106
- Avg merge
- 6d 13h
- Merged PRs (30d)
- 1
Description
Skip Fuse gets #SendingRisksDataRace errors calling async transpiled bridged methods in a Task. (The bridge isn't @MainActor or Sendable.)
/Users/dfabulich/git/skiphack/skipapp-showcase-fuse/Sources/ShowcaseFuse/WebAuthenticationSessionPlayground.swift:89:71: error: sending 'self.webAuthenticationSession' risks causing data races [#SendingRisksDataRace]
87 | let urlWithToken: URL
88 | if #available(iOS 17.4, *) {
89 | urlWithToken = try await webAuthenticationSession.authenticate(
| |- error: sending 'self.webAuthenticationSession' risks causing data races [#SendingRisksDataRace]
| `- note: sending main actor-isolated 'self.webAuthenticationSession' to nonisolated instance method 'authenticate(using:callback:preferredBrowserSession:additionalHeaderFields:)' risks causing data races between nonisolated and main actor-isolated uses
90 | using: URL(string: "https://push.skip.tools/webauth-demo/?scheme=org.appfair.app.showcase")!,
91 | callback: .customScheme("org.appfair.app.showcase"),
/Users/dfabulich/git/skiphack/skipapp-showcase-fuse/Sources/ShowcaseFuse/WebAuthenticationSessionPlayground.swift:96:71: error: sending 'self.webAuthenticationSession' risks causing data races [#SendingRisksDataRace]
94 | )
95 | } else {
96 | urlWithToken = try await webAuthenticationSession.authenticate(
| |- error: sending 'self.webAuthenticationSession' risks causing data races [#SendingRisksDataRace]
| `- note: sending main actor-isolated 'self.webAuthenticationSession' to nonisolated instance method 'authenticate(using:callbackURLScheme:preferredBrowserSession:)' risks causing data races between nonisolated and main actor-isolated uses
97 | using: URL(string: "https://push.skip.tools/webauth-demo/?scheme=org.appfair.app.showcase")!,
98 | callbackURLScheme: "org.appfair.app.showcase",
[#SendingRisksDataRace]: <https://docs.swift.org/compiler/documentation/diagnostics/sending-risks-data-race>
The workaround I used was to add a Sendable extension in an #if SKIP_BRIDGE block.
extension WebAuthenticationSession: @unchecked Sendable {}
… but that adds a warning to the build, "warning: When bridging API from a transpiled module, place all code within a #if !SKIP_BRIDGE condition"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the reported async transpiled bridge calls to @MainActor methods in the Skip Fuse WebAuthenticationSessionPlayground.swift example and review how Skip handles bridged actor isolation and Sendable annotations. Reproduce the #SendingRisksDataRace diagnostics, then verify that the supported bridge output avoids the diagnostic without requiring an unchecked Sendable extension or producing the SKIP_BRIDGE warning.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- swift
- Domain
- compilers, mobile-dev
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Needs clarification
- Newbie friendliness
- 45/100