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. Dismiss Notice

Question How can I figure out what is taking so long during AssetDatabase.Refresh?

Discussion in 'Asset Database' started by darthdeus, Aug 16, 2020.

  1. darthdeus

    darthdeus

    Joined:
    Oct 13, 2013
    Posts:
    53
    For some reason every time I make a code change in Unity I get a "AssetDatabase.Refresh" loading modal that takes at least 5 seconds to run before the editor becomes responsive. This is really with any code change, even after removing basically all of my 3rd party assets, and after searching my project for explicit calls to AssetDatabase.Refresh.

    I've tried running the profiler on the editor as the reload happens, as shown in the image below, and indeed the main cause is the AssetDatabase.Refresh call.

    Looking further down the hierarchy, this seems to be related to the ReloadAssembly call, which makes me ask ... can I somehow trace this and figure out which assemblies are actually taking so long? I've tried attaching the JetBrains dotTrace profiler, but it doesn't want to attach to the Unity editor, and I'm not sure what other options are there.

    I also found a few issues that could be possibly related to this? https://issuetracker.unity3d.com/is...tes-slower-when-compared-to-previous-versions and https://issuetracker.unity3d.com/issues/focusing-the-editor-window-causes-noticeable-slowdowns



    Am I the only one experiencing this? Unity was never this slow to me, but recently I'm just losing my mind over having to wait up to 10 seconds on every single code change. This is on a Ryzen 9 3900X with 64GB RAM and an NVMe SSD, and a somewhat small indie game developed by basically one person over the past month with a few assets.
     
  2. PraetorBlue

    PraetorBlue

    Joined:
    Dec 13, 2012
    Posts:
    7,722
    What version of Unity is this?
     
  3. darthdeus

    darthdeus

    Joined:
    Oct 13, 2013
    Posts:
    53
    Currently on 2020.1.2f1.
     
  4. darthdeus

    darthdeus

    Joined:
    Oct 13, 2013
    Posts:
    53
    BigHandInSky and PraetorBlue like this.
  5. gcast1995

    gcast1995

    Joined:
    Oct 27, 2019
    Posts:
    25
    So I'm still getting a 5-6 second delay on a very small project. Was this bug actually fixed...?
     
  6. darthdeus

    darthdeus

    Joined:
    Oct 13, 2013
    Posts:
    53
    Take a look at the resolution notes here https://issuetracker.unity3d.com/is...slow-asset-reimport-when-modifying-any-script ... if none of them apply to your project, submit a bug report so Unity can take a look at it. They won't be able to fix more of these problems unless they have something to reproduce it with.