Application freeze when syncing with spreadsheet

More
8 years 5 months ago - 8 years 5 months ago #1069 by jimmyt3d
Hi Frank,

My game is complete and I have got the spreadsheet on Google Drive, so I have now turned 'Auto Update Frequency' to 'Always' so that it updates with any changes.
However now the game freezes for about 50 seconds just after it has booted (presumably when it is syncing) is there any way of preventing this?
The build is PC standalone and I am still using 2.5.0 f1 due to my game being about to go out the door.
My spreadsheet has around 1300 Keys on it, so it is quite a big sheet.

Any suggestions?

Many thanks
Last edit: 8 years 5 months ago by jimmyt3d.

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

More
8 years 5 months ago #1071 by Frank
Hi,
Congrats on your game!
I haven't noticed that big delay, and will definitively test it out as soon as I get back.

Most of the times when synchronizing, the game take a couple seconds to recompute the font's texture if you are using dynamic fonts, but that should be it. And if all fonts are bitmaps, it's almost instantaneous.

Also, sync will only happen the first time it opens the game, and from that point on, only if there have been changes. Nonetheless, 50 seconds its way way too much. I will check that out and get back to you ASAP.

Thanks,
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

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

More
8 years 5 months ago #1072 by jimmyt3d
Hi Frank,

Thanks for your quick response. Some extra information - I have just turned my internet off and booted the game and the freeze still occurs without internet.
It is definitely something to do with the plugin as it only happens if I have 'Always' set, if it is set to 'Never' the freezing stops.
I have 6 keys on there that are sprite swaps depending on language (a particular set of buttons are swapped for another if a particular language is selected), but all other keys are just text, no dynamic fonts.

Many thanks

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

