juniordiscart / com.unity.addressables

Addressables extended with the ability to build multiple catalogs, ideal for traditional DLC purposes.
https://docs.unity3d.com/Packages/com.unity.addressables@1.17/manual/index.html
Other
76 stars 23 forks source link

IndexOutOfRange exception when building bundles #3

Closed rene-hinterland closed 1 year ago

rene-hinterland commented 2 years ago

Hi!

We've been trying to use this library to build DLC and have hit a weird issue. When building some specific groups, we get an IndexOutOfRange exception in ContentCatalogData. More specifically this line: var deps = entry.Dependencies.Select(d => keyIndexToEntries[d][0]).ToList();

I can't give a lot of information, but we added some logging and it seems that a specific bundle (with some scriptable objects in it) has an empty list, which from reading the code seems like very unintended behaviour. We're only experiencing this when using this library and not when using the standard library.

Is this something you've encountered?

rene-hinterland commented 2 years ago

Been trying to create a small repro project, but with no luck. For now, we've modified:

var deps = entry.Dependencies.Select(d => keyIndexToEntries[d][0]).ToList();

to be:

var deps = new List<ContentCatalogDataEntry>(64);
foreach (var d in entry.Dependencies) {
    List<ContentCatalogDataEntry> catalogDataEntries = keyIndexToEntries[d];
    if (catalogDataEntries == null || catalogDataEntries.Count <= 0) {
        continue;
    }
    deps.Add(catalogDataEntries[0]);
}

It's not the nicest and it feels like it's just hiding a symptom instead of fixing the root cause

nofilenamed commented 2 years ago

Give a look at ExternalCatalogSetup.cs

Try to change line 66:

return assetGroups.Exists(ag => ag.entries.Any(e => (e.IsFolder && e.SubAssets.Any(a => loc.Keys.Contains(a.guid))) || oc.Keys.Contains(e.guid)));

to:

return m_AssetGroups.Exists(ag => ag.entries.Any(e => (e.IsFolder && e.SubAssets.Any(a => loc.Keys.Contains(a.address))) || loc.Keys.Contains(e.address))); //don't use guid

This could fix the problem, that some keys appears inside the main catalogs, and prevents the issues with dependencies.

juniordiscart commented 1 year ago

Oh, I only just discovered this topic now... Sorry for the late response.

I haven't ran into such an issue myself yet, and I can't reproduce. The ContentCatalogData comes from the vanilla Addressables implementation though, so I'm a little hesitant to touch it without knowing what is going on or what the trigger might be.

Did you find something to reproduce the issue? Perhaps it is fed incomplete information due to dependency calculation, but without knowing for sure, I'm gonna keep it like it is for now.

juniordiscart commented 1 year ago

I think this issue got resolved in #4 .

Scheshi commented 1 year ago

This is still being caught on the version from 06/28/2023 @juniordiscart