Search Unity

Very Slow App Startup time

Discussion in 'Windows' started by ekhader, Nov 25, 2014.

  1. ekhader

    ekhader

    Joined:
    Oct 2, 2013
    Posts:
    40
    Hello Everyone,
    I have a problem with game startup time on wp8 device, the splash screen stays 13 seconds on launching the app,
    I have searched every place on the net to find any clue from which this could happen.
    I have tried to load empty scene that does absolutely nothing and the same amount of time is always taken.

    I wonder if anyone has any clue on this problem. and btw loading scenes takes also very long time, and i have solved this in a tedious and unpleasant way by changing all my levels into prefabs, but now i am only left with the last problem which is that starting time.

    so in short my case:
    1. empty scene that does nothing with just a camera object in it takes 13 seconds to start.
    how to debug this or even have any clue from where it is happening.
    2. if I make a new project then the load time is 3 seconds.

    Note: my project is big and has a lot of code, but at least in the empty test scene none of the code is used.

    another question is where is the UnityPlayer.pdb debug so i could use it with the VS performance analysis tools, I have only the release and master pdb files but not the debug and i can't load the symbols from those.

    if anyone has any idea please do share.

    Thanks alot.
     
  2. pumpkinszwan

    pumpkinszwan

    Joined:
    Feb 6, 2014
    Posts:
    214
    I suggest you create a new game with one simple scene (e.g. a single sprite on screen), and test the startup time.
    That will determine whether it's your game code or not causing the delay. If your blank game still takes 13 seconds to start the issue is probably not your actual game.

    What device(s) are you testing on? My game (see my signature) takes about 3 seconds on a Lumia 920 before the first scene is visible.

    Are you running in development/debug mode? If so your performance will be degraded a LOT. Try deploying the MASTER build from Visual Studio (even the release build suffers poor performance, and the master is the one you would actually release).

    If you're testing in the emulator that might explain the poor performance.
     
    lifeisfunxyz likes this.
  3. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Hi,

    do you by any chance start the application from visual studio? It might be that 13 seconds actually contains 10 seconds of Visual Studio resolving symbols, and thus freezing your application during that time. Launching directly from the the device will not have this issue.

    Furthermore, as pumpkinzwan said, make sure to deploy the application in "Master" configuration.

    As for Debug PDB files - we don't ship neither debug DLLs, nor PDB files for Windows Phone 8.0. In debug and release configurations, it will use the release DLL, so you should be able to use release PDB to resolve the symbols.
     
    lifeisfunxyz likes this.
  4. ekhader

    ekhader

    Joined:
    Oct 2, 2013
    Posts:
    40
    Hello,
    Thanks guys for the tips, however;
    I am using of course Master build, and I test on the actual device and without the VS attached to the device.
    the device I am testing on is lumia 520 wp8 and the results a bit better on lumia 920 like half of the time on lumia 520 but that as well not acceptable time around 7 seconds.

    and for pumpkinszwan suggestion of creating a new project I have already done that and the time was around 3 seconds on lumia 520. so the problem obviously in my current project.

    but the problem is how to discover which is causing the problem if none of my code is actually running in the empty scene test i talked about earlier.

    I am still clueless I have spent the last two weeks working on this performance issues.

    BTW I am using Unity 4.6.0f2.
     
  5. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    You could use Visual Studio profiler to profile the start up - it might give clues which engine subsystem is taking a lot of time.
     
  6. ekhader

    ekhader

    Joined:
    Oct 2, 2013
    Posts:
    40
    The problem i can't load the symbols files so i don't get any useful info from the profiler, i have tried everything i know to get the symbols to load but with no results.

    but does anyone knows what happens during the splash screen if the scene to be loaded is completely empty?
     
  7. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    Well, Unity is initializing, but that doesn't take very long, unless you have a really big probject with lots of scripts.
    One thing to check in VS is exceptions. Exceptions are very costly, so if you get a lot of them during startup, it might take a lot of time.
     
  8. ekhader

    ekhader

    Joined:
    Oct 2, 2013
    Posts:
    40
    I do have big project, my own code is about 200+ cs files,
    and the tools about 600+ cs files.

    But i feel that unity is doing something crazy behind the scenes, for example if i load a level with Application.loadlevel it takes around 10 seconds on lumia 920, and if i pack the level as a prefab and instantiate it then it takes 2 seconds.

    and because of this i had to change all the game logic and menus and almost touch every file to get it to be fast, but this last thing about the game start up time is not in my hands to change.
     
  9. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    It's strange that it won't let you load the symbols - does it say the symbols don't match the DLLs? From which folder are you loading symbols? Are you targeting Windows Phone 8.0 or 8.1 from Unity?
     
  10. ekhader

    ekhader

    Joined:
    Oct 2, 2013
    Posts:
    40
    I finally managed to get the symbols to load it wasn't straight forward, but anyway
    i found out that most of the time goes into:

    ResourceManager::VirtualRedirectTransfer 4,305 0 31.31 0
    std::_Sort<ResourceManager::Dependency *,int,ResourceManager::Dependency::Sorter> 3,044 0 22.14 0

    this test is done with a completely empty scene.

    i don't which resources it tries to sort and which dependencies in an empty scene??

    I would appreciate any help or hint in this.
     
  11. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Hey, this is indeed strange, I can't really tell you what might exactly be causing this, but I will check and get back to you. In the meantime, could you submit a bug? This is clearly not intended behaviour, and we'd like to fix it.
     
  12. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Okay, so here's an update: this is happening because the engine is indexing assets in your Assets/Resources folder, so you could later load them with Resources.Load(). However, it taking so long IS NOT normal or expected. So please, report a bug.
     
  13. ekhader

    ekhader

    Joined:
    Oct 2, 2013
    Posts:
    40
    I was just typing that i noticed that the removing the levels prefabs from resource folder improved the speed but now am in trouble because there is no way i could remove them from resource folder.
    is there anyway I could pre index the resources folder? or any work around this? I have a deadline in 3 days or all will be lost for me :((((((
     
  14. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Hey,

    I've got a workaround for you. It won't be the prettiest solution, but it should work. Putting stuff to Asset bundles, rather than Resources, will avoid all the extra indexing and you will still be able to load them at runtime just fine.
     
  15. ekhader

    ekhader

    Joined:
    Oct 2, 2013
    Posts:
    40
    Thanks alot I will give it a try and I will file a bug about this issue.
     
  16. holdingjason

    holdingjason

    Joined:
    Nov 14, 2012
    Posts:
    135
    Was this every solved? I am having the exact same issue with level prefabs in resources killing initial app load time?
     
  17. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Hi,

    we did receive the report from the OP a few days ago, but we could not reproduce the issue internally, and the OP did not send us a repro. Our QA tried building their own prefabs and store them in Resources folder, but they got nowhere near the times OP is mentioning. Unfortunately, without a way to reproduce it, we cannot possibly fix it.

    If you're having the same issue - could you report a bug as well with a repro illustrating the issue?
     
  18. ekhader

    ekhader

    Joined:
    Oct 2, 2013
    Posts:
    40
    Hi,
    Sorry for late to reply, I was extremely busy I have to release the game and I am already over schedule but once I release this week I will make a project and send it.

    I am still having that problem so I definitely want it to be fixed.
     
  19. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Thanks.
     
  20. kalineh

    kalineh

    Joined:
    Dec 23, 2015
    Posts:
    241
    Just updating this thread - we have most of our prefabs and assets in Resources/ since we do a lot of dynamic asset loading. Our startup time was profiled to be about 12s, moving things out of Resources/ to a static folder reduced startup time to about 2s.

    This is regardless of which scene you have open - this happens on a full scene or an empty scene. Every file in Resources/ is loaded.

    Looking through filemon IO calls during startup, Unity just does a load of every single asset in the Resources/ folder, and a huge amount of reads through resource database files.

    As a side note, a lot of unity's startup file reads are in relatively small chunks (7168b), which might be faster with bigger chunk read size. Some of the DLLs read 2b or 4b at a time - definitely not ideal (also log output writes are 1b per write call, be sure to run editor with -nolog).
     
  21. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    Yeah, all resources are treated as a single asset bundle that gets loaded on startup. It's not really designed to have much stuff there - it's best to only use it for stuff that you always need.
     
  22. kalineh

    kalineh

    Joined:
    Dec 23, 2015
    Posts:
    241
  23. leolicos

    leolicos

    Joined:
    Dec 1, 2010
    Posts:
    28
    Is this still an issue for anyone? I have a very large RPG game that is taking a long time to load. There are a lot of assets in the Resources folder that I can probably take out and move to scriptableobjects and references elsewhere. It's taking my game several minutes to startup before any scripts are loaded. When looking in the player's output file, there's a very long time delay after "<RI> Initialized touch support.", and before "UnloadTime: 1.276600 ms", but after this and when my scripts start running, things run fast again.
     
  24. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    You could use the profiler to see what is taking the time.
     
  25. leolicos

    leolicos

    Joined:
    Dec 1, 2010
    Posts:
    28
    The long startup time only happens in a build. In the Unity Editor, it runs fine after clicking the play button. It starts up pretty quick. But when I do a build, and run the executable, it takes several minutes to load. I get a white screen with (not responding) for several minutes before any of the Unity splash screen stuff shows up.

    I've never used the Profiler outside of the editor at all, is that possible? Is that what you meant? If so, could you link me to documentation on how to do that, otherwise I'll do some searching for connecting the profiler to an executable before it's run to capture what happens the moment it starts up.
     
  26. leolicos

    leolicos

    Joined:
    Dec 1, 2010
    Posts:
    28
    I did some searching and I found the docs for the profiler and building the game as a development build, autoconnect profiler, and deep profiling support. I run the profiler as a standalone process (for convenience).

    I tried different combinations of running the game, then selecting from the drop down; selecting 127.0.0.1 from the drop down then running the game. Sometimes there would be a Local drop down and I can select the game then, but now it's not showing up anymore.

    upload_2022-3-25_22-50-3.png
     
  27. Tautvydas-Zilys

    Tautvydas-Zilys

    Unity Technologies

    Joined:
    Jul 25, 2013
    Posts:
    10,680
    That's weird. Do you have any custom firewalls or proxies configured on your machine?
     
  28. MartinTilo

    MartinTilo

    Unity Technologies

    Joined:
    Aug 16, 2017
    Posts:
    2,461
    @leolicos have you tried to not use the Standalone Profiler but the regular one? The Standalone Profiler was primarily checked for it's Use Case of profiling the Editor and might still have some issues connecting to a built Player.