Forced to loose a frame every time Addressables.LoadAsset is called

I’ve noticed that by calling Addressables.LoadAsset there is ALWAYS at least one frame delay before the loadTask completes even if the asset is stored locally, further more the Task seems to be updated by the main thread so there is no parallelism going on there and there!
I get that the call is meant to be asynchronous but shouldn’t the returned Task at least be updated on a parallel thread so we programmers can choose to wait for that Task to finish if we want to provide synchronous loads?
At the very least I shouldn’t be forced to loose a frame every time I want to load an asset…
Is there any plan to fix this?

Thank you!

1 Like

As to operating on another thread, we’ve looked into it, but it’s not doable for many of the engine systems we’re building on top of. We intend to look into it more to investigate.

One of the key issues is that all the providers are using Async interfaces. If you wanted to trick addressables into being sync, you actually need to replace the providers, not just wait for the existing ones. We just posted a sample of doing that here: GitHub - Unity-Technologies/Addressables-Sample: Demo project using Addressables package

Thank you unity_bill! Hope you guys find a way to resolve the 1 frame delay… If I read correctly the Synch trick doesn’t currently work for all modes and all platform so I’m not going to be using it in the end… but good to know it is somehow possible.

1 Like

Any news about this?

You can wrap the system in your own asset manager, hold the references to already loaded objects, then when you request that asset, return Task.FromResult(obj). I do exactly that in my project (though I use promises instead of Tasks, but that’s a moot point).

Yeah but that way the first time you load an object is always going to be asynchronous, right?

Yes. If you want synchronous, you will have to preload your assets and cache them somewhere, then you can synchronously instantiate from that cache.

1 Like

Thanks for the info!

As of Addressable 1.19, there is AsyncOperationHandle.WaitForCompletion() that force the load request to complete in the same frame like Resouces.Load. Example:

var request = Addressables.LoadAssetAsync<Sprite>(path);
request.WaitForCompletion());
1 Like