Reentering the Update method is not allowed

Hi,
I have added the Localization package to replace my old SmartLocalization asset and it is good, but it often causes this exception. It generally happens after I load an Addressable prefab. I can work without issue for a few minutes, but once it starts, it keeps happening.
Any way around it ? I have an urgent update to release and it can’t wait. Thanks

Exception: Reentering the Update method is not allowed.  This can happen when calling WaitForCompletion on an operation while inside of a callback.
UnityEngine.ResourceManagement.ResourceManager.Update (System.Single unscaledDeltaTime) (at Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/ResourceManager.cs:1080)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject].WaitForCompletion () (at Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:200)
UnityEngine.Localization.Settings.LocalizedStringDatabase.GetLocalizedString (UnityEngine.Localization.Tables.TableReference tableReference, UnityEngine.Localization.Tables.TableEntryReference tableEntryReference, System.Collections.Generic.IList`1[T] arguments, UnityEngine.Localization.Locale locale, UnityEngine.Localization.Settings.FallbackBehavior fallbackBehavior) (at Library/PackageCache/com.unity.localization@1.3.2/Runtime/Settings/Database/LocalizedStringDatabase.cs:241)
UnityEngine.Localization.Settings.LocalizedStringDatabase.GetLocalizedString (UnityEngine.Localization.Tables.TableReference tableReference, UnityEngine.Localization.Tables.TableEntryReference tableEntryReference, UnityEngine.Localization.Locale locale, UnityEngine.Localization.Settings.FallbackBehavior fallbackBehavior, System.Object[] arguments) (at Library/PackageCache/com.unity.localization@1.3.2/Runtime/Settings/Database/LocalizedStringDatabase.cs:189)
Langues.t (System.String s) (at Assets/Scripts/Managers/Langues.cs:34)
AncientGames.Market2.SetupColumn () (at Assets/Scripts/Menus/Market2.cs:92)
AncientGames.Market2.UpdateAll (UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1[TObject] op) (at Assets/Scripts/Menus/Market2.cs:69)
DelegateList`1[T].Invoke (T res) (at Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/Util/DelegateList.cs:69)
UnityEngine.Debug:LogException(Exception)
DelegateList`1:Invoke(AsyncOperationHandle`1) (at Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/Util/DelegateList.cs:73)
UnityEngine.ResourceManagement.ResourceManager:Update(Single)
MonoBehaviourCallbackHooks:Update() (at Library/PackageCache/com.unity.addressables@1.19.19/Runtime/ResourceManager/Util/MonoBehaviourCallbackHooks.cs:26)

It looks like you are calling localization UnityEngine.Localization.Settings.LocalizedStringDatabase.GetLocalizedString from an addressable callback. Likely a Completed one. Addressables does not allow this when another callback occurs inside the callback. This is what is happening here, localization is using addressable callbacks internally.
Can you defer the call so it’s not inside the callback? Maybe use a co routine instead?
Alternatively use preloading so the table is already loaded and we wont need to use any callbacks

Thanks for the quick reply.
I have tested putting the call in a coroutine and it seems to work for this prefab. I’ll try to hunt down all the other ones now.
Thanks a lot.

1 Like