More
8 years 5 months ago - 8 years 5 months ago #1073 by jimmyt3d
A bit more info which might be helpful - after the freeze has occurred and the game resumes - if I click away from the application to another window, the game often crashes ("Filename.exe" has stopped responding") - this also only happens when the sync is set to 'Always'. I think I have got round this by setting 'Run in background' in the settings.

If I press PLAY within Unity itelf. the freeze occurs here also (completely freezing Unity), but lasts even longer, around 2 minutes. As soon as it resumes, the message 'Language Source was up-to-date with Google Spreadsheet' appears in the console.

I've narrowed down where the freeze occurs - it is as soon as it hits the first piece of text with the localize component on it, as soon as it tries to load the scene the freeze occurs.
Eg. I have 2 splash screens that appear initially, both of which have images and no text, then the title screen appears (which does have translated text) and the freeze occurs at the end of the second splash screen and it won't load the title screen until the freeze has finished.

So in short - the freeze is occurring as soon as the application tries to translate something when the updating is set to 'Always' - with or without an internet connection!

**UPDATE**

- I found out that the reason it was crashing when multi-tasking out of the application, was probably because it was performing a sync at this point (at the point mentioned below).

- I've also discovered that if a change has been made to the spreadsheet, it freezes up again once it hits the screen with any translated text.
- Make a change to the spreadsheet
- Boot the build
- It freezes on the screen/scene before the one with the first piece of text for 50 - 90 seconds (depending on machine)
- It then loads the next scene, then after 7 seconds it appears to perform the sync for the new text it has picked up from the spreadsheet and freezes for another 50-90 seconds.
- If you then reboot the application it will perform the first sync again, but then once it reaches the text screen it will not perform a second sync.

I have put a fake loading screen at the point of the first freeze to mask over the fact that it has frozen, but it's really not an ideal solution!
Last edit: 8 years 5 months ago by jimmyt3d.

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

More
8 years 5 months ago #1074 by Frank
Hi,
I have been profiling the latest few hours trying to reproduce your issue and find a solution.
Found that on v2.5 there was a big lag. However, caused by a few things:

1- Dictionaries are not serialized by Unity, so, on startup I have to rebuild the dictionary from the list of terms.

2- Communication with google was using JSON and deserializing the JSON was not the most efficient/memory friendly approach

3- If a new version of the spreadsheet is found, then the resulting JSON is saved into PlayerPrefs and used from that point on, (even when disconnected as that's supposed to be the most up to date data), however, the dictionary was rebuilt twice if there was a JSON in the PlayerPrefs.


After that, I switched to 2.6.0 and most of those points are solved there. In 2.6, there were lot of improvements to the way the game syncs with google, no more JSON files and overall there is just a small lag when rebuilding the dictionary, but I tested with a language Source with 4000 terms and the delay was just 1.8 seconds on startup.

My advise its that you update to the latest version of the plugin. It will perform better and its way more stable. Here are instructions on how to safely update the plugin: inter-illusion.com/forum/i2-localization...-asked-questions#837
Also, when testing in the Editor, delete the PlayerPrefs values and before shipping, Import-Replace the latest spreadsheet.

Also, to solve the issue about the dictionary been rebuilt twice, please replace the function AddSource in the LocalizationManager.cs line 211-220 by this one:
		internal static void AddSource ( LanguageSource Source )
		{
			if (Sources.Contains (Source))
				return;

			Sources.Add( Source );
			Source.Import_Google();
			if (Source.mDictionary.Count==0)
				Source.UpdateDictionary();
		}

I'm including this change as well in v2.6.1

Another thing I noticed from the info you gave me (BTW: thanks for all the detail), one of the issues you mentioned looks a lot like dynamic fonts (sorry for reiterating that, haha).
If the lag happens when displaying the text, then it means that the font texture is recreated. Unless you are using TextMesh Pro or NGUI and building yourself the texture with all the characters, having different font sizes and styles will hurt performance. The new Unity UI doesn't have the best support for bitmap fonts, so by default it uses dynamic ones.

To rule out that's the case, can you please, remove all Labels from your loading screen (just place a localized image/sprite).
If the issue its dynamic fonts, then the loading screen will show no lag, and the lag will happen when loading the second screen.

Hope that helps, And please, if after upgrading to 2.6 and making the suggested change you still find a lot of lag. It will help, if you could create a repro project that I could test, I'm prioritizing helping you release your game without lag. So, feel free to email the repro project.

Thanks,
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

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

More
8 years 5 months ago - 8 years 5 months ago #1076 by jimmyt3d
Hi Frank,

Thank you very much for your support, it's much appreciated!

I worked in games QA for 8 years so I know how to write bug reports ;)

Regarding the Dynamic text, I originally misunderstood what you meant by this term, but from what you have since said - yes it seems I am using it after all, all my translated text is - 'Target - UGUI Text', and as soon as it hits a scene with one of these in, it freezes to sync.
It seems that if it does an inital sync and then picks up a change and updates, this update occurs 7 seconds after hitting a screen with the text on (after the initial freeze/sync), then it will freeze for this period, if the screen is triggered to load another scene in less time than this then it will delay this update til the next screen.
In my instance, the screen it ends up doing it on is the Title screen which is obviously a no-no as it has password input etc on this screen.
So I input a fake loading screen with a 10 second delay before the title screen and after the original sync, but this means there is a 10 second wait even if it is not doing anything. Unfortunately my client would like it to only delay if there is something to update and they do not want loading screens where they are not necessary.

So I guess my only solution is to update to the latest version of the plugin, however I am very worried that something may go wrong, my deadline is tomorrow morning (9am GMT) so if I were to lose all my translations now it would be very bad news.
Syncing the current version with the online spreadsheet works perfectly - importing and exporting.
If I delete the plugin and install the new one, it should just import the new spreadsheet ok and everything will match back up?
Is there a way of restoring the old plugin if anything goes wrong?

*EDIT*

3- If a new version of the spreadsheet is found, then the resulting JSON is saved into PlayerPrefs and used from that point on, (even when disconnected as that's supposed to be the most up to date data), however, the dictionary was rebuilt twice if there was a JSON in the PlayerPrefs.


Does this mean in 2.6 that any previous changes will not be remembered if booting without internet? This is quite an important feature as the password to load the app is controlled from the spreadsheet.

Many thanks
Last edit: 8 years 5 months ago by jimmyt3d.

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

Time to create page: 0.174 seconds
Template by JoomlaShine