Application freeze when syncing with spreadsheet

More
8 years 6 months ago #1077 by Frank
Hi,
All the localization data is stored in the i2Language.prefab. To avoid losing the data it contains, export it into CSV or to a Google Spreadsheet. Then you will be fine to delete and install the new version.
Its a good idea to also make a copy of the I2 folder. If for some reason, you need to go back to the previous version, you should just copy the I2 folder back to the original location and everything will work normally.

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.


No, the downloaded data will still be saved into PlayerPrefs. But its now using a custom format, not JSON. Parsing this format its far faster/memory efficient than dealing with all the JSON structure, so it loads faster.
Problem before, was that it was building the dictionary on Awake, then getting the data from the PlayerPrefs JSON, parsing it and creating the list term, then redoing the dictionary. And if after contacting google, there was a newer spreadsheet, then the process was repeated for the downloaded data.

Now, it only rebuilds the dictionary once (either from the original data or the PlayerPrefs data) and parsing the saved data its faster than parsing the JSON. So its quite a lot of performance gain.

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.



Dynamic fonts are great, but they create a lot of lag, especially when switching to a language with different character's set or when you have lot of different font sizes.
Unity will be rebuilding the font's texture as it encounters more texts/font sizes, and that could make the texture to regenerate several times.

The ideal solution its to move out dynamic fonts altogether. Use Unity bitmap fonts, textMesh pro or anything similar. But that could be a problem for you if your deadline it tomorrow!

There are a few things I had used to decrease the lag caused by dynamic fonts.


For instance, you could create a script in your loading scene that for every font you use, calls Font.RequestCharactersInTexture with all the characters and sizes you are using. That will trigger only 1 texture rebuild instead of multiple ones as Unity finds more characters.

something like:
public void Awake()
{
      var Characters = ScriptLocalization.Get("UsedCharacters");

      Font.RequestCharactersInTexture(Characters, 14);   // one for every font size
      Font.RequestCharactersInTexture(Characters, 32); 
      //etc
}

Just make a term in your source containing all used characters in each language:
UsedCharacters = "abcde.......


Similarly, you can add a hidden text (behind your loading screen sprites) containing all the used characters. So that you don't have to do the script. That will trigger rebuilding the font texture only once as all the text its included in a single object.

Nonetheless, the approach that will give you a lag free solution its to move into bitmap fonts.

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

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

More
8 years 6 months ago - 8 years 6 months ago #1078 by jimmyt3d
Hi Frank,

Ok, so I made a brand new project and a couple of test scenes and put 2.6 into that (I wanted to test on a new project first before touching the main one, where I have not yet updated to 2.6).
The sync that occurs now takes about 2 seconds as you say, which is fantastic!
However, the problem I am having is that the translated piece of text keeps reverting back to the original piece of text after I have updated the spreadsheet.

- Made a build with the translation set to the word LOADING
- Edited the spreadsheet to the word BOO
- Boot the app
- The screen with the text on loads instantly, but still has the original LOADING text, then after 8 seconds it pauses for 2 seconds and then carries on (still with the old text)
- Shut the app down and then run it again
- Now the text says BOO and there is no 2 second pause
- Now restart the app again - the word will have reverted back to LOADING, then the pause
- Then restart and it keeps doing the same thing over and over

I've uploaded a build for you to see it in action, follow the steps above and you will see what I mean - any thoughts on this?
There are 2 scenes to represent splash screens - one red, then one green with some text flying around and then another screen with the same piece of text.
The pause happens on the 3rd screen (with the empty password box).
drive.google.com/file/d/0B2uFyEE4UoHhQWY...QUE/view?usp=sharing (hosted on Google Drive).

Thanks!

Update - It seems that if the sync occurs on the green screen, then when the white screen loads, the text is updated, but if it hasn't synced by the time it loads the white screen, it will do it here instead. On my real project, this is where I have my password box that is controlled by the spreadsheet, so it needs to have synced before it gets to this screen - is there any way of forcing it to sync on the green screen instead of just hoping it will?
Last edit: 8 years 6 months ago by jimmyt3d.

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

More
8 years 6 months ago - 8 years 6 months ago #1079 by jimmyt3d
Hi Frank,

Another quick update, I've done another build with some different text on the green screen (instead of using the same string that was on the white one) and this has made a huge improvement to making it sync on this screen, it now always seems to do it on the green screen much more often. However if I turn my internet off and run it again, it reverts back to the original 'LOADING' and stays on this until I run it with internet again, then it returns to the latest one.
Here's a copy of the build for you to take a look at - drive.google.com/file/d/0B2uFyEE4UoHhZHZ...S00/view?usp=sharing

Thanks!

UPDATE -

Ok so I've now completely updated my main project to 2.6 and all is well, it initially kept downloading the spreadsheet as blank and removing everything from the source, but doing an export afterwards and then importing again sorted that out. - It may be worth adding that to your thread about safe updating? As if you exported by accident after it imported a blank sheet you could end up with a blank sheet and a blank source.

Putting the ABCD... etc letters hidden on the loading screens seems to work well at forcing the sync at this point, it's not the perfect solution but it's better than it was.
However the big problem is it losing the updated text if you turn the internet off, it appears that the saving to the player prefs is not happening, as the problem occurs 100%. As soon as you turn internet back on again, it syncs back up ok. Do you have any idea why this might be? This feature worked fine for me on 2.5.
As my password is set on the spreadsheet, this is going to cause problems with users who boot without an internet connection if the password has been changed since the build was made.

Thanks!

UPDATE

Ok now the player prefs is working fine and correctly recovering the last change if I am offline. Not sure why it wasn't before, every build I made had the problem, but the last 2 have been fine - could something have been preventing it saving? The only thing I did differently was that I did a fresh re-import of the spreadsheet before making the build, after this, the first attempt at the offline test failed, but then each attempt after it that (on the same build) worked fine.
Last edit: 8 years 6 months ago by jimmyt3d.

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

More
8 years 6 months ago #1081 by Frank

Ok now the player prefs is working fine and correctly recovering the last change if I am offline. Not sure why it wasn't before, every build I made had the problem, but the last 2 have been fine


Hi,
Its great that its working now!!

My bet about the builds not picking the PlayerPrefs correctly, its that the Key value remained the same, but the content saved in the PlayerPrefs changed (its not a JSON any longer).
So, maybe your devices had the previous downloaded data and they were unable to extract it correctly when only reading from the playerPrefs (offline) but was downloading and extracting correctly when connected. If at some later point, you changed the spreadsheet content, then the editor imported the new data and incremented the version number. So the PlayerPrefs was overridden, and the game was able to understand its content.

But again, Its great your project is working now!!

BTW, When you release your game, feel free to make a post in this forum about it, it could help with visibility and I will love to check it out!!!

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 #1089 by jimmyt3d
Hi Frank,

Yes all is working well, it does seem to occasionally not remember the updated data when offline, but works a high percentage of the time which is good.

Unfortunately the application isn't for release to the public, it is for my client's internal company use only. However they are currently working on a promotional video for it which will be released online and a 'public' version may be available too, when that happens I'll definitely stick a link on here so you can check it out!

I have another project in the pipeline, which will definitely be made public when finished and will definitely make use of your plugin :cheer:

Thanks again for all your help, your customer service has been outstanding!

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

Time to create page: 0.141 seconds
Template by JoomlaShine