Search Issue Tracker

Fixed

Fixed in 1.19.19

Votes

0

Found in [Package]

1.19.18

Issue ID

ADDR-2521

Regression

No

Exception thrown when using AddressablesAssetPostProcessor.OnPostProcess.Register

Package: Addressables

-

We added AddressablesAssetPostProcessor.OnPostProcess.Register to the localization package:

{code:java}
[InitializeOnLoad]
class LocalizationAssetPostProcessor
{
static LocalizationAssetPostProcessor()
{ AddressablesAssetPostProcessor.OnPostProcess.Register(OnPostprocessAllAssets, 1000);
}
{code}

however when opening a project with no Library folder the following error is thrown:

{noformat}
InvalidOperationException: Collection was modified; enumeration operation may not execute.
System.Collections.Generic.SortedList`2+Enumerator[TKey,TValue].MoveNext () (at <ef151b6abb5d474cb2c1cb8906a8b5a4>:0)
UnityEditor.AddressableAssets.Settings.AddressableAssetUtility+SortedDelegate`4[T1,T2,T3,T4].Invoke (T1 arg1, T2 arg2, T3 arg3, T4 arg4) (at Library/PackageCache/com.unity.addressables@1.19.18/Editor/Settings/AddressableAssetUtility.cs:490)
UnityEditor.AddressableAssets.Settings.AddressablesAssetPostProcessor.OnPostprocessAllAssets (System.String[] importedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromAssetPaths) (at Library/PackageCache/com.unity.addressables@1.19.18/Editor/Settings/AddressableAssetPostProcessor.cs:15)
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at <eae584ce26bc40229c1b1aa476bfa589>:0)
UnityEditor.AssetPostprocessingInternal.InvokeMethod (System.Reflection.MethodInfo method, System.Object[] args) (at <4330b7b9ef6d4dd780b09ebcbf09fc68>:0)
UnityEditor.AssetPostprocessingInternal.PostprocessAllAssets (System.String[] importedAssets, System.String[] addedAssets, System.String[] deletedAssets, System.String[] movedAssets, System.String[] movedFromPathAssets) (at <4330b7b9ef6d4dd780b09ebcbf09fc68>:0)
{noformat}

To reproduce open the LocalizationTests project on this branch https://github.cds.internal.unity3d.com/unity/com.unity.localization/pull/388
Make sure you have no library folder.

I investigated the issue and found that its caused by us calling AddressableAssetSettingsDefaultObject:GetSettings in AddressablesAssetPostProcessor:OnPostprocessAllAssets.
More info in this thread https://unity.slack.com/archives/C8Z80RV4K/p1645189194229419

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.