Page 1 of 1

Loading game gets stuck.

Posted: Thu Oct 19, 2023 10:08 am
by GREI
Hi,
I am a bit confused about how to use the save system.
I have the four components (SaveSystem, Json...) from tutorial attached to the dialogue manager.
Then I let my button perform a bit of code

Code: Select all

    private void SaveGame()
    {

        SaveSystem.SaveToSlot(0);

    }
and

Code: Select all

    private void LoadGame()
    {

        SaveSystem.LoadFromSlot(0);

    }
But when I got something saved and try to load, the game would just freeze and stop working.
Please tell me what I am doing wrong here.
Thanks!

Re: Loading game gets stuck.

Posted: Thu Oct 19, 2023 11:03 am
by Tony Li
Hi,

Are there any errors or warnings in the Console window?

If you're playing in the Unity editor's play mode, does Unity freeze? Or can you exit play mode?

In the scene that you're loading, is there anything that might call LoadGame() again when the scene starts? This could put the game into an infinite loop.

Re: Loading game gets stuck.

Posted: Thu Oct 19, 2023 11:09 am
by GREI
Hi,
No error messages at all. The entire unity would freeze (i.e. I cannot minise the window or exit play mode ect). After a while it would unfreeze and that's it.
I don't have any other trigger for loading scenes other than the button click, so I think the game is not in a loop.

Re: Loading game gets stuck.

Posted: Thu Oct 19, 2023 11:22 am
by Tony Li
Please try this:

1. Close and reopen Unity. This will create a fresh Editor.log file (see here for location of file).

2. Reproduce the issue.

3. When Unity unfreezes, don't do anything else in Unity. Examine the Editor.log file. If you jump to the bottom of the file, it should indicate what was going on when Unity froze.

Re: Loading game gets stuck.

Posted: Thu Oct 19, 2023 12:23 pm
by GREI
Hi,
it seems that it is repeatedly unloading assets and seriealised fields.

Code: Select all

Unloading 59 unused Assets to reduce memory usage. Loaded Objects now: 7742.
Total: 69.504000 ms (FindLiveObjects: 0.535100 ms CreateObjectMapping: 0.305500 ms MarkObjects: 68.605400 ms  DeleteObjects: 0.057200 ms)

Unloading 3 Unused Serialized files (Serialized files now loaded: 0)
UnloadTime: 0.630900 ms
Loaded scene 'Temp/__Backupscenes/0.backup'
	Deserialize:            2.348 ms
	Integration:            29.993 ms
	Integration of assets:  0.669 ms
	Thread Wait Time:       0.010 ms
	Total Operation Time:   33.020 ms
System memory in use before: 167.5 MB.
System memory in use after: 168.0 MB.

Unloading 59 unused Assets to reduce memory usage. Loaded Objects now: 7742.
Total: 69.308400 ms (FindLiveObjects: 0.502200 ms CreateObjectMapping: 0.272500 ms MarkObjects: 68.470100 ms  DeleteObjects: 0.062900 ms)

Here are the last couple of lines


Unloading 3 Unused Serialized files (Serialized files now loaded: 0)
UnloadTime: 0.647500 ms
Loaded scene 'Temp/__Backupscenes/0.backup'
	Deserialize:            2.329 ms
	Integration:            30.431 ms
	Integration of assets:  0.692 ms
	Thread Wait Time:       0.010 ms
	Total Operation Time:   33.462 ms
System memory in use before: 167.4 MB.
System memory in use after: 168.0 MB.

Unloading 59 unused Assets to reduce memory usage. Loaded Objects now: 7742.
Total: 69.557800 ms (FindLiveObjects: 0.498700 ms CreateObjectMapping: 0.262800 ms MarkObjects: 68.736800 ms  DeleteObjects: 0.058800 ms)

Refresh completed in 0.008523 seconds.
RefreshInfo: RefreshV2(AllowForceSynchronousImport) scanfilter: 
RefreshProfiler: Total: 7.774ms
<RI> Initialized touch support.

Re: Loading game gets stuck.

Posted: Thu Oct 19, 2023 4:09 pm
by Tony Li
That looks fairly normal. Can you look back further to identify a pattern?

Re: Loading game gets stuck.

Posted: Fri Oct 20, 2023 7:24 am
by GREI
yes, the pattern is "Unloading 3 Unused Serialized files" and "Unloading 59 unused Assets to reduce memory usage. ". They are repeated many many times and it seems that is pretty much all it is doing.

The log has got 120199 lines and over 5MB in size. Majority of them are "Unloading 3 Unused Serialized files" and "Unloading 59 unused Assets to reduce memory usage. "

Re: Loading game gets stuck.

Posted: Fri Oct 20, 2023 7:44 am
by Tony Li
Can you send a reproduction project or the Editor.log file to tony (at) pixelcrushers.com?

If not, do you see any messages that says it's loading (not unloading)?

What versions of Unity and the Dialogue System are you using?

Re: Loading game gets stuck.

Posted: Fri Oct 20, 2023 7:57 am
by GREI
Yeah, I'll send the file over, thanks a bunch!

Re: Loading game gets stuck.

Posted: Fri Oct 20, 2023 4:50 pm
by Tony Li
Thank you for sending the project. I replied to your email. The problem is that the Update() method was adding another "SaveGame" and "LoadGame" to the UI buttons every frame. I attached a fixed version of the script that uses the Start() method instead and also uses the SaveSystem class.