Forum rules - please read before posting.

Loading time of savegame is significantly high

edited January 2021 in Technical Q&A

Hi,

I have two scenes - Main Menu and First Scene
When I load the First Scene from savegame the game stuck in loading phase for very long time
which is vary:

  1. 25 sec if the player already in First Scene
  2. 45 sec if the player in Main menu
  3. 90 sec if the player Main menu and it the first time loading

I'm loading from Unity UI menu with SaveList element

However,
1. Return from First Scene to Main Menu using 'switch scene' action, takes only 1second
2. RestartGame from Main Menu to First Scene (including Reseting Menus), takes only 2 seconds

In deep profiling the following take lots of CPU:
1. Garbage collector running in Preload Single Step it looks like it work hard to
delete unused objects (mentioned in console) - most of the problem come from here!
2. SaveSystem.LoadSaveGame() - ExtractMainData() and ChangeScene() takes some time

profilers attached

profiling
profiling 2

CPU: intel i7 3.6GHz
RAM: 16.0GB
Display adapter: AMD Radeon R9 200
VRAM: 2.0GB
HD - not SSD

Unity version: 2020.2.1f1
AC version: 1.72.4

Any suggestion how to fix it?

Comments

  • The unloading of assets may be related to your assets inside Resources folders. How many such folders do you have, and what do they contain? They should only contain the bare-minimum assets necessary.

    What else can you share about the project? Issues like this are generally down to the specifics of the scene / project - i.e. how large they are, how many things AC has to load (i.e. Remember components), and what assets it needs to load externally. Does your Player have any Remember components, and/or are you using any third-party assets/systems as well as AC?

    Try creating a new AC scene with the Scene Manager, but leave it otherwise blank. Then try switching to that, saving, and then loading that save from the Main Menu. Does that take a similarly long time? That'll help determine if the issue is scene-related or not.

    See also the Manual's "Performance and optimisation" chapter, which covers a number of AC-specific performance tips that can reduce long load times.

  • edited January 2021

    Amazing! I checked my Resources folder and spotted
    my Speech folder has over 2000 speech audio files!

    For test, I took out entire speech folder of project.
    And the loading time, reduced to 2 seconds (4 seconds on first load),
    which means that was the bottleneck.

    I might able to reduce the Speech folder amount by 70%

    I checked also the manual it mentioned:
    Speech files better be in Asset Bundles - I tried that approach before, and had an issue that some of files wasn't played in build, I will try and check it again.

    I used ogg, mp3, and wav format. what is the best format to use for
    best perofrmance?

    The speech folder has subfolders according to names of characters
    is that affecting performance too?

    The manual also mentioned it doesn't need to be in SaveableData folder
    so in my case it's just under Resources\Speech.

    PS
    There is any quick way of checking which speech files being
    used in my project instead of go over all files?

  • Speech files better be in Asset Bundles - I tried that approach before, and had an issue that some of files wasn't played in build, I will try and check it again.

    Either using Asset Bundles, or Addressables, will be more performant than relying on Resources folders.

    For Addressables, set your Reference speech files field to By Addressable, and then make sure each audio file's Addressable name matches up with the expected name as listed in the Speech Manager. Be sure to back things up first, however.

    I used ogg, mp3, and wav format. what is the best format to use for

    best perofrmance?

    I'm not sure - that's a question for Unity, I'm afraid.

    The speech folder has subfolders according to names of characters

    is that affecting performance too?

    Per-characters subfolders should improve performance, if anything.

    There is any quick way of checking which speech files being used in my project instead of go over all files?

    While Reference speech files is set to By Naming Convention, you can select a line in the Speech Manager and click the Ping file button to have AC attempt to locate the audio file. If the file isn't found, you'll get a message in the Console.

  • edited January 2021

    Thank you, I reduced the amount of speech files to 30%
    and used Addressables approach. now loading savegame takes only 2 seconds :)

    Few remarks which might be good to mention in the manual:

    Addressables are case sensitive, when I used Naming Convention
    speech file named: Player1 or PLAYER1 were both acceptable.
    With Addressables you need to make sure it's the same name as speech manager expecting including Upper\Lower case.

    A quick approach to set all the Addressable names same as their file names:
    (instead of doing that manually one by one)
    select all speech files and choose Simplify Addressable Names


    I'm still facing a loading time issue though,
    this time it's not related to savegame.
    when running the game and first empty scene loaded,
    it takes 7-10 seconds to finish.

    Here's the steps I did so far:

    I marked all files in the project as Addressable
    (not sure if that's do anything since I'm not loading them from code).

    Making sure all sprites asstes not exceeding 2K.

    Build size - 3.09GB
    globalgamemanagers.assets.resS takes 2.18GB out of it.

    Is that file related to AC managers?
    Do the managers load at first call to 'load scene'?

  • edited January 2021

    Here is a link where I helped a guy to reduce loading from 30 sec to 1-2.
    It's about optimizing audio files. It might rely to you since you use a lot of audio files such as speech.

    https://adventurecreator.org/forum/discussion/comment/40336#Comment_40336

    I don't know what kind of game you are making but 3Gb is a lot. Try to find ways to optimize it. Check out tips in the manual.

  • edited January 2021

    "globalgamemanagers" isn't related to AC managers, no. It's my understanding that's related to Unity itself.

    AC Managers are loaded in when first entering an AC scene. Use Unity's Profiler, with Deep Profile enabled, to determine the source of the slowdown.

    Pay particular attention to your Music/Ambience clips, if you're using AC's dedicated Actions for playing those. They should be set to Streaming in their Inspectors.

  • edited January 2021

    I fixed the issue, MANY thanks guys!

    The video that SkyTree explains how to see the Build Report in the log
    helps me find out that textures size in the build was 2.9GB out of 3.09Gb :o

    Most of them were related to the animations of the protagonist.
    So I reduced the sprites max size from 2048 to 1024 in the critical ones
    (those which mentioned at the beginning of the report)
    Then, a magic happened! :)

    Build size now is 1.31GB
    globalgamemanagers.assets.resS size became 713MB
    first load take only 2 seconds!

    I'm in the moon o:)

  • edited January 2021

    Glad to help you :)
    if it's a 2d game uncheck bitmap in your spriets, this saves you like 60% space.

  • edited January 2021

    Yes, it's a 2d game. Bitmap is uncheck by default and I haven't set any :)

    Looking at the build report, some sprite atlases takes bit space,
    I don't think I can do anything with that.
    (It's a balance of loading bit bigger textures vs small textures chunks at run time)

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.