Directory.Exists in AddressablesFileEnumeration takes long time when starting play mode

Hello!

We have a pretty large dataset in addressable. When entering play mode, the method ExtractAddressablePaths in AddressablesFileEnumeration.cs creats over 100MB garbage and takes multiple seconds at the Directory.Exists call.
In fact the cause is the large dataset. But exchanging the Directory.Exists call with AssetDatabase.IsValidFolder improves this process a lot resulting in a much faster switch to play mode.

Maybe this is an easy improvement you could at to the next version of addressables after checking that this is a valid change.

Similarly, we are also having performance issues with one of our Addressable Groups.

This particular one contains 50 or so addressable folders as follows :

6515647--734608--upload_2020-11-12_9-52-27.png

While it would take 10 to 20 seconds before, it now takes a whooping 4 minutes to process the group (either when entering play mode with a custom build script (sync addressables), or just when trying to inspect the group in the Addressables Group window). Most of the processing time seems to be spent in AddressablesFileEnumeration.EnumerateAddressableFolder when the build script calls GatherAllAssets for each entry.

We were considering using the AddressablesFileEnumerationCache but cannot since it’s an internal class.

The issue appeared when upgrading from 1.11 to 1.13.

Update:

I really hate doing this, but it decreases our loading time from 5 min 30sec, to 30 sec…
@davidla_unity is there a proper way to replicate this behavior without having to hack into the internal addressable classes?

string absolutePath = System.IO.Path.Combine(Application.dataPath, "../Library/ScriptAssemblies/Unity.Addressables.Editor.dll");
Assembly ass = Assembly.LoadFile(absolutePath);
Type asmType = ass.GetType("UnityEditor.AddressableAssets.Settings.AddressablesFileEnumeration");
MethodInfo begin = asmType.GetMethod("BeginPrecomputedEnumerationSession", BindingFlags.NonPublic | BindingFlags.Static);
MethodInfo end = asmType.GetMethod("EndPrecomputedEnumerationSession", BindingFlags.NonPublic | BindingFlags.Static);
object[] parameters = new object[] { aaSettings, true, null };

begin.Invoke(null, parameters);
var errorString = ProcessAllGroups(aaContext);
end.Invoke(null, null);

This code sample is used in our custom BuildScript (derived from SyncAddressables).

Happy to kick this to the team for some insight. Which version of Addressables is being used?

Thanks! We are currently using version 1.13.1.

We are using Addressables 1.16.1, if this is from any interest :slight_smile:
Forget to mention it.

Thanks! Spoke with the team, and they advised to update to 1.16.4 when it releases as it should be fixed in that version.

1 Like