In my game I am getting a StackOverflowException
whenever a locale with more than 1 fallback is initialized and the “Preload Selected Locale and Fallbacks” option is selected.
This can happen on startup or whenever the selected locale is changed, with the line
LocalizationSettings.SelectedLocale = locale;
If it helps for context, all of my locales have English as a fallback by default, but for some locales I have it fall back to a regional variant first, and this error appears with the ones with that setup. I’m using editor version 2022.3.17f1 and Localization version 1.5.2.
This isn’t a huge problem for me because my game works fine with just the “Preload Selected Locale” setting, but this seemed like a somewhat significant bug, so I wanted to point it out. Hope this can help get it resolved!
Full Error Log
StackOverflowException: The requested operation caused a stack overflow.
System.Collections.Generic.HashSet`1[T].Initialize (System.Int32 capacity) (at <2a397996daff412691ae4781443e8e88>:0)
System.Collections.Generic.HashSet`1[T].AddIfNotPresent (T value) (at <2a397996daff412691ae4781443e8e88>:0)
System.Collections.Generic.HashSet`1[T].Add (T item) (at <2a397996daff412691ae4781443e8e88>:0)
UnityEngine.Localization.Locale+<GetFallbacks>d__20.MoveNext () (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Locale.cs:302)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:87)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/PreloadDatabaseOperation.cs:90)
UnityEngine.Localization.Operations.PreloadDatabaseOperation`2[TTable,TEntry].GetAllFallbackLocales (UnityEngine.Localization.Locale current, System.Collections.Generic.HashSet`1[T] locales) (at ./Library/PackageCache/com.unity.localization@1.5.2/Runtime/Operations/Pr<message truncated>