Confused about concurrency problem presented in wwdc24 video

No, nonisolated just means that it's not isolated to any actor — which of course isn't any kind of explanation.

To understand what's going on, you need to consider an additional piece of information: the function that's being marked nonisolated is an async function.

A non-isolated async function runs on a special non-actor asynchronous context, and that is similar to the non-main context that concurrent tasks use more generally in Swift. In particular, that's going to involve a non-main thread.

So, it's the combination of nonisolated and async that "forces" execution off the main thread.

1 Like