UniTask icon indicating copy to clipboard operation
UniTask copied to clipboard

UniTask Tracker: UniTask Tracker continues to display task information after exiting play mode

Open tmoritaa opened this issue 6 years ago • 2 comments

Hello,

I think I found an issue with the UniTask Tracker where it continues to display tasks that were running when exiting play mode. I've written down the reproduction steps, as well as the script I used to reproduce this issue below.

I reproduced this issue with Unity 2018.4.14.

I also looked into this a bit, and it seems this bug did not occur with UniTask 1.0.0, but does occur in both UniTask 1.1.0 and 1.2.0. Furthermore, importing UniTask 1.1.0 and reverting commit f82c7622 seems to fix this issue. I unfortunately don't completely understand the code, but it seems like the code wrapped in the #if UNITY_EDITOR is the cause.

Please let me know if there's any more information I can provide, or if there's anything I can help with.

Thanks!

Reproduction Steps: Attaching the script below to a GameObject in an empty scene

  1. Open UniTask Tracker and start play mode
  2. Reload UniTask Tracker and confirm that the task is displayed in the tracker
  3. Stop Play mode

Result: UniTask Tracker continues to display the task, with the Elapsed time continuing to increase everytime you press reload, and the task status remaining on pending.

public class Experiments : MonoBehaviour {
  private CancellationTokenSource tokenSource;

  void Start() {
    this.tokenSource = new CancellationTokenSource();

    var token = this.tokenSource.Token;
    this.Test(token).Forget();
  }

  void OnDestroy() {
    this.tokenSource.Cancel();
    this.tokenSource.Dispose();
  }

  private async UniTaskVoid Test(CancellationToken token) {
    while (!token.IsCancellationRequested) {
      Debug.Log("Test");
      await UniTask.Delay(500, cancellationToken: token);
    }
  }
}

tmoritaa avatar Dec 26 '19 02:12 tmoritaa

I've seen this as well.

cg-adam avatar Jan 20 '20 20:01 cg-adam

As the application ends, the loop stops, so yes, it continues. This is true in a sense, though, since it doesn't stop in the actual application either (the application quits before it stops).

neuecc avatar Apr 15 '20 15:04 neuecc