Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Resolved Help needed. Unity takes forever to reload domain when using Visual Studio 2022

Discussion in 'Editor & General Support' started by y4n3k, Mar 27, 2023.

  1. y4n3k

    y4n3k

    Joined:
    Mar 9, 2017
    Posts:
    6
    Hello Everyone!
    I'm struggling with very strange issue. When I'm saving any script, Unity, as a part of domain reload - will move all the scenes to temporary folder and back.
    This is so fast that I never noticed it's happening. Since few days this process started to take over a minute.
    When investigating, I found out it's happening only when editing code through Visual Studio 2022.
    I've been using VS Community 2022 for almost a year together with this project. Issue started to happen last weekend.
    I'm on Unity 2022.2.11f1, I upgraded to 2022.2.12f1, then downgraded again - happens on both. It might be that it's not related to editor.

    Sometimes I would get error that Unity is not able to move the scene from Temp folder:


    Upon pressing "Try again" - it works, still takes forever.

    I tried different settings in VS but nothing makes any difference:


    As it's not so easy to explain, I made a short video where I add Debug line to clean script.
    In Visual Studio Code - reloading domain takes around 9 seconds.
    In Visual Studio 2022 - the same action over a minute.

     

    Attached Files:

  2. MelvMay

    MelvMay

    Unity Technologies

    Joined:
    May 24, 2013
    Posts:
    10,620
    Visual Studio is a just a code editor here, it doesn't control the Unity Editor.

    The error above is stating it doesn't have permission so this is a local disk permission, possibly file corruption.

    I would suggest closing the Unity Editor and Hub then try deleting the above temp folder and maybe the Library folder too then reopening the project.

    If you're not already, I would suggest using source control before you do this. In the very least, a backup.
     
  3. y4n3k

    y4n3k

    Joined:
    Mar 9, 2017
    Posts:
    6
    Thank you MelvMay for reply!
    I've deleted entire Library folder and allowed Unity to rebuild it from scratch (twice).
    The temp folder is deleted automatically once Unity Editor is closed.
    I am using source control.

    I understand that Visual Studio is just a text editor, however there is huge difference in what Unity does when I make changes to the same file (not referenced by any object or script - new empty script file).
    This might be due to some settings somewhere, no clue.


    Difference is visible when monitoring which files are written to disk.
    Visual Studio Code, saved the file at 10:34:20:


    Domain completely reloaded after 28 seconds:




    Now, when using Visual Studio 2022, saved the file at 10:43:18


    Domain completely reloaded after 91 seconds:



    Huge amount of operations that Unity is executing with VS2022, they do not happen when using Visual Studio Code (there is much more):
     
  4. y4n3k

    y4n3k

    Joined:
    Mar 9, 2017
    Posts:
    6
    Hello again.
    I think I've fixed the issue. Still not sure what exactly was causing it.
    I moved back to last week version of the project, and problem didn't show up.
    Then I went back to current (flawed) version, and I did following:
    Changed Source Control plugin in Visual Studio 2022 from Git to none. (I'm using SourceTree with BitBucket for source control)
    Removed 2 experimental packages - "Unity Collections" and "Aseprite Importer"

    As of this moment problem doesn't occur.
     
    MelvMay likes this.