Loading simple prefab takes 2-3 seconds on Android

I’m currently testing my app on Android and noticed that some Prefabs (marked as Addressables) have very long loading times of 2-3 seconds per Prefab.

The Addressable Group the Prefabs are in has CRC disabled, compression set to LZ4 and the Bundle Mode as “Pack Separatly”.
“Contiguous Bundle” is also activated.

Is there a way to see why an Addressable loaded via LoadAssetAsync (or even InstantiateAsync) takes so long?
I already checked the Profiler, but can’t really see any options to see why loading times are so long.

Addressable version: 1.18.15
Unity version: 2020.3.17f1

Any help, hints and/or tips are greatly appreciated!

Have you tried to enable the Contiguous Bundles setting found in the AddressableAssetSettings file?

7489199--921857--upload_2021-9-12_7-14-56.png

For some reason turning on that option causes this issue in my game, at least in iOS. They load instantly when I turn the setting off.

Loading Async will likely not show up in the CPU Profilers Hierarchy view when it’s set to main thread, as it’s hopping over some threads. You’ll probably want to look at this with Timeline view, checking out the loading threads and turning on Flow Event visualization.

Ah, I forgot to mention this! Yes, I had this already enabled.

@MartinTilo Thank you for the hint.

It shows that “Application.Preload Assets” and “Loading.Perform [Preloading assets]” are taking 1500-3000ms, which matches the loading times we see in our Android app.
The issue here is that we don’t see why this is happening. Shortly before displaying the loaded asset, even the Profiler freezes until the Prefab is displayed.

We reduced the Prefab for testing to only a 2D Image with no Sprite set, so there is nothing that should take a long time to load.

@MartinTilo We tested the Prefab with compression set to Uncompressed, and it seems this doesn’t make a difference compared to LZ4.

Does the profiler not show loading samples for individual items?

@MartinTilo Do you have a screenshot that shows where to find this?

It might be that some of the details in these screenshots are only there in +2021.2 versions where the instrumentation of the I/O samples was improved along with the addition of the Asset Loading and the File Access Profiler Modules (and some of their content also got an update with the improvement of timeline tool tip time summaries and the samples selection UX), but iirc some File.Read MetaData (such as the file name) and the flow events for Async loading should be there in 2020.3 already.





@MartinTilo After looking for these details, I noticed that the huge loading delay was caused by an AudioClip being loaded in the background at the same time. As soon as the AudioClip was loaded, the “troublesome” Prefab loaded without issues.

Is there a way to load the AudioClip (also an Addressable) at the same time or with lower priority than other Addressables?

I’d say if the audio clip isn’t referenced from the prefab, it should probably be possible. I just have too little info about how and what you’re loading.

@MartinTilo When the Scene starts, I load the AudioClip via
await Addressables.LoadAssetAsync(“Sounds/BGM/bgmName.wav”);

When I then tap on a UI button to open a menu (the Prefab that had issues loading), I’m calling from another script
var prefab = await Addressables.LoadAssetAsync(menuAssetReference);
Instantiate(prefab, transform);

The AudioClip and the Prefab are unrelated from each other. Loading times for the AudioClip are around 2-3 seconds (which is expected for a BGM?).

Hmm, I’m not too firm on addressables but from a cursory glance at the API docs, I couldn’t see a way to prioritize these requests. So it looks like you might have to prioritize them by how you order the LoadAssetAsync requests…

Can you isolate it in a new project to reproduce the problem? Then you could upload it and people can take a look what the issue might be.

@Peter77 Tbh it sounds to me like the async loading pipeline ist just a regular FIFO queue without prioritization so if the audio was scheduled for loading first, it’ll hold up loading requests that come up after it.

1 Like