Constant crash when changing Scene - WaitForCurrentOperationAsyncOperationBase

Hello,

I am encountering a really blocking bug that makes my whole editor crash when I am changing a scene, not the first time but 100% the next times.

I am forced to force quit Unity using the Windows Task Manager and in 15 sec time I have an Editor.Log filled with more than 300 000 references to WaitForCurrentOperationAsyncOperationBase.cs, from the Localization Plugin, which I have the last version.

I absolutely need to find a way to fix this bug fix or at least find a workaround because I just cannot work as long as it is here. And the most mysterious thing is that it appeared without any specific reason because I use the package for multiple months and wasn’t working on it before having the crash.

I hope I can find help here because I tried everything I found online about Localization or Addressables.
The issue seems to happen during the “Awake” event, I tried to disable everything I had that could happen before it in the logs but without any results.

Just one element make me think that it could be my own code issue is that it only happens in one scene, “Start_CharaSelection” but it is a really simple scene with few elements and the scene opens perfectly fine when directly opened inside the editor.

Here is 3 crash log I encountered during my tests :
CrashLogLocalisation.zip (8.4 MB)

The Logs are filled with this block :

(Filename: ./Library/PackageCache/com.unity.localization@1.5.3/Runtime/Operations/WaitForCurrentOperationAsyncOperationBase.cs Line: 20)

Calling WaitForCompletion on an operation that is already waiting.
UnityEngine.StackTraceUtility:ExtractStackTrace ()
UnityEngine.DebugLogHandler:LogFormat (UnityEngine.LogType,UnityEngine.Object,string,object[])
UnityEngine.Logger:Log (UnityEngine.LogType,object)
UnityEngine.Debug:Assert (bool,string)
UnityEngine.Localization.Operations.WaitForCurrentOperationAsyncOperationBase`1<UnityEngine.Localization.Tables.StringTable>:InvokeWaitForCompletion () (at ./Library/PackageCache/com.unity.localization@1.5.3/Runtime/Operations/WaitForCurrentOperationAsyncOperationBase.cs:20)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1<UnityEngine.Localization.Tables.StringTable>:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:174)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:607)
UnityEngine.Localization.Operations.WaitForCurrentOperationAsyncOperationBase`1<UnityEngine.Localization.Settings.LocalizedDatabase`2/TableEntryResult<UnityEngine.Localization.Tables.StringTable, UnityEngine.Localization.Tables.StringTableEntry>>:InvokeWaitForCompletion () (at ./Library/PackageCache/com.unity.localization@1.5.3/Runtime/Operations/WaitForCurrentOperationAsyncOperationBase.cs:32)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1<UnityEngine.Localization.Settings.LocalizedDatabase`2/TableEntryResult<UnityEngine.Localization.Tables.StringTable, UnityEngine.Localization.Tables.StringTableEntry>>:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:174)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:607)
UnityEngine.Localization.Operations.WaitForCurrentOperationAsyncOperationBase`1<string>:InvokeWaitForCompletion () (at ./Library/PackageCache/com.unity.localization@1.5.3/Runtime/Operations/WaitForCurrentOperationAsyncOperationBase.cs:32)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1<string>:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:174)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<string>:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:195)
MindVenture.Intro.QuestionAnswerData:OnValidate () (at Assets/Scripts/Narration/Intro/QuestionAnswerData.cs:37)
UnityEngine.ResourceManagement.ResourceProviders.AssetDatabaseProvider:LoadAssetAtPath (string,UnityEngine.ResourceManagement.ResourceProviders.ProvideHandle) (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/ResourceProviders/AssetDatabaseProvider.cs:41)
UnityEngine.ResourceManagement.ResourceProviders.AssetDatabaseProvider/InternalOp:LoadImmediate () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/ResourceProviders/AssetDatabaseProvider.cs:110)
UnityEngine.ResourceManagement.ResourceProviders.AssetDatabaseProvider/InternalOp:WaitForCompletionHandler () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/ResourceProviders/AssetDatabaseProvider.cs:90)
UnityEngine.ResourceManagement.AsyncOperations.ProviderOperation`1<UnityEngine.Localization.Tables.StringTable>:InvokeWaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/ProviderOperation.cs:81)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1<UnityEngine.Localization.Tables.StringTable>:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:174)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:607)
UnityEngine.Localization.Operations.WaitForCurrentOperationAsyncOperationBase`1<UnityEngine.Localization.Tables.StringTable>:InvokeWaitForCompletion () (at ./Library/PackageCache/com.unity.localization@1.5.3/Runtime/Operations/WaitForCurrentOperationAsyncOperationBase.cs:51)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1<UnityEngine.Localization.Tables.StringTable>:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:174)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:607)
UnityEngine.Localization.Operations.WaitForCurrentOperationAsyncOperationBase`1<UnityEngine.Localization.Settings.LocalizedDatabase`2/TableEntryResult<UnityEngine.Localization.Tables.StringTable, UnityEngine.Localization.Tables.StringTableEntry>>:InvokeWaitForCompletion () (at ./Library/PackageCache/com.unity.localization@1.5.3/Runtime/Operations/WaitForCurrentOperationAsyncOperationBase.cs:32)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1<UnityEngine.Localization.Settings.LocalizedDatabase`2/TableEntryResult<UnityEngine.Localization.Tables.StringTable, UnityEngine.Localization.Tables.StringTableEntry>>:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:174)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:607)
UnityEngine.Localization.Operations.WaitForCurrentOperationAsyncOperationBase`1<string>:InvokeWaitForCompletion () (at ./Library/PackageCache/com.unity.localization@1.5.3/Runtime/Operations/WaitForCurrentOperationAsyncOperationBase.cs:32)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationBase`1<string>:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationBase.cs:174)
UnityEngine.ResourceManagement.AsyncOperations.AsyncOperationHandle`1<string>:WaitForCompletion () (at ./Library/PackageCache/com.unity.addressables@1.22.2/Runtime/ResourceManager/AsyncOperations/AsyncOperationHandle.cs:195)
MindVenture.Intro.QuestionAnswerData:OnValidate () (at Assets/Scripts/Narration/Intro/QuestionAnswerData.cs:37)

Thank you a lot for your time

It looks like you are trying to load localization data inside of OnValidate which then triggers the same method again. Its hard to say much more without seeing that method but I suspect you have some sort of recursion going on thats not stopping.

Can you share some of the code so I can better understand whats going on?
The QuestionAnswerData class would be a good start :slight_smile:

Oh in deed it feels so obvious now thank you so much! I didn’t know why I didn’t stopped on that last line of the repeating log!


        private void OnValidate()
        {
            localizedQuestion = new LocalizedString("IntroQNA", "Q" + index.ToString(Intro_Questions.FORMAT_STYLE));

            var operation = localizedQuestion.GetLocalizedStringAsync();
            operation.WaitForCompletion(); // Force synchronous loading
            questionLocalized = operation.Result;

            for (int i = 0; i < answerArray.Length; i++)
            {
                answerArray[i].Refresh(index, i);
            }
        }

Here is the code I was using, it is actually just a OnValidate to try to visualize the result for me in the editor and I remember it wasn’t working outside of PlayMode, so I can fully remove this code.

Maybe you know a better way to do this if I want to preview like this the result of multiple LocalizedString assembled together. At least I won’t execute this code if Application.isPlaying.

It is such a mystery why I have this issue now when I did this code 6 months ago, why it is only appearing the second time I am loading this scene ?

Everything seems to works fine now,
Thank you so much for your quick help!

Im not sure why its doing that. What is on line 37 of QuestionAnswerData?

Line 37 is this line :
var operation = localizedQuestion.GetLocalizedStringAsync();
localizedQuestion being of type LocalizedString

Its something to do with operation.WaitForCompletion(); but im not really sure why its causing the multiple loading.
Are you able to share your project so I can take a closer look?

This being part of a 5 years long project I am not really sure how to share this, I tried to look at UnityPackage export but if I include the Dependencies it is just checking a huge part of my code not related to this scene.
I can export to you the major files used in my intro scene + the localization table if it’s enough ?
I would also prefer to do it with a google-drive shared only to your email if possible.

Thank you for your help!

Are you able to reproduce the same issues in a smaller project? If so then that would be ideal to share or you can give me instructions on how to reproduce it myself.

I tried for hours to reproduce a similar setup in a small project without encountering the crash, I have no idea what is activating this “OnValidate” recursion on my Scriptable object at the moment where the scene is loading. The interaction seems very strange.

I also tried with Odin since I have it on my project. I don’t know what to do more.
At least thank you a lot for solving this issue for me, I hope other people won’t have it.

1 Like