playMaker

Author Topic: Load Level Additive Async - Frame Rate Drop - How to fix? [solved]  (Read 14062 times)

createasaurus

  • Full Member
  • ***
  • Posts: 146
I've been lovingly building my game around the Load Level Additive Async command.  The idea was to have uninterrupted game play, with a manager quietly loading and destroying assets within a single level.  Now that I'm further along, I'm realizing that whenever the Load Level Additive Async command is called, there is a big frame rate drop.  This is confirmed with spikes in the profiler.  I fear I fundamentally misunderstood the Additive Async command.  I thought the idea of "Async" was to slowly load new information at a nondestructive speed, so that the loading process would be stealth and hidden without frame drops.  I've been researching this problem in the Unity forms and people talk about fixing it with:
Quote
a combination of Time.deltaTime + Application.backgroundLoadingPriority = ThreadPriority.Low
Honestly, these discussions are above my head.  But they do give me hope.  Does anyone here know how to use  the Load Level Additive Async command in a way that I can slowly load information in the background, without large frame drops.

Gratefully and hopefully,
Chris (createasaurus)
« Last Edit: November 14, 2014, 04:07:07 PM by createasaurus »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Load Level Additive Async - Frame Rate Drop - How to fix?
« Reply #1 on: November 14, 2014, 02:17:03 PM »
Hi,

It's unfortunate indeed. Could you reference these discussion, I would like to read them, I may be able to help you more on this then.

First, if you are targeting mobile, you will face memory warning issues if you load levels additively because of very bad memory leaks with Unity engine itself. So, even if you work very hard to remove spikes... down the line it's not a viable solution for large game content.

If you don't target mobile, then fine, but be aware that the memory leaks nonetheless are very much present anyway, so make sure you profile all the way to the end of your game and watch memory as you load and load levels.

You should create a system that handles your content and always knows what needs to be deleted and when. It's a huge effort and very costly to develop as there isn't really a generic way to do this, as the "level" paradigm is supposed to be exactly that...

-- Have you studied bundles? you could make smaller chuncks or data and they could behave better than asynch additive loading.

-- Or you need a custom solution using pooling and custom serialization:

-- using a pool system for your content is a known solution that works very well and prevent even spikes as content is spawned and despawned, so make use of pools where ever you can, it's the best way.

-- serialize your content your own way. I use xml ( via XmlMaker for example) a lot, I have a client mobile game project with 50K!!! lines of xml and it's a brease and faster then load additive, without the memory leak at all!!! more on this when it will be out :) You can use a database as well, but in all cases, it's a lot of work indeed... and quite challenging if you want to do it all in PlayMaker ( but again possible with xmlmaker and database assets that are compatible with PlayMaker).

So maybe not the answer you expect, all this this to give a bug warning on spending time fixing something that may become obsolete because of other problems. so I would push the development to a point where you can finish the game more or less and profile the memory, then you can decide to invest time in address spikes, but in all cases, it will likely mean a lot of rework in the project structure, so always stressfull.

 Bye,

 Jean

createasaurus

  • Full Member
  • ***
  • Posts: 146
Re: Load Level Additive Async - Frame Rate Drop - How to fix? [solved]
« Reply #2 on: November 14, 2014, 02:56:42 PM »
Hi Jean,

Thank you for your thorough answer.  My big take away is that indeed I was using Load Level Additive Async incorrectly.  I now see that it's purpose is not to load, quietly and discreetly behind the scenes while the game runs.

Here is the discussion I was referencing:
http://forum.unity3d.com/threads/performance-while-application-loadlevelasync.105278/

You have given me alot to research and learn about - which is very good.  At least I'm not stuck.  ;)  I will move forward as I try to learn more about bundles, pooling, and custom serialization.  These are all things I know nothing about yet, so I will begin to learn.

I also may consider giving up the dynamically loading element of this game.  Maybe at my beginner level, I should simply stop the action and let the level elements load with a little "level loading icon".

I will need to do more learning and experiments before I decide.

Thank you so much again,
Chris (createasaurus)


« Last Edit: November 14, 2014, 04:07:59 PM by createasaurus »

jeanfabre

  • Administrator
  • Hero Member
  • *****
  • Posts: 15500
  • Official Playmaker Support
Re: Load Level Additive Async - Frame Rate Drop - How to fix? [solved]
« Reply #3 on: November 15, 2014, 04:08:41 AM »
HI,

 I think this topic in general is the key factor that differentiate AAA like games and indie games, so indeed I am willing to follow your progress on this.

Typically, you should think in terms of "chapters" in your game and try to gather everything needed during the whole chapter game play, you can afford a loading time between chapters, it's fine ( see cut the rope, it's organized as well in chapters, loading a chapter takes time, loading levels within chapters is instant, so they use this technic too).

 now if your game is a constant stream from start to finish, insert the spikes at key points in your game, when you reward the player, or when you play a cut scene, you will gave to be clever and hide the spikes through different means, typically cut scenes and popups saying "Congrats you went that far you won some credits), that typically is a disguised trick to load at the same time the next bunch or props while you read that popup content.

 now, the big challende then is resuming to a given point of the game, the key is to store everything needed as the user progress, AND put everything back as it was set by the game play, is a coin was picked or not, if a door was opened or closed, this is very important for consistency of the story line, especiallay if the use can go back on his steps, if not, then you are safe on that regards, and only look forward in the storyline.

 Bye,

 Jean
 Bye,

 Jean

createasaurus

  • Full Member
  • ***
  • Posts: 146
Re: Load Level Additive Async - Frame Rate Drop - How to fix? [solved]
« Reply #4 on: November 15, 2014, 05:44:52 AM »
Thank you again Jean,

I agree, minimal "waiting" or the at least the appearance of waiting is a:
Quote
key factor that differentiate AAA like games and indie games

My vision was breaking up the game into small elements that would be often loading and being destroyed by a manager.  Who knows, I may be able to realize this vision for my NEXT game as supposedly:
Quote
one of the unity5 features is "load level async will work as advertised".
http://answers.unity3d.com/questions/774129/load-level-additive-async-lag-spike.html

However, for THIS game, I'll work within the constraints of the current system, as I am a beginner on my first game and I need to think simple.
Quote
insert the spikes at key points in your game, when you reward the player, or when you play a cut scene
Absolutely, this is the new plan.
Quote
the big challende then is resuming to a given point of the game
I'm up to this challenge!  ;)

Thanks again,
Chris (createasaurus)

PS One final thought...  I am on counsel development, so I might be able to push through as planned by raw force... if I just carefully monitor key offenders in the profiler.  Hmmmm.  I will be experimenting.  Sorry, it's just hard to give up the dream too quickly.
« Last Edit: November 15, 2014, 06:36:42 AM by createasaurus »