Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

UserReportingClient not threadsafe

Discussion in 'Unity Cloud Diagnostics' started by Falondrian, Jul 29, 2019.

  1. Falondrian

    Falondrian

    Joined:
    Dec 4, 2018
    Posts:
    35
    Hi, you are using a regular C# list "synchronizedActions" for scheduling actions from coroutines. The way it is implemented is not threadsafe:

    foreach (Action synchronizedAction in this.synchronizedActions)
    {
    this.currentSynchronizedActions.Add(synchronizedAction);
    }

    this.synchronizedActions.Clear();
    foreach (Action synchronizedAction in this.currentSynchronizedActions)
    {
    synchronizedAction();
    }

    The synchronizedActions list could be modified during the iteration and also before the Clear() call.
     
  2. bretth_unity

    bretth_unity

    Unity Technologies

    Joined:
    Dec 1, 2016
    Posts:
    38
    This will be corrected in the next SDK version. Thank you. :)
     
    Falondrian likes this.
unityunity