Addressables - DeferredCompleteCallbacks concurrent race-condition bug

It leads to unpredictable results - events skipping, null reference exception, infinite loop or even memory damage. It can happen on failed WebRequest for example for now.

Test to prove: test for concurrent DeferredAsyncCompleted events (FAILS with skipped… · nick-dodonov/com.unity.addressables@968f05c · GitHub

Fix: fix concurrent DeferredAsyncCompleted event process/register race-con… · nick-dodonov/com.unity.addressables@efe943f · GitHub

2 Likes

Or possibly it’s my fault - to think I can implement ResourceProvider in a real async manner.((
Just about everything in unity is main-threaded and AsyncOperation of WebRequest looks the same.

In such case the bug is better to transform to the “feature request” - to Assert (in debug only) public api methods that are not thread-safe.

  • It’ll give a better understanding of what is really allowed.
  • It’ll safe people starting to use Tasks without looking at SynchronizationContext and ContinueWith such public calls.