Forum rules - please read before posting.

Slow First Load

edited November 2020 in Technical Q&A

Dear Chris and AC followers,
this is something I've been struggling since the very first demo of ENCODYA (more than a year ago) and yet, I cannot find a proper solution.
And it's the very first load of an AC scene.
I'm using Unity 2019.3.6f1 | AC 1.71.8
So, my project is the following:
I've one scene (non AC), which has a simple video and a loading script.
Then my first AC scene is my Main Menu, which is rather light (some pictures, some animations).
The first load takes about 35 seconds (no matter the length of the video) and if I've a progress bar, this bar takes about 2 seconds to go to 100%.
So, after many and various tests of all sort, I've come to the conclusion that my "Main Menu" scene actually takes 2 seconds to load, but then I've to wait about 33s for AC to load what it needs to work and start properly my first AC scene. This could be Players, Menu graphics (I've a menu with all my Inventory PopUp that are 100+ sprites), Speech Asset Bundle, Other Menu backgrounds (some have a video background), etc.
The problems are:
1- I think that 33s are still too much to load AC. Please consider that when I load my first scene or when I switch scene during my gameplay, it takes about 2-3s. I've optimized everything following the manual. So my scenes switch is actually fast and working properly, except the very first load.
2- There's no way to get the actual progress of that first load, because it's not the scene itself being loaded (which takes just 2-3s) but all the rest AC needs to work (??). So actually Unity "freezes" for those 33 seconds, and if you click the mouse or trying the Alt+Tab, Windows returns a crash message.
3- Those 33s freezes whatever I've on my first non AC scene (so if I've an animation, it freezes, if I've music, it stops, same for a video, etc.).

My question is: why all of this is happening? Am I the only one with this issue? How can I optimize this first load or, at least, getting a proper loading bar (not for the first scene, but for whatever AC is storing). I truly have tried all the options (getting a non AC scene-Menu for instance, loads in a sec), but every time I need to load the first AC scene, I get those 30 frozen seconds no matter what.
This happens only on a build. If I'm in the editor, the first load is super fast (maybe because what AC needs to work is already loaded in Unity when opening the editor?).
It's frustrating because I cannot tell the players "Please do not touch anything, just wait 30 seconds on a frozen screen"...

So I wonder if something has been done for the first load, since I've been reporting this for long time.
Thanks a lot for the awesome support!

P.S. I haven't tried putting a dummy player on my first scene yet, this might improve the loading time, but even if I reduce those 30s to 15s, it'll be still non-friendly for the users to have 15s of frozen Unity.

P.P.S. If my AC loading time is 30s and I put a video of 30s, it still waits the video to finish before launching the first scene, therefore I've to wait 30s more... So, for instance, if I've a "async.allowSceneActivation = true;" after the video ends, the count of the "AC frozen load" (i.e. 30s) starts at the moment of the allow = true. Like that it's related more with the "awake" of my first AC scene, and not its loading.

Comments

  • edited November 2020

    Loading times in any project are a combination of factors. When AC is loaded, so too are the assets and resources of your game that it relies on.

    Which of the performance boost tricks listed in the Manual specifically have you implemented? The use of SaveableData Resources folders, audio assetbundles, and reduction of animation clips in your Animators will make the largest difference of those listed.

    That there is a difference between Editor and Build suggests that there is more at play here beside AC. Be sure to plug your Profiler - with Deep Profile enabled - into your Build, as this is the first step in finding the cause of any optimisation issue.

  • edited November 2020

    Loading times in any project are a combination of factors. When AC is loaded, so too are the assets and resources of your game that it relies on.

    I understand, but would be nice to have a progress bar of AC resources, and not having Unity freezing for the time it takes to load AC only assets.

    Which of the performance boost tricks listed in the Manual specifically have you implemented? The use of SaveableData Resources folders, audio assetbundles, and reduction of animation clips in your Animators will make the largest difference of those listed.

    All of them! Kind of... I've the Saveable Data Resources folders and dummies, I've the Speech on an AssetBundle, etc. Regarding animation clips, I'm not anymore using tons of sprites (my game from 2D became 2.5D), so I've two 3D players which are FBX sets of animations, only few MBs each.

    That there is a difference between Editor and Build suggests that there is more at play here beside AC. Be sure to plug your Profiler - with Deep Profile enabled - into your Build, as this is the first step in finding the cause of any optimisation issue.

    Well, when I launch the Editor it takes a lot to load my project, but when I test the runtime it's fast. So I thought that the difference from Editor to Build, is because in the Editor the AC assets are already loaded. So when I click "play" on my first scene it goes very fast (2-3s) in the Editor, but when I launch the exe of the Build I had that freezing behavior explained (30s to load AC). Again: this happens only for the first load, the load between scenes is pretty fast also on build and same as in editor.

    I'll try the Profiler/DeepProfile... But I'm afraid I won't be able to fasten AC load under 10-15s, and the problem is that I cannot cover with video/animations/progressbar those 15s (where Unity freezes). But I'll give a look and let you know...

  • The first step is to learn what's causing it - dealing with it comes second.

    2D or 3D, having many animations in your Animators can contribute to performance.

    A simple way to test if this is the case here is to create a dummy Animator with no clips in it, and then (temporarily) assign it as the Animator Controller for all Player prefabs listed in your Settings Manager, or those present in the game's first scene.

  • edited November 2020

    33 s to load your first scene with AC is insane!
    Here is my story: Profiler, profiler, profiler! :)
    Use profiler to find what's causing the problem.

    I made my 2d adventure game and it was 4.4 Gb build size ! Which is insane too.
    But it was easier to work with since I had to test it a lot and with out optimization it is easier to run in the editor and make changes to the game (sometimes)

    Then I started optimizing the final build,- the size and performance.
    From 4.4Gb to 1.4 Gb! ( I think I still can reduce it to 1.2Gb)
    If your game is 2d uncheck mipmaps on all textures! It's useless for 2d and saves you 20-40% size.
    All your sprites or textures should be power of 4 for smaller size, saves upto 40% and faster load into memory. Pack all your sprites!

    Here is a video with some tips about sprites and texture optimization

    My first starting AC scene used about 15 sec to load now it is 2 seconds !!!.
    I found that was due to bad music compression and load all of it into memory 80 Mb at once. Profiler showed insane memory usage by Audio 435Mb at all times (Fmod and Audio)
    After optimizing music I also reduced the size of all music from 80 Mb to 25Mb
    Now Profiler shows 35Mb Audio memory usage at all times.

    That is due to size reduce and the the way music is loaded into memory. I set all music to Streaming compression format instead of loading it all right away.
    For music, but might work for sounds too! Uncheck Preload Audio Data, check Force to Mono(no-one cares about stereo ,saves lots of size), set Load type Streaming, Compression format Vorbis, quality 50, Sample rate Setting to Optimize sample rate.

    I was super surprised how music was screwing my performance and loading first scene time.
    Here is the guide I used to optimize music and sounds
    https://gamedevbeginner.com/unity-audio-optimisation-tips/

    Also check Optimization guide in AC manual , Super helpful!!!

    P.S. Oh and btw chaosmonger I don't have empty none AC scenes, all my scenes are with AC.
    And the very first scene after Unity splash screen plays a video intro 100Mb(1.40Mins) and after menu game and when press new game another 30Mb(40sec) video is played and only then scene is changed. And all of this is loaded now as I said 2 sec. To give you perspective .

    Hope this helps anyone :)

  • Chris am I correct Disable Console logs only affects performance in the editor and not in the build. I noticed huge performance boost when I run my game in the editor with Show logs in Console? to Never but not in the build.

    Also, I have lots of inventory items sprites (120x120 pixels).
    Let's say I texture pack Sword item sprite and other none inventory images and the whole texture would be now 1024x1024. Will now Unity and AC load the whole 1024x1024 texture every time in other scenes into memory if I have sword item in my inventory in my game?
    In other words would it be better to leave all sprites that might be loaded in other scenes out of the texture pack so to reduce the memory use of unnecessary big texture. And only pack those sprites that would be used in the current scene and when you leave it, it is cashed out?

  • edited November 2020

    am I correct Disable Console logs only affects performance in the editor and not in the build.

    Logs can be set to display only in the Editor but not builds. If you set it to Never, then they will be removed from builds as well. How much this impacts performance is a question for Unity, but certainly it will help.

    Will now Unity and AC load the whole 1024x1024 texture every time in other scenes into memory if I have sword item in my inventory in my game?

    AC will only request inventory graphics for those specificially being displayed.

    Whether or not all sprites in a sprite pack are loaded, when only one is requested, is also a question for Unity though.

  • edited November 2020

    Thanks a lot SkyTree. I'll have a deep look soon.
    My game is not 2D anymore, therefore I got rid of the tons of sprites. It's 2.5D so my 3D characters are rather light now in terms of MBs. I've very few textures and sprites, all considered (compared with my demo, which was fully 2D).

    Excluding Cut-Scenes (high quality video files for about 15 minutes), my game is now about 2GB. And it has 130 scenes (!), 2 switchable players, 36 NPCs, about 20 extras (passers) + 20 flying vehicles, about 40 music tracks and 4000+ (!) lines of dialogue. And lot more...
    As I said already, I've also read and applied almost everything in the Optimization guide of AC manual.
    I'm using a non-AC first scene to give something to the user that load instantly (considering I never had my first AC scene to load in less than 15s).

    I'll give a try to what you suggest for music and sounds (I've tons of sounds, so it might be it). But somehow I think could be also what's on the "Menus" (I rely a lot on Menus, that contain lot of data, pictures, background videos, etc.). I think the assets for the AC menus only are about 200mb.

    Nevertheless, I'll definitely try the hints for music/sounds and sprites/textures. And check the profiler to see what's causing the stall.

    Thanks a lot for your precious suggestions!

  • FYI:
    Simply changing my music from "decompress on load" to "streaming" reduced my loading time from 30s to 1s! Amazing!

  • Glad it worked :D

  • Wow - I just tried "streaming" on the music too - cut down cold startup time by 50% 👍

  • Indeed - both music and ambience tracks are part of the Settings Manager, so will be loaded when AC begins.

    I'll add a tip about this to the Manual.

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.