Search Unity

Bug Editor takes minutes to become responsive after a code change

Discussion in 'Editor & General Support' started by jbassking, Dec 11, 2023.

  1. jbassking

    jbassking

    Joined:
    Feb 27, 2014
    Posts:
    118
    It doesn't seem to matter the amount of change to any of the code. It can take 2-4 minutes before I can hit the play button. And even once I hit play, it takes another minute or more before it actually plays.

    The issue started after upgrading from 2020.1.10f1 to 2022.3.14f1.

    Update - It pays to mention that clicking stop and play again takes ~1:30 before it goes into play mode. This is without any changes.
     
    Last edited: Dec 11, 2023
  2. spiney199

    spiney199

    Joined:
    Feb 11, 2021
    Posts:
    7,859
    New versions of Unity are definitely slower in some capacity, though 2-4 minute domain reload times are pretty absurd.

    What were your reload times on the older versions?
     
  3. jbassking

    jbassking

    Joined:
    Feb 27, 2014
    Posts:
    118
    10 seconds maybe. It was really quick.
     
  4. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,890
    This begs one question because it is phrased vaguely: did the issue start IMMEDIATELY after upgrading to 2022.3 or were you able to continue working with it normally for a few script changes, possibly for hours or days and THEN that's when it started to be slow?

    In the latter case it has to do with whatever change was made to the project. You should try to track that down. Could be a very complex asset or changes to an editor script or installing a 3rd party asset.

    In both cases I would try deleting the Library folder and reopen the project. Sometimes this fixes the odd issue.
    Also intrusive 'security' software (aka antivirus) is known to cause slowdowns, sometimes severely so. Adding the project folder to the active scanner's exclusion list is best practice.
     
  5. jbassking

    jbassking

    Joined:
    Feb 27, 2014
    Posts:
    118
    I was immediately
     
  6. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,890
    Then try deleting Library.

    Also consider that you are making a GIANT leap technologically. If you run into such a big issue, I would stop and go back to 2020 and start upgrading to 2020.3 then 2021.3 subsequently to check if that issue occurs there. If so it may make it easier to narrow it down. Also trying 2023.1 can't hurt.

    Of course you shouldn't do that with the active project, always change editor versions in a copy of the project respectively keep a backup.
     
  7. stonstad

    stonstad

    Joined:
    Jan 19, 2018
    Posts:
    659
    Can confirm that deleting \library (with editor closed) is the first step to reclaiming iteration performance. It will never be as good as 2019/2020, but this should help.
     
  8. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,890
    Copy your project, delete the Library, open it with 2019.4. If necessary hard-fix any script errors eg comment some lines out. Then see if the project is that much faster.

    In my tests taking a Unity 2017 project and upgrading it all the way up to 2023.1 the 2019.4 version was the slowest overall. It was also the last version which did not have the "Hold on" progress bar. I think it's a myth that 2019 and early 2020 versions were faster - they just did not show the progress bar.
     
  9. stonstad

    stonstad

    Joined:
    Jan 19, 2018
    Posts:
    659
    Every project is unique and will manifest different iteration performance bottlenecks. In general terms, iteration performance after 2019.2 did in fact become slower due to the various reasons discussed here: https://forum.unity.com/threads/improving-iteration-time-on-c-script-changes.1184446/
     
  10. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,890
    I measured this in two projects, one actual project I worked on and one where I slammed as many scripts into that I could find that also worked across all versions. 2019 was the slowest for assembly reload overall, 2021 was doing good, 2022 dipped a little, then 2023.1 provided a 50% speed increase.

    Like you said every project is different. Unity also explained that you cannot compare new projects across versions, specifically due to the changes and number of packages installed by default. If you take one project and upgrade it however, you are likely to see relatively little performance impact.
     
  11. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,739
    If you take one project and upgrade it you consistently see worse iteration times.

    Within the same version as time goes by, you see minor improvements, but overall the trend from major version to major version is still worse. This is because more and more code is moved from C++ land to C#, and even though there is a lot of effort going towards mitigating the problem, with a lot more C# code it is inevitable that things will get worse.

    2019 was faster than 2020 and 2021, but it was also still pretty bad.

    I haven't tested 2022 extensibly because it has blocker bugs, and also is slow in new ways: for example, the almost instant shader compilation times in 2021 and earlier, is now slow and makes the editor hang for a few seconds. This is on a minimal repro, it's much worse on a real project:


    Therefore I did not bother with measuring assembly reloads and other stuff, I did not get that far before I encountered showstoppers.

    But one of the reasons the myth that newer versions are a bit faster is perpetuated, is because of the removal of Collaborate, which made everything super slow, but that has little to do with the editor itself getting slower.

    With that said, 2-4 minutes far outpaces the decay of iteration that Unity has, so something is wrong. Let us know if deleting the Library and reimporting has changed anything at all.
     
    Last edited: Dec 13, 2023
  12. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,890
    Interestingly the video shows that the newer Unity version enters playmode faster but then does some stuf asynchronously causing the framerate to dip.

    In any case you would normally disable domain reload if you enter playmode often, as this makes it near instantaneous. No idea about whatever happened in that dialog, it may be shaders, but I've never before encountered this in any project entering playmode.

    My measurements are further down in this thread: https://forum.unity.com/threads/whats-the-fastest-unity-version-2017-2023.1486416/

    Mileage may vary but the real urban myth here is that 2019 is the fastest. You still get to hear that from time to time. Hardly anyone is saying that newer Unity versions are becoming faster.
     
  13. AcidArrow

    AcidArrow

    Joined:
    May 20, 2010
    Posts:
    11,739
    That is not what is happening. Don’t know where you got the “does some stuf asynchronously”. What stuff? It’s a repro project, it has zero user scripts in it.
    You are.
     
  14. jbassking

    jbassking

    Joined:
    Feb 27, 2014
    Posts:
    118
    deleting the Library folder seemed to have helped some but it still takes ~1 min without any changes.
     
  15. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    5,890
    I know. I'm also hardly anyone. ;)