Lag when first time calling ES3.Save after play

Discussion and help for Easy Save 3
Post Reply
HoshinoArika
Posts: 5
Joined: Mon Aug 14, 2023 2:30 pm

Lag when first time calling ES3.Save after play

Post by HoshinoArika »

Hi!
I found after each time I enter play mode, the first time the ES3.Save is called is going to make the game frezze for a little bit of time, the later calls will not. I am calling the same method that will create a new directory and a new file (new folder and a new text file for a new save slot).

I tried calling ES3.Init() in Start(), but it didn't help;

Please help! Thanks!
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Lag when first time calling ES3.Save after play

Post by Joel »

Hi there,

We've had no reports of this. Please can you show me the code you are using, and also let me know if you've changed any settings.

Could you also use Unity's profiler to see exactly what code is causing the slowdown (I recommend using the Deep Profile option which will give you more information).

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
HoshinoArika
Posts: 5
Joined: Mon Aug 14, 2023 2:30 pm

Re: Lag when first time calling ES3.Save after play

Post by HoshinoArika »

Please check the attachments for the screenshots of profiler(with Deep Profile ON) and ES3 setting.

The code block executed is

Code: Select all

    public void SaveNewWorld(string worldName, string worldIdentifier, WorldSettingProfile worldSettingProfile)
    {
        this.Log($"Start saving new world {worldName} with identifier {worldIdentifier}");
        CurrentWorldName = worldName;
        CurrentWorldIdentifier = worldIdentifier;

        var saveFilePath = GetWorldSaveFilePath(worldName, worldIdentifier);

        SaveApplicationVersion(saveFilePath);
        SaveWorldSetting(saveFilePath, worldSettingProfile);
        this.Log($"End saving new world {worldName} with identifier {worldIdentifier}");
    }

Code: Select all

    private void SaveApplicationVersion(string saveFilePath)
    {
        try
        {
            ES3.Save(nameof(Application.version), Application.version, saveFilePath);
        }
        catch (Exception e)
        {
            ShowNotification(LocalizedHints.SaveErrorHint, e.Message);
        }
    }

Code: Select all

    private void SaveWorldSetting(string saveFilePath, WorldSettingProfile worldSettingProfile)
    {
        try
        {
            ES3.Save(typeof(WorldSettingProfile).ToString(),
                worldSettingProfile, saveFilePath,
                new ES3Settings(ES3.ReferenceMode.ByValue));
        }
        catch (Exception e)
        {
            ShowNotification(LocalizedHints.SaveErrorHint, e.Message);
        }
    }
where class WorldSettingProfile is ScriptableObject.

It seems that ES3GlobalReferences.get_GlobalReferences() causes the problem
Attachments
ES3 SETTING.png
ES3 SETTING.png (80.47 KiB) Viewed 906 times
ES3 SAVE LAG Hierarchy.png
ES3 SAVE LAG Hierarchy.png (506.98 KiB) Viewed 906 times
ES3 SAVE LAG Timeline.png
ES3 SAVE LAG Timeline.png (571.61 KiB) Viewed 906 times
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: Lag when first time calling ES3.Save after play

Post by Joel »

Thanks for sending that over.

Please could you expand the writer.WriteRef() row below the one you have highlighted, and any other rows beneath it until the percentage is minimal or there are no rows left to expand. This will allow me to see precisely what line is causing the slow down.

Also just to check, are you using the latest version of Easy Save?

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