I occasionally get this error in Xcode’s console:
Potential Structural Swift Concurrency Issue: unsafeForcedSync called from Swift Concurrent context.
What does this mean, and how can I resolve it? Googling it doesn’t turn up any results.
This doesn't crash the app - it’s just an error diagnostic that I see in the Xcode console. The app keeps running before and after the issue.
Is there a way I can set a breakpoint to catch this where it happens?
I filed FB20484368.
Thanks.
I was worried it was related to something in my code.
You are right to be worried here. While the problem isn’t with your code, the issue could affect your code. Lemme explain…
Actually, that explanation got way too long so I’ve moved the first part of it here: Waiting for an Async Result in a Synchronous Function
You can think of the unsafeForcedSync
code as being like the mySynchronous(…)
function from that post, except that it checks whether it’s being called from a Swift async function and logs if that’s the case. That log is not just noise: It tells you that you’re potentially exposing yourself to Swift concurrency thread pool exhaustion, and hence to a deadlock. But what you do about it is one of those classic engineering trade-offs. Do you leave it for Apple to resolve? Or do you take ‘heroic measures’ to move this work out of your Swift async function?
My inclination is to just leave it to Apple, but I wanted to explain the fundamentals so that you can make an informed choice.
Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"