Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Scripts compilation/import extremely slow in 2019.3.xx

Discussion in '2019.3 Beta' started by lordnedox, Jan 17, 2020.

  1. lordnedox

    lordnedox

    Joined:
    Jan 7, 2016
    Posts:
    29
    Hi,
    I hope this wasn't already addressed but I've noticed since moving to the beta that my scripts are taking forever to get compiled/imported when I move from VS back to Unity.

    Indeed I have approx. 3,000 C# files in the project, so I've tried creating a new folder, with a single C# script and an assembly definition file. It was my understanding that changing/importing this script, being in its own assembly, should have been blazing fast.

    However, it still takes more than 10-12 seconds when i change the script and move back to Unity. Sometimes the "import xxxxx.cs" popup appears, something it just hangs with no UI.

    Tried both with 2019.3.0f1 and 2019.3.0f5.

    Older versions weren't super fast either, but I think at least 50% faster than the beta.

    Any suggestions? I'd be willing to update the project with assembly definition files, but if it takes 12 seconds to compile one script with 10 lines of code in it, seems more a waste of time to me.

    Cheers
     
  2. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    530
    It's probably the Domain Reload not the compilation time? When the loading circle thingy in the lower right is rotating the editor is compiling, when it's hanging the domain reload is happening which involves serializing/deserializing loaded assets, disabling/enabling ExecuteInEditMode stuff and ScriptableObjects and doing a AssetDatabase refresh.
    Some AssetDatabase stuff is still slower in 2019.3.

    You can attach the profiler, do a recompile and stop the profiler when finished. This gives you a pretty good overview what too the time and maybe you can work around it. ReloadAssembly should be a huge spike.
     
    phobos2077 likes this.
  3. lordnedox

    lordnedox

    Joined:
    Jan 7, 2016
    Posts:
    29
    I really can't profile anything, as soon as I leave from VS 2017 and go back to Unity, the Editor hangs for about 12 seconds, sometimes the "Importing ******.cs" popup appears at the beginning, sometimes it briefly appears just before functionality is restored.
    There's no circle icon, it's just completely frozen.

    Indeed it's not compile time, if I clear the Scripts cache it takes a second to rebuild it right away, it's doing some crazy gigantic refresh which is totally useless.

    Am I the only one facing this issue?
     
    BootySmashDeluxe and phobos2077 like this.
  4. LeonhardP

    LeonhardP

    Unity Technologies

    Joined:
    Jul 4, 2016
    Posts:
    3,143
  5. lordnedox

    lordnedox

    Joined:
    Jan 7, 2016
    Posts:
    29
    Great, thanks. I just wanted to know it's something at least being notified by someone and it wasn't just me, I will follow that thread closely.
    Unfortunately it's a 15 GB project and can't really make it available. With small projects the problem is not really noticeable.
    However it seems to me that by adding assembly definition files there's no improvement at all while importing the new scripts.
     
  6. julian-moschuering

    julian-moschuering

    Joined:
    Apr 15, 2014
    Posts:
    530
    Open the profiler, start it then do a script change and go back to the editor. After it reacts again stop the profiler. There now should be a frame taking alot of seconds.
     
  7. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    I really hope something will be done with domain reload. A huge part of my work day is wasted waiting for Unity to "un-hang" itself. There should be at the minimum some kind of progress bar for this process. It can take 10 seconds or more on a relatively small project (several gigs, some packages).
     
    gg_tk, Cascho01 and PhoenixAdvanced like this.
  8. lordnedox

    lordnedox

    Joined:
    Jan 7, 2016
    Posts:
    29
    I'd be OK if at least assembly definitions would solve the issue, but I've tried one assembly with one script of 5 lines of code, and when I change it it takes the same time as any other assembly change (10-15 seconds).
    It's quite depressing, but let's hope something will come up soon :)
     
  9. Awarisu

    Awarisu

    Joined:
    May 6, 2019
    Posts:
    215
    Profile file sent, changed one line of C# in an asmdef'd setup, with a trivial scene of one biped and a bunch of cubes. Case 1213483.
     
  10. devilhunterxl

    devilhunterxl

    Joined:
    Dec 19, 2018
    Posts:
    14
    Any progress on this story?
     
  11. sdb7

    sdb7

    Joined:
    Apr 8, 2013
    Posts:
    23
    second this..i have 2-5 second lag when return from visual studio..its just small project with dots package, hybrid renderer. my system is quad core i7 1.6Ghz, DDR3 12GB memory, external gpu with GT710 1GB DDR5
     
  12. yurilin1

    yurilin1

    Joined:
    May 22, 2013
    Posts:
    102
    I have tested this problem caused by asset pipline v2 which is really a bug feature.
    NBX{YP8O3T0M})UE`XL@KM2.png
    This happened in any project even just new empty with newly installed unity.
    versions in unity 2019.2 wont cause this problem because of using asset pline v1.
    If you reimport from a 2019.2 project with 2019.3 or 2019.4 and choose keep v1.
    The compiling would be quick enough.So this surely was the problem.
    But I think unity would never meet this problem as it looks like linked with the system hardware.
    Even if you reinstall the system.Save problem still happened.
    It is not an occasionally bug but happened on very few machine.So unity would never fix it I think

    :mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad::mad:
    ==================previous======================
    Unity got serious problems on the save/script instant compile for 2019.3+ (100 percent happen on 2019.4 or 2020)
    I am afraid that the promblem maybe linked with the pakcage manager or asset bundle something as 2019.2.7 did not happens.
    I have changed IDE from vs to rider.Still got the same problem while saving is maddly slow.
    I just create a new project and the bad lag happened. My computer 16GB win10 with RTX2060 cpu:9400f
    it must be a unity bug conflict with system.Because very few person seems faced this problem.
    With the lag,unity is just jammed and useless but it can not used for work anymore.
    Any time you just change a number to test the game would wait like a fool for 3-5 seconds.
    Please fix as it is an urgent 1st serious bug I've ever meet
     
    Last edited: Aug 17, 2020
    e01100111e and sdb7 like this.
  13. Dogo224

    Dogo224

    Joined:
    Mar 7, 2016
    Posts:
    1
    Hi, try to update visual studio.
     
  14. travelhawk

    travelhawk

    Joined:
    Jan 13, 2017
    Posts:
    22
    I'm having the same issue. When I open a script the editor hangs and freezes for 10 seconds....
     
  15. jwlondon98

    jwlondon98

    Joined:
    Mar 27, 2015
    Posts:
    12
    unity, don't make me regret updating to 2019.3.5. shouldn't have to deal with 10-15 of bs hanging after a simple script change
     
  16. julesradu

    julesradu

    Joined:
    Nov 9, 2017
    Posts:
    6
    I'm having the same issue (my profiler says the bulk of the time is taken by VS Unity bridge -- syntaxtree.visualstudio.unity.bridge.projectfilepostprocessor), likely because VS recompiles all the assemblies when I make a tiny change. It's very unproductive :(

    Is there any fix on this ?
    PS: I'm using Unity 2019.4.14f1. Are earlier versions prior to 2019.3.x better ?
     
  17. Slock20969

    Slock20969

    Joined:
    Nov 18, 2015
    Posts:
    15
    I am in 2019.4.13f1 and I am getting the same thing. Every little script change I do causes a 10-15 second hang in UNITY.
     
  18. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    Having the exact same issue with Unity 2019.4.14. I didn't have any issues like this using 2019.3, and that was after converting my project to asset database V2. I managed to capture the freeze in the profiler after deleting an empty .txt file that had no impact on scripts:



    Same issue, SyntaxTree.VisualStudio.Unity.Bridge etc. is causing 24,000 ms slowdown. When I save a script and try to compile, I get this before the compilation starts:



    Seems to be related to V2's ReloadAssemblies -> ReloadAssembly -> EndReloadAssembly. The before and after processing invokes each take 35,000 ms. I have no clue why this is happening suddenly, sometimes when I start up this version of Unity it doesn't happen. I didn't have any of these issues in previous versions and it's slowly making this project a nightmare to work on :( any ideas would be appreciated.
     
  19. nyonge

    nyonge

    Joined:
    Jul 11, 2013
    Posts:
    49
  20. InsaneStudio

    InsaneStudio

    Joined:
    Jan 1, 2016
    Posts:
    4
    This is really affecting my mental health, each small change I have to wait 15-30 secs with unusable editor (I7 7700QK - Nvme SSD - 16gb ram - gtx1070) Unity 2019.4.18 please if anyone fixed this help us
     
    nukadelic and phobos2077 like this.
  21. noethis

    noethis

    Joined:
    Nov 11, 2013
    Posts:
    129
    Any updates on this? I went from Unity 2019.3.1f1 to 2019.4.22f1 and my script compile times went from 10-15 seconds to 80-180 seconds. :(

    EDIT: Wondering if there's some kind of slowdown accumulation over time. Restarting my computer actually fixed the issue for now. Will continue to monitor to see if compile times climb back up.
     
    Last edited: Apr 23, 2021
  22. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    I also had a slowdown accumulation over time but it was pretty random. After I updated my Visual Studio (was using an old version of VS 2017 and now using close to the latest version of 2017) the problem seemed to go away for a bit. Now it appears to be back but way reduced and not as frequent, .txt import times are only a few seconds instead of 30s. Script compile times do get extreme though when I experience the problem, however it's happening extremely rarely now instead of several times a week. I would recommend updating VS and see if that helps a bit.

    There was a bit of discussion on this thread about it and I also made my own thread with more info here but I haven't included the latest problems with it popping back up again. Now I believe that there is a licensing bug which is causing it, when I looked into the Editor logs I found that it was printing out a ton of errors anytime I encountered the slowdown. Try looking at the log files to see if you have the same issue when it's compiling for a long time, I believe it comes down to a few problematic calls that have something to do licensing. This might explain why restarting Unity fixed it, because it could refresh or reconnect this aspect(?)

    I've been told that Unity devs are looking into it, hopefully they can get to the bottom of it soon. It might also be related to Unity Hub, if that has any impact on this license issue, I wouldn't really know for sure. But there's no guarantee that the problem I'm having is related to what you've been experiencing :/ see if you can do a Profile capture when it happens and check if it's getting stuck at the same function calls.
     
  23. DovitItalia

    DovitItalia

    Joined:
    Mar 23, 2020
    Posts:
    50
    Here I am too. My project is pretty big with around 1k classes, not using asmdef files. Every time I do a single small change to the code (even just a newline) going back to unity takes more than 30 secs.

    I'm using Unity 2019,4,21, a macbook pro i7 6 cores with 16gb ram and Jetbrains Rider as IDE

    I'm having this situation almost since the beginning of the project so I thought was "normal", found this post almost immediately now by searching on google.

    By profiling the editor i see a huge consumption by AssetDatabase.V2, I don't know if i want to use Asset pipeline version 1 as the editor said is deprecated
     
  24. SomeGuy22

    SomeGuy22

    Joined:
    Jun 3, 2011
    Posts:
    722
    I would expect if you have a large project that compiling could just take that long due to the amount of classes. Though I'm not sure if compiling will be triggered just by making a new line. A good way to test would be if you edit a .txt file and see if it takes the same amount of time for the change to import. That is something that under normal circumstances would only take 2-3 seconds for me, but when I encounter the "bugged state" of Unity it used to take up to 30.

    Last time I had the issue compiling jumped up to 2 mins when before it would take 5s. I think the key would be the difference between how long it should normally take just based on your computer specs vs. if you get a specific bug. Can you also check your Editor logs for any strange errors during compilation? The file locations can be found here.
     
  25. mrstruijk

    mrstruijk

    Joined:
    Jan 24, 2018
    Posts:
    53
    I have the same issue. Every change in any script results in Unity (2019.4.19) to recompile for at least a minute. I have created asmdefs for pretty much everything now (to clear out the Assembly-CSharp asmdef completely). Also moved all third party packages to the Standard Assets folder. Currently I'm upgrading to the latest 2019 LTS (2019.4.28) to see if that changes things. Fingers crossed!
     
    motorage likes this.
  26. mrstruijk

    mrstruijk

    Joined:
    Jan 24, 2018
    Posts:
    53
    Well I tried it so far, and if it is any quicker, it's not significant. Editing a script in an ASMDef of only 5 other scripts takes 50 seconds to a full minute.
     
  27. mrstruijk

    mrstruijk

    Joined:
    Jan 24, 2018
    Posts:
    53
    Setting the Asset Pipeline to V1 did help! The compile times are still abysmal, but only half as abysmal as before. Now, editing that same script 'only' takes 30 seconds to compile...
     
  28. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    Are you sure this is compile time? Sounds like you are experiencing slow domain reload. You should profile it and see what exactly is taking so long.. The more packages and third-party tools you have and the more windows are opened - the slower the domain reload will be.
     
  29. jakudlaty

    jakudlaty

    Joined:
    Apr 25, 2015
    Posts:
    1
    This engine is doomed if we have to profile editor instead of focusing on game development and profiling... Unity devs - please focus on fixing bugs instead of adding milions of unstable futures nobody asked for...
     
    TheOmnisimush, adehm, APTEM59 and 4 others like this.
  30. Eloren

    Eloren

    Joined:
    Jul 17, 2019
    Posts:
    24
    That's just ridiculous