Performance hits when updating from google

1 year 2 months ago - 1 year 2 months ago #3355 by abuki

I would like to know what is the best practice for updating localization from google.
I was doing that during scene load so some frame drop could be barely visible. But now I can see, that I only start the update during loading and the download is finished when the scene is loaded already, and there is significant frame drop:

The auto-update could work for me too, but that means that this frame drop would be uncontrollably on the start of application?
Are there any options to have this spike under control? I mean by processing performance heavy methods on a specific time (e.g., scene loading) or reduce the performance load?
Last edit: 1 year 2 months ago by abuki.

Please Log in or Create an account to join the conversation.

1 year 2 months ago #3356 by Frank
LocalizeAll is the call that changes all the texts/sprites/sounds, etc to the correct localization.
The call itself is not very heavy, it just go to all the localized objects and apply the translation, however, depending on what you are localizing, it could have a performance impact as you point out.

For instance, if you are using Unity UI Texts, then, just by setting all the enabled labels in your texts to their translation, Unity has to get the text characters from the font and fit them into its internal font texture. The same if you are localizing sounds or prefabs. And if you are switching fonts, then they have to be loaded from disk, etc.
Unfortunately for Unity UI texts, there is no much that can be done, as Unity needs to query all the new characters in order to render them.

But you switch the timing:
If you are in a loading screen, then, before hiding the loading screen, manually call LocalizeAll, that way you get the hitch there and not as soon as the first Update is called.

Also, it maybe better to use TextMeshPro or a similar bitmap font asset that doesn't regenerate the font atlas at runtime.

Another thing, have you tried running with Deep Profile enabled to see which target is the one taking the longest. LocalizeAll will be calling some "Target" classes that do the actual setup. That will allow you to know if the issue is loading textures, fonts or when setting texts and having Unity regenerate the atlas.

Hope that helps,

Are you :-) Give I2L 5 stars!
Are you :-( Please lets us know how to improve it!
To get the betas as soon as they are ready, check this out

Please Log in or Create an account to join the conversation.

1 year 2 months ago #3357 by abuki
Thanks. I am not able to deep profile build, and in the editor, it behaves differently, probably the update is made during the scene load as scene loading is slower in the editor. Anyway, 99% of my localize components are on prefabs in resource folder - NONE of them is loaded in the scene — all of them using Text Mesh Pro (the old one, before Unity bought it). Just very few elements using UI Text and they are in a different scene.

Regarding timing - My current setup:
- start async scene load
- start google update (which is asynchronous)
- scene load finish
(this is where you suggest LocalizeAll call, but it does not prevent from calling that later again from coroutine)
- the scene is loaded, I can play the game
- I play the game for a few seconds
- performance hit appears as the game asynchronously finished google update

I discovered that the actual performance heavy method is Import_Google_Result(wwwText, eSpreadsheetUpdateMode.Replace, true); called from Import_Google_Coroutine
I think the problem is that I can update from Google asynchronously, but have no control when the game calls this method after downloading from the web. This is the bottleneck for me right now. Don't know if there might be some issues later, but as I said, all the Localize components are on prefabs in resource folder, so I think that should be ok. My ideal solution would be this - create the www call at the beginning of the game and let me decide when to integrate the result (calling Import_Google_Result), which I can do during loading when some hiccups won't be visible to the user.

Please Log in or Create an account to join the conversation.

1 year 2 months ago #3373 by abuki
Any tips on how to achieve something similar using current API? Or some tips to change the design to get rid of the hits?
Right now I am thinking of hacking this feature into the source code.

Please Log in or Create an account to join the conversation.

1 year 1 month ago #3430 by abuki
Hi Frank,

Thank you very much. The last update solved my issue. I am using update always with applying on scene load. Works perfectly as intended, I even removed my update code :).

Great work!

Please Log in or Create an account to join the conversation.

Time to create page: 0.215 seconds
Template by JoomlaShine