Hi, we’re using Unity 2022.3.16f1 with Addressables 1.21.19 and have encountered in two separate occasions a game killing bug, where the game hangs indefinitely if any of the game objects in a scene which is being loaded, in their Start() callback call LoadAssetAsync() on an AssetReferenceT and call WaitForCompletion() on their AsyncOperationHandle.
Hey, so first off I wanted to send you this: Synchronous loading | Addressables | 1.21.21 it’s our documentation on WaitForCompletion and can show some of the known issues with using that API.
This exact issue isn’t known, but we have seen similar issues when calling WaitForCompletion and some other Addressable APIs as part of a callback. I think your combination of callback + Start() + WaitForCompletion() is probably causing some hang up on either our side, or the engine level load code.
Something you might try is actually setting some flag as part of the OnComplete of your LoadAssetAsync() call that you’re calling in Start(). Once that flag, or whatever, is set, continue your script like normal. It’s not going to be 100% synchronous, but it should resolve the deadlock. In order to get a “closer-to-sync” behavior, make sure all your Asset Bundles are local to the device. I assume they probably are since you’re testing your game, but I just wanted to call that out. You can use DownloadDependenciesAsync to make sure everything is local/cached beforehand.
Even if your Bundles are locally built to device, you might still want to call DownloadDependenciesAsync if you’re on Android, because Bundle caching can help speed up performance on that platform in particular.
Thanks for the prompt response, in our asset groups config I as per-Unity best practices for Addressables, I set each group to use UnityWebRequest, all groups are local, I indeed observed a smoother experience.
Would you recommend running DownloadDependenciesAsync() always at startup?