The code is as followsi. It hangs and crashes the app sometimes. The performance trace shows CPU usage > 95% on Oculus Quest 2. This proves that " LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[index]" is the one causing the hang. Why is this so CPU intensive? Is there a way to speed it up?
if (boLocalizationTableLoaded == false)
StartCoroutine(setLanguage(index));
else
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[index];
public IEnumerator setLanguage(int index) {
// Wait for the localization system to initialize, loading Locales, preloading, etc.
yield return LocalizationSettings.InitializationOperation;
boLocalizationTableLoaded = true;
// This variable selects the language. For example, if in the table your first language is English then 0 = English. If the second language in the table is Russian then 1 = Russian etc.
// This part changes the language
LocalizationSettings.SelectedLocale = LocalizationSettings.AvailableLocales.Locales[index];
}
This is likely from the initialization operation. It needs to load all the locales and any tables that are marked as preload.
When you change the selected locale it needs to unload the previous language and then initialize for the new one, so preload all the new tables.
Do you have initialize-synchronously enabled? This could cause the performance issues you describe.
Is this happening every time or just when you change the language? Do you do this at the start to set your start language?
I do this at start to set my language and every time the language is changed. Initialize-synchronously is unchecked in localization settings. The preload button is somehow missing in localization table window so I couldn’t mark the table as preload. My localization version is 1.0.5. Shouldn’t the preload button be to the right of this window? I don’t have an asset table just a string table.
It’s just a performance issue on Oculus. It works perfectly fine on PC VR through Oculus Link. I have 27 languages and each languages text file is ~20KB. Is there a way to break up the text files so it doesn’t need to load everything in one shot? For example, I could break up the text files
by menu tab.
I had a similar problem.
When players changed their language during runtime everything worked perfectly fine, but when they changed the language to not be the default (en), the game would crash.
Through testing i found out, that setting the selected locale from the Awake() will crash my builds. When shifting the code to the Start() method, it works perfectly fine.
Note that the selected locale would print out as valid to the logs from the awake method.
And when the game would crash this way, the game would not produce any error logs.
(This was a nightmare to debug, I thought it would have sth to do with other settings like aspect ratio that players also adjusted when they reported the bug)
I didn’t, I haven’t found that yet. Thanks, for the reply!
Also, I thought I would only need to worry about the initialization on the game start. The Game has a self-made intro scene that takes about 6 seconds to complete, and loads the Localization after that in the main menu scene.
Is the Localization initialized newly each time a new scene gets loaded?
If localization has not been used yet then there’s a chance it may have not been Initialized. We had a bug a few versions ago where initialization was not starting straight away. The safest thing to do would be to force it or yield wait for it. It may be working for you now in Start but there’s always a possibility that at some point it will stop working if it takes a little longer to load.
So to be safe add a check on the initialization operation for this bit of code. Most parts don’t need it but for AvailableLocales it is needed.