Search Unity

Extremely slow scene loading with Unity Android

Discussion in 'Android' started by tr1stan, Dec 15, 2010.

  1. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    While it's true that Unity uses it's own way to load files from within the .apk, using AssetManager et al would not have helped at all in this case. The problem was located elsewhere actually.
     
  2. gram

    gram

    Joined:
    May 11, 2011
    Posts:
    5
    I just confirm that the problem is solved on 3.4.0b3.

    Many thanks for your trouble. :)
     
  3. larrykirschner

    larrykirschner

    Joined:
    Oct 27, 2010
    Posts:
    22
    Erique,

    We've got an android game scheduled to GM and publisher is refusing to accept due to loading-performance issues. We've been trying to mitigate with our code as much as possible, but obviously, we'd rather have the update that fixes the issues at the unity level.

    So questions are:

    1) How can I get a copy of the 3.4 beta so we can gauge the performance improvement?

    ...and...

    2) Roughly when is 3.4 scheduled for release?
     
  4. Wozik

    Wozik

    Joined:
    Apr 10, 2009
    Posts:
    662
    larrykirschner please email me to oleg@unity3d.com and I'll share the release containing a fix asap.

    Oleg
     
  5. Wozik

    Wozik

    Joined:
    Apr 10, 2009
    Posts:
    662
    I got a couple of emails asking for a 3.4 beta. So let's make it clear, I can indeed share the latest public beta of Unity 3.4 who really needs it. It is in the beta 3 stage and the beta tester responses are quite promising. Still there may be some bugs left, but you're free to release to iOS or Android with this beta.
     
  6. sperrine

    sperrine

    Joined:
    Jun 8, 2011
    Posts:
    1
    Wow. So much faster loads on our Xoom test device. Like 4 minutes before, to 6 seconds now. Thanks Oleg!
     
  7. mindlube

    mindlube

    Joined:
    Oct 3, 2008
    Posts:
    993
    Thanks Wozik, I sent you a PM to request it. Or if anyone else can hook me up- thanks. Want to do an Android release in the next few days.
     
  8. Derell Nar

    Derell Nar

    Joined:
    Jan 25, 2011
    Posts:
    10
    I'm sorry if this was covered already.

    I have this problem as well....
    I use LoadLevelAsync().
    What I found out is that the loading of the new scene is not as long as the Unloading of the previous scene.

    If one scene has a lot of assets loaded (most of which are loaded with Resources.Load()) it takes up to 20 seconds before the First Awake of the new scene is called....

    I also tried LoadLevel and there was no difference in load times.
     
    Last edited: Jun 29, 2011
  9. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    I've installed v3.4 now, but the very slow loading still hasn't been fixed, atleast on my projects.

    On my main project, it's actually increased. On v3.3 it took 30 secs to get to the main menu which is the first screen, but with v3.4 it takes 1 minute. I haven't changed anything in the project.

    On the other hand, on a much simpler project, which doesn't do anything but go from "gamestart" scene to "loading" scene to "title" scene (doesn't load anything in either of those, nor use Resources, nor use AssetBundles, it just uses Application.LoadLevelAsync to switch scenes fast, simulating how my main project's loading system works). It used to take 30 secs but now takes 20 secs, but it's still very slow compared to iOS only using 1 sec to do it.

    This is the same project I submitted as a bug report to Unity and also sent to Wozik who confirmed the bug in the sample project I sent.

    I didn't have access to the 3.4 beta so wasn't able to test it 5-6 months ago when I submitted this, but the reports from other users say that it should be fixed, and Unity 3.4 contains many speed improvements when it comes to the Android build...

    I'm testing it on a stock Nexus One with Android 2.2.1. I also upgraded it to 2.3.4 now to test, but it still happens there as well. Also tested on a HTC Desire.

    Should it just work out of the box, or is there some changes I need to do in order to get it utilize the speed boost in 3.4?
     
  10. DamianGto

    DamianGto

    Joined:
    Apr 20, 2011
    Posts:
    159
    Well they did say they fixed it in 3.4, but I say its almost the same.
    Add the new terrain in a scene and you can add 10-15 seconds to the load up, even if the terrain is empty and very small.
    I think there is still a major bug in the android support.
    I hope they will find a way to fix it soon.
    until then my only solution is to make a scene with a loading sign that the user can look at.
     
  11. unitynewb

    unitynewb

    Joined:
    Feb 22, 2009
    Posts:
    243
    Do you guys have any examples of what is currently the fastest way to load an Asset? Right now I'm saving and loading to a serialized XML file. Would that be the best way?
     
  12. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    I haven't done any serializing of Assets, so I unfortunately don't know the best way to do that. I'm using AssetBundles to store levels or graphics I only need to load at certain times, and then unload again after using them once.

    Currently with Unity Android 3.4, if you have multiple scenes, it can take a very long time to switch between them, even if you don't do any Asset loading at all...

    I emailed Unity about this so hopefully they can re-check the sample project I sent 5 months ago :)
     
  13. spree

    spree

    Joined:
    Apr 20, 2009
    Posts:
    20
    I think we've hit the same bug as you. Going from MainMenu to Level1 is relatively fast (~10s). But returning to the MainMenu (which uses way less assets as the levels) takes 10 minutes. (no that is not a typing error)
    As we are loading an empty scene in between I know that even loading of that scene takes approx. 5+ minutes. So the problem seems to be the UNloading of assets rather than the loading of new ones.

    Any idea how to prevent this from happening? And no I don't use Resources.Load anywhere.

    PS: Unity3.4, HTC Desire with Android 2.2
     
    Last edited: Aug 3, 2011
  14. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    Unfortunately I don't have any suggestions on how to prevent that, it sounds like it's the same problem I have...

    I've submitted a bug report with sample project to Unity, but haven't heard from them. I recommend submitting a bug report with sample project to them regarding this if you are able to. Hopefully someone at Unity will check this out eventually...
     
  15. eriQue

    eriQue

    Unity Technologies

    Joined:
    May 25, 2010
    Posts:
    595
    Can you give me the case number of the repro project you submitted?
     
  16. Wozik

    Wozik

    Joined:
    Apr 10, 2009
    Posts:
    662
    it's case 392128
    I am on it
     
  17. Wozik

    Wozik

    Joined:
    Apr 10, 2009
    Posts:
    662
    I'd like to remind, that using a small "loader" scenes can slowdown the loading on Android even though it may appear to be a good practice on iOS. So please load the necessary scene without any intermediate ones.
     
  18. spree

    spree

    Joined:
    Apr 20, 2009
    Posts:
    20
    I removed the loader scenes, but unfortunately that doesn't fix the problem. If it does improve at all the improvement is so marginal that I didn't realize it.

    It looks like this is somehow related to how (and then) scenes are cached in the engine. If I make a normal build the first big scene loads relatively fast (approx. same as on ios), however when i return to a previously loaded scene it takes about 5-10 minutes. If I load the scenes from an asset bundle using the new caching functions I don't have that extremely long load time, but instead now every level takes about 1 minute to load (which is still much too long). My guess is that the 1 minute load times are because the assets are cached on sd card and the 10s are because the first level was in memory. However I still have no idea how to influence that caching strategy to get "normal" load times for every level.
     
  19. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    I've also removed my loader scene, but that just makes the switch from one scene to another in 11 secs instead of 22 secs. Basically for my project it takes 11 secs just to open an empty scene or a scene with many gameobjects, even if I don't do any assetbundle or Resources loading.

    This doesn't happen in a completely empty game project though, it loads scenes fast then, so it just seems like my game might just be too big for Unity Android currently.

    Most likely it's all the in-memory stuff or references that Unity has to transfer over when switching scenes that makes this happen, and if it's too big of a project it just takes time... So no idea how to fix this :(
     
  20. Julien@Mentalwarp

    Julien@Mentalwarp

    Joined:
    Aug 23, 2011
    Posts:
    1
    I had the same problem : huge loading times (> 60 sec) between scenes.
    I found a way to reduce these loading times to about 4 seconds !

    My solution is not very clean, but it works : I replaced the loading of scenes (Application.LoadLevel) by the addition of scenes to the current one (Application.LoadLevelAdditive), and added a script in the new scene to destroy game objects from the former scene.

    I hope this solution will work for you guys too.
     
  21. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    Ah, cool, thanks Julien! I'll check that out, hopefully it will improve the loading time here too :)
     
  22. spree

    spree

    Joined:
    Apr 20, 2009
    Posts:
    20
    @Julien, that somehow doesn't work for me. Are you loading an empty scene before using LoadLevelAdditive?

    I also got some replies from Unity support on that, they said loading anything from the apk (so basically everything that is not in resources or assetbundles) is really slow on Android because it has to uncompress that apk. The other thing I was told is that using static references (e.g. Singletons) is bad on Android, which kind of sucks, as a lot of my code is based on singletons.

    I just wanted to share this with you, maybe it helps. It didn't help with my problems so far. :(
     
  23. Wozik

    Wozik

    Joined:
    Apr 10, 2009
    Posts:
    662
    Well, I spent some time comparing if the empty loader scene does really make a huge difference. And the results are it does not. At least for my test case. And if you have a case where the loader scene makes it much slower, please report a bug.

    Spree, what you're talking about used to be a true statement, but we mostly fixed it for 3.4 and we're still working on a better loading. Please tell me your case number so I can look at your project and elaborate on your particular case.

    Additionally I'd like to highlight, that the assets put to the Streaming Assets folder don't get compressed.

    Also I am not sure why static references are slow on android.
     
  24. fractivSammy

    fractivSammy

    Joined:
    May 26, 2011
    Posts:
    10
    Has there been any progress on this issue? All of a sudden we are seeing the same issue as spree: main menu and game scene are quick to load (2-3 seconds), but returning to the main menu takes 5+ minutes. This didn't happen in the previous release of our game, so I tried to track down what changed, and I just don't see anything obvious. I'm going to continue to look at this and will post if I find anything useful.

    edit: I'm using Unity 3.4.2, but 3.4.1 exhibits the same issue.
     
    Last edited: Dec 8, 2011
  25. fractivSammy

    fractivSammy

    Joined:
    May 26, 2011
    Posts:
    10
    I believe this issue is something to do with assets being unloaded from memory. When I use Application.LoadLevel(), I get extremely bad load times (on the order of minutes). I get the same bad load times if I use Application.LoadLevelAdditive() in combination with Resources.UnloadUnusedAssets() to evict the stuff I don't need from memory (we use Resources.Load() for some of our assets).

    However, if I use Application.LoadLevelAdditive() WITHOUT calling Resources.UnloadUnusedAssets(), loading times are fast (2-3 seconds).

    I implemented one of the other poster's suggestions about using LoadLevelAdditive() in combination with GameObject.Destroy() to get rid of the old scene objects, and it seems to work nicely. I guess I'm slightly concerned about increased memory usage with this technique, but it's the best solution I have for now.
     
  26. TMK

    TMK

    Joined:
    Mar 29, 2010
    Posts:
    91
    Just wanted to mention that my problem with the slow scene loading has been fixed by the newest Unity 3.5.b6 version, yay! :D
     
  27. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    Using Unity 3.5.0f5, and I'm having big issues with loading times.

    Simply put, the more levels you have in your game, the longer it takes to load a single one. This happens since that start of the game.
    I tested it on a game whose levels are clones of the same single level. If there are few scenes (like 4), loading is quick as it should (around 1 second). If there are more levels (like 18), loading takes ages (around 5 seconds).

    This practically renders Unity Android useless, since the game I'm working on right now will be composed of some 90 levels. Any solution for this? It's very bad, and also an old bug :/

    Thanks,

    Daniele
     
    99thmonkey likes this.
  28. tiktakgames

    tiktakgames

    Joined:
    Jun 27, 2011
    Posts:
    15
    the same i have 30 scenes and takes 5 seconds to load
     
    99thmonkey likes this.
  29. Demigiant

    Demigiant

    Joined:
    Jan 27, 2011
    Posts:
    3,242
    As a temporary solution, I'm using LoadLevelAdditive as suggested above. Though, Resources.UnloadUnusedAssets MUST be called, otherwise there will be major memory leakages. Anyway, using LoadLevelAdditive and than calling UnloadUnusedAssets - after the level has loaded and you manually destroyed the old game elements - is way faster than using LoadLevel (for some strange - read buggy - reason), so I'd suggest using that for now. This sucks, though :/

    P.S. tried issuing a Unity bug report about this, but as usual no feedback. It's quite discomforting.
     
    Last edited: Mar 23, 2012
  30. Arowx

    Arowx

    Joined:
    Nov 12, 2009
    Posts:
    8,194
    Hi I'm getting about 17 seconds to load a transition screen and the same again to load the games scene.

    The transition screen is has 1 plane and the game scene dynamically builds the level so is almost empty.

    This is way too slow any help/advice, what has the most impact on scene loading time, textures, models, instantiations?
     
  31. Crazy Robot

    Crazy Robot

    Joined:
    Apr 18, 2009
    Posts:
    921
    Has this issue been solved with Unity 3.5.4?
     
  32. S3dition

    S3dition

    Joined:
    Jan 6, 2013
    Posts:
    252
    This issue seems to be ongoing. I have a scene with 3 basic objects and 1 slightly complex object (still under 7,000 tris for the entire scene). One particle effect. Using all mobile shaders and a plane. This scene loads up in about 3 - 5 seconds. Next scene I cut down to just 2 textured cubes and an untextured plane and it took 33 seconds to load. A single mesh kicked it up to 1 minute. It only has 2.2k tris in the whole scene and is using a wopping 4.9mb to 10.6mb of video memory.

    No scripts except a back button that uses about 8 lines of code (works as a next, quit, and back). Nothing else going on at all. If I go back to the first scene, it takes around 20 seconds to load.

    Are the developers still working on this issue? I notice it's been a couple of years and the issue appears to persist. Using Unity 4.1.2f.
     
  33. Mey

    Mey

    Joined:
    Dec 25, 2012
    Posts:
    5
    We've been able to reduce the loading time of one of our scenes on android from ~20 sec to less then a sec by using loadlLevelAddetives on load.
    the scene was very lean to begin with (about 10 draw calls) and it was unclear why the load and unload took so long.
    Anyway - this fix applies also to the initial load (less then a second) and to every load after (even shorter), hope this helps!
     
  34. JayG81

    JayG81

    Joined:
    Sep 4, 2012
    Posts:
    72
    I'm having this problem as well with Unity 4.2. I've basically stripped my game of almost everything (most textures, all sounds except one, all scenes except one...) and it still takes 30 seconds to load up.
     
  35. miniduck

    miniduck

    Joined:
    Sep 27, 2012
    Posts:
    117
    Sounds like a perfect package to send to unity fogbugz. Please do so and paste ticket id here
     
  36. JayG81

    JayG81

    Joined:
    Sep 4, 2012
    Posts:
    72
    I think it may just be my phone. I downloaded some other games made with Unity and they are taking 2-3 times as long to load. I'm using the Samsung Galaxy S Captivate. It loads up within a few seconds using the Galaxy Tab 2.
     
  37. melkior

    melkior

    Joined:
    Jul 20, 2013
    Posts:
    199
    I'm having the same issue with Unity 4.3.3 for Android scenes taking 20-30 seconds to load.
     
    99thmonkey likes this.
  38. melkior

    melkior

    Joined:
    Jul 20, 2013
    Posts:
    199
    I was able to figure out (accidentally) most of my performance issue.

    We finally reached the production phase in art when most of the 3d models their corresponding UV's and textures were either done or likely to not be tweaked too much so we put them all on one big atlas this weekend.

    Adding the majority of the assets to one atlas / material appears to be the key that took the 30 second load down to about 3.5 seconds.
     
  39. su32132

    su32132

    Joined:
    Feb 15, 2013
    Posts:
    1
    Down from 30sec to 3.5? How big is your combined texture. Unity will failed if trying to read texture over 2048 (2K), we tried 4K and unity just failed to launch property.

     
  40. RvBGames

    RvBGames

    Joined:
    Oct 22, 2013
    Posts:
    141
    We hit this problem too on the Amazon Fire TV, with Unity 4.3.4. Loading the Menu is quick but loading the first scene takes a very long time, sometimes up to 5 minutes. Moving between levels, which is basically a reload of the same scene but with different options, the loading is decent.

    1. Are the shaders compiled at runtime on the Android? If so, how do we precompile them?
    2. Does loading prefabs cause a problem?
     
  41. Agent_007

    Agent_007

    Joined:
    Dec 18, 2011
    Posts:
    899
  42. 99thmonkey

    99thmonkey

    Joined:
    Aug 10, 2012
    Posts:
    525
    I'm surprised that this issue has still not been resolved. I'm having the exact same issue. Levels loaded great when I only had 2 or 3. Now that I have over 18 I get load times of 32 seconds. Once I have a level loaded, complete the level, and go to the next level, it only takes 3 seconds. If I go to my main menu (a blank scene with only NGUI menu and level selectors), it takes 32 seconds to load the next level.
     
  43. melkior

    melkior

    Joined:
    Jul 20, 2013
    Posts:
    199
    Sorry for the delayed response, I did not get a notification -- the atlas texture is 1024x
     
  44. RvBGames

    RvBGames

    Joined:
    Oct 22, 2013
    Posts:
    141
    I'm still having the same problem with the latest release of Unity version 4.5.2f1.

    The attached logcat file shows the game loading the main menu rather fast. At 17:10:31.866 the game was started and went quite from 17:10:37.051 to 17:12:02.635, almost a 90 second delay. . .doing nothing.
     

    Attached Files:

  45. Frenzykk

    Frenzykk

    Joined:
    Aug 6, 2013
    Posts:
    6
    Hi, don't know if this will be solution for you, but: We had same problem just few days ago on android and we was totally lost but we tracked the problem down (at least for us).
    We had menuscene which contained like 150 big meshes but all that meshes was saved in 3 .FBX files. And thats the core of the problem. I assume that unity can do something like parallel file loading for performance boost but with this many meshes in one file it just can work in only one thread which i suppose is kinda slow

    Hope this will resolve your issue
     
  46. Andres-Fernandez

    Andres-Fernandez

    Joined:
    Feb 4, 2013
    Posts:
    57
    Hi there, I just wanted to share my two cents on this subject.
    I had some similar problem with the unloading time (or what I thought it was just unloading time), but after some testing I found out that the unloading time also depends on the new scene being loaded (I don't know why, It just happened in my tests). In my case, using LoadLevelAdditive had no performance impact over using LoadLevel. Results of tests with 2 significative scenes:

    Unity version: 4.5.3p
    Device: Samsung Galaxy Tab 3 Lite 8GB (Wi-Fi), White
    Scene 1 (profiler at runtime):

    • Textures: 98 / 17.1 MB
    • Meshes: 46 / 2.7 MB
    • Materials: 106 / 54.4 KB
    • AnimationClips: 0
    • AudioClips: 0
    • Assets: 535
    • GameObjects in Scene: 159
    • Total Objects in scene: 813
    • Total Object Count: 1348

    • Draw calls: 90 Tris: 21.6k Verts: 35.6k
    • Batched Draw Calls: 0 Batched Tris: 0 Batched Verts: 0
    • Used Textures: 0 / 0B
    • RenderTextures: 0 / 0B
    • RenderTexture Switches: 0
    • Screen: 64x64 / 48.0KB
    • VRAM usage: 48.0 KB to 1.4MB (of 208.0MB)
    • VBO Total: 45 - 1.3 MB
    • VB Uploads: 0 - 0 B
    • IB Uploads: 0 - 0 B
    • Shadow Casters: 0
    Scene 2 (profiler at runtime):



      • Textures: 197 / 21.4 MB
      • Meshes: 247 / 4.8 MB
      • Materials: 127 / 64.7 KB
      • AnimationClips: 0
      • AudioClips: 0
      • Assets: 960
      • GameObjects in Scene: 1583
      • Total Objects in scene: 11682
      • Total Object Count: 12642



      • Draw calls: 194 Tris: 65.7k Verts: 108.8k
      • Batched Draw Calls: 546 Batched Tris: 22.7k Batched Verts: 46.7k
      • Used Textures: 0 / 0B
      • RenderTextures: 1 / 32.0 MB
      • RenderTexture Switches: 2
      • Screen: 64x64 / 48.0KB
      • VRAM usage: 32.0 MB to 34.4MB (of 208.0MB)
      • VBO Total: 242 - 2.4 MB
      • VB Uploads: 0 - 0 B
      • IB Uploads: 0 - 0 B
      • Shadow Casters: 0
    Resulting unloading times of scene 1 + number scenes in build (Scene 1 + 7 scenes equal to Scene):
    • Scene 1 to scene 2 + 8 scenes in build = 2500 ms unload time
    • Scene 1 to empty scene + 2 scenes in build = 140 ms unload time
    • Scene 1 to empty scene + 9 scenes in build = 140 ms unload time
    The unloading time is measured using a stopwatch started just before calling Application.LoadLevel() and stopped inside function OnDisable().
    Unloading times were heavily impacted by the loading time of the following scene, bearing in mind that scene 2 is very heavy on load (it has to parse a couple JSON files, 600KB toghether).
    Just tried the opposite (loading a heavy scene from empty) and results as expected (pretty much as everyone in this thread).
     
    Last edited: Feb 9, 2015
  47. unity_AB460D8CC301F6DAB987

    unity_AB460D8CC301F6DAB987

    Joined:
    Sep 21, 2022
    Posts:
    1
    its 2022 and am still facing the issue and its most probably due to the texture compression format