Does @MainActor need some sort of precondition to run on the main actor?
I have an app intent with a perform method. The codebase is fully Swift6 with strict concurrency. It compiles and runs great. However, I ran into this issue.
The.perform method does not run on the main actor, no matter what I try. Am I missing something, or is there something missing from my understanding of how @MainActor works?
the screenshot doesn't make it clear that the execution context is not the main thread/actor, since the name is truncated. the Task number is 47, but what is the actual executor?
The code is running in an arbitrary task, but that task has (presumably) been scheduled to run on the main actor (at least until the next suspension point, anyway).
If you widen the left-hand panel (the Debug Navigator in Xcode parlance), you should see the underlying queue's name is something like "com.apple.main-thread (serial)". Or, better yet, if you switch from task view to thread view, you should simply see this code running on thread 0, the main thread.
ops, this is a good point! I was confused by the mix of thread and task on the side bar. Yes, after switching to thread view. It is on the main-thread.