tracing coroutine, using async wait?

I have a bit of a problem with this spaghetti code I’m trying to untangle.
Things fire up left and right and they do so through coroutine and as you know you cannot trace a coroutine.
I’m trying to convert a coroutine that loads a level async into something traceable and my understanding is async await does.
How do I do that?
Here is the original code:
calling method:

public void LoadLevel(string name, bool noWait = false)
    {
     // ... stuff
            StopAllCoroutines();
        StartCoroutine(_LoadLevel());
    }
IEnumerator _LoadLevel()
    {
                   // ... stuff
        StartCoroutine(FadeOutAllAudio());
        yield return new WaitForSeconds(1);
        yield return LMLoadLevel(loadingName);
}
    public AsyncOperation LMLoadLevel(string loadingName)
    {
        loadLevelAsyncOperation = Application.LoadLevelAsync(loadingName);
        Fader.SetAsync(loadLevelAsyncOperation);
        return loadLevelAsyncOperation;
    }

What do you mean by trace? You can certainly print log statements from a coroutine if that’s what you’re asking. They also run at very predictable times, outlined in this diagram: https://docs.unity3d.com/Manual/ExecutionOrder.html

1 Like

trace = get a full chain of calls
As you can see in this call stack the trace doesn’t include the caller.
5921003--632675--upload_2020-5-30_16-38-56.png
This is what I’m trying to get
5921003--632678--upload_2020-5-30_16-43-51.png
line with breakpoint ----> call … call —> engine entry point

5921003--632672--upload_2020-5-30_16-35-23.png

What? How are you printing out the stack trace? This always worked for me:

string str = UnityEngine.StackTraceUtility.ExtractStackTrace ();
Debug.Log(str);

Looks like the Visual Studio Call Stack