Welcome, Guest
Username: Password: Remember me

TOPIC: Performance hits when updating from google

Performance hits when updating from google 1 month 1 week ago #3355

  • abuki
  • abuki's Avatar
  • Offline
  • New Member
  • Posts: 6
  • Karma: 0
Hello,

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 month 1 week ago by abuki.
The administrator has disabled public write access.

Performance hits when updating from google 1 month 1 week ago #3356

  • Frank
  • Frank's Avatar
  • Offline
  • Administrator
  • Posts: 1169
  • Thank you received: 253
  • Karma: 77
Hi,
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,
Frank
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
The administrator has disabled public write access.

Performance hits when updating from google 1 month 1 week ago #3357

  • abuki
  • abuki's Avatar
  • Offline
  • New Member
  • Posts: 6
  • Karma: 0
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.
The administrator has disabled public write access.

Performance hits when updating from google 1 month 6 days ago #3373

  • abuki
  • abuki's Avatar
  • Offline
  • New Member
  • Posts: 6
  • Karma: 0
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.
The administrator has disabled public write access.

Performance hits when updating from google 1 week 1 day ago #3430

  • abuki
  • abuki's Avatar
  • Offline
  • New Member
  • Posts: 6
  • Karma: 0
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!
The administrator has disabled public write access.
Time to create page: 0.092 seconds
Template by JoomlaShine