When a synchronous app hangs unexpectedly, examining the call stack for the thread(s) can help with identifying what caused the hang. When using Swift’s Concurrency though the call stacks are often almost entirely empty as the threads are waiting for work. Is there a way to produce an async “call stack” for Swift concurrency tasks that are suspended? I know Instruments can show some information about concurrency tasks but I haven’t been able to get quite get what I need out of it, and unfortunately I primarily need to be able to do this on Linux.
If you have a pointer to the task, and you’re willing to do some spelunking, then yeah, the stored continuation function pointer and async context for a suspended task can be used to trace what it was doing
Sounds like a potentially helpful view in the debugger. I imagine a task view in Xcode, that shows all currently existing tasks with their known state (running/suspended, cancelled, priority, task-local) and partial stacks, at least what‘s known from their continuations.
2 Likes