Problems with WebGL Build

Discussion and help for Easy Save 3
Post Reply
vikramapilla
Posts: 8
Joined: Thu Mar 03, 2022 8:16 pm

Problems with WebGL Build

Post by vikramapilla »

Hi Joel,

recently I have been facing some issues with using the ES3 system on WebGL.

1. Where is the data stored on WebGL when the storage type is "Cache"?

2. What is the max data ES3 can save on WebGL?

3. Does ES3 tend to be slower on development build, with exception settings as "Throw Exceptions Only"?
I ask this because, on my editor, the saving time for 70 objects takes 3 seconds whereas on WebGL it is 7.5 seconds for the same number of objects.

4. On my editor saving and loading works fine, however, on WebGL, there seems to be some exception. Do you know what could have caused the issue?

Image


Best Regards
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problems with WebGL Build

Post by Joel »

Hi there,

By default data is stored in PlayerPrefs on WebGL when you call ES3.StoreCachedFile.

The limit that you can save in WebGL is defined by the browser, so the limit may differ for different platforms. Generally 2MB tends to be the size they allocate.

Regarding performance, Development mode is inherently going to be slower because debugging is happening (though as this is defined by Unity, I recommend asking them if you want more detail on why). However, this will not be the only reason for a performance difference and it's likely that there are other factors. For example, WebGL working within a security sandbox. I would also check that you've not got any old data in your WebGL build which might be bloating your save file (you can delete your save data using ES3.DeleteFile, or clear PlayerPrefs entirely using PlayerPrefs.DeleteAll()).

For further information on improving performance, please see the Improving Performance guide:
https://docs.moodkie.com/easy-save-3/es ... rformance/

We're not aware of "WebGL Save System" which is mentioned in the error, and doesn't seem to be related to us. I recommend contacting Unity to see whether this relates to them, and also ensure that exceptions are enabled so you can see what exception is being thrown to cause the error.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
vikramapilla
Posts: 8
Joined: Thu Mar 03, 2022 8:16 pm

Re: Problems with WebGL Build

Post by vikramapilla »

Thanks for your answers.

I can confirm that the exception is caused by ES3 because when I make a release WebGL build with disabled exceptions and without the ES3 system, the scene runs fine without any errors. As soon as I add ES3 to the scene, and build it again to run, the scene doesn't load, an error is thrown.

Could it be possible that the references have something to do with it? My scene has almost 15000+ references.
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problems with WebGL Build

Post by Joel »

Hi there,

In this case it will be an error thrown by PlayerPrefs and something related with Unity’s internal classes. As PlayerPrefs is part of their functionality, I recommend sending a bug report to them for further information.

However, I strongly recommend enabling exceptions so that you can see what the error is. For example, PlayerPrefs will throw a PlayerPrefsException if WebGL has run out of storage space. Without exceptions you cannot detect this.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
vikramapilla
Posts: 8
Joined: Thu Mar 03, 2022 8:16 pm

Re: Problems with WebGL Build

Post by vikramapilla »

Hello Joel, I am still unsure if it is a Unity error or ES3's.

When I enable exceptions for the WebGL build, my scene works absolutely fine without any errors on the console. However, if I set the exceptions to "None" in Publishing Settings, and run the scene on the browser - there are errors on the console as soon as I activate ES3 either through Save or Load.

Hence, I created a sample project for your to reproduce this. Could you please check it out at your end once?

Project Link: URL deleted

Background: I have two scenes - "InputScene" and "SampleScene". The "InputScene" has a slider which takes input for how many prefabs to spawn in the "SampleScene". By default, the spawning size is 10 and when the "Load" button is pressed in "InputScene", "Sample Scene" is loaded with the instantiated prefabs. Then, in the "SampleScene", the user can save, load or delete the prefabs via ES3.

Input Scene
Image

Sample Scene
Image

Error Reproduction Steps
  • Create an empty Unity project and copy the folders Assets, Project Settings, and Packages in the Project folder
  • Add the scenes "Input Scene" and "Sample Scene" from the folder "Assets/Save System/Scenes" to the build settings
  • Build the scene once with exceptions enabled (Build 1) enabled and then another with exceptions set to "None" (Build 2)
  • Run "Build 1", there should be no errors on the console when the save button is pressed in the "Sample Scene"
  • Run "Build 2", there should be errors on the console when the save button is pressed in the "Sample Scene"
User avatar
Joel
Moodkie Staff
Posts: 4826
Joined: Wed Nov 07, 2012 10:32 pm

Re: Problems with WebGL Build

Post by Joel »

Thanks for sending this over, I deleted the link from your post as it contained the Easy Save package, allowing anyone to download it. In the future if you could private message links to projects that would be greatly appreciated.

I've managed to replicate the issue from this and appears to be a bug at Unity's end. Their assembly list is returning assemblies which aren't actually referenced by the project (in this case, the Cinemachine assembly), so won't actually be included in the build. We rely on this list to know which assemblies to look for ES3Types in at runtime. This is fine when exceptions are enabled because we can just catch the error when an assembly is absent. However, when exceptions are disabled we're unable to catch this exception so it fails.

I'll report this bug to Unity. In the meantime if you private message me your invoice number I'll send over a workaround for this issue.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply