Loading Bug (ES3JsonReader)

Discussion and help for Easy Save 3
Post Reply
ColdFire
Posts: 4
Joined: Wed Apr 10, 2024 2:46 pm

Loading Bug (ES3JsonReader)

Post by ColdFire »

Hi, I'm glad to have purchased Easy Save 3, this powerful plugin that adds saving functionality to my game. Now, I've encountered a tricky issue that needs to be resolved.
When using Easy Save 3, I save many different objects in the same file. In fact, I save an entire world block in a single file. Multiple saves of the same world block may be stored under the same key. When loading, sometimes the ES3JsonReader class throws an error: "Expected "{" or "null", found ".") causing the load to fail. It seems to occur when loading a specific component, indicating that the JSON data for that component is corrupted. The error appears randomly for objects that are not related to each other. I have even tried clearing the original key data before saving, but the error still occurs. What could be the cause of this issue and how can it be resolved? Thank you.
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading Bug (ES3JsonReader)

Post by Joel »

Hi there,

This error usually occurs if you're loading data as a System.Object in a context where the actual type of the object can't be established. However, it's not possible to know exactly why this is happening for you without more information.

I recommend making a copy of your project and removing everything from the scene where you're encountering the issue until you track down the specific object and Component triggering the error. You can then mark each field of that Component with an [ES3NonSerialized] attribute until you track down the specific field or property of that Component. Once you've done this, if you could send me the Component in question and let me know which field is causing the issue along with info on how this is being saved (i.e. is it being saved as part of a GameObject, or is it's Component being saved directly, and how are you saving and loading them) then I can hopefully provide more specific information.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
ColdFire
Posts: 4
Joined: Wed Apr 10, 2024 2:46 pm

Re: Loading Bug (ES3JsonReader)

Post by ColdFire »

Thank you for your advice, which confirmed me that the issue was caused by a specific component rather than random data corruption. I added some debug code to precisely locate the problem and finally managed to reproduce the bug consistently. I rely on the ES3GameObject to save custom components without creating an ES3UserType for each one. Before saving, I preprocess the entire world block, adding and setting the ES3GameObject for each GameObject. For a world block with about 30,000 objects, the preprocessing time is around 0.01 seconds, which is an acceptable performance loss. However, the preprocessing cannot be reapplied, meaning if the GameObject already has the ES3GameObject attached, it won't be processed again. That is, if some components of the GameObject are dynamically deleted in the game, the component list of ES3GameObject isn't updated in time and retains null values. This causes abnormal data during saving and throws a fatal error when loading. I changed the preprocessing to be reapplicable, updating the ES3GameObject based on the state before saving every time. The problem seems to be solved, but I still need some time to continue verifying it.
Thanks again, I've been using Easy Save 3 for several months now and find it very efficient and convenient. I've also accumulated quite a few questions and will look for an opportunity to consult you again. :D
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Loading Bug (ES3JsonReader)

Post by Joel »

Glad you've (hopefully) managed to resolve the issue :)

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