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

New in Addressables 1.4.0: long time spent "Preparing Addressables Data" in BuildScriptFastMode

Discussion in 'Addressables' started by MFG-jkhoo, Nov 28, 2019.

  1. MFG-jkhoo

    MFG-jkhoo

    Joined:
    Jul 15, 2016
    Posts:
    19
    We've tried upgrading from Addressables 1.3.8 to 1.4.0.

    With 1.3.8, using BuildScriptFastMode (Asset Database), it takes less than 5 seconds between pressing play in the editor to having the game start.

    With 1.4.0, there's now a significant amount of time spent "Preparing Addressables Data" as it gathers assets. The start time after pressing play now takes over 15 seconds, over triple the startup time versus 1.3.8.

    Is there any reason why BuildScriptFastMode needs to take so much longer now?
     
    Colin_MacLeod likes this.
  2. zhuxianzhi

    zhuxianzhi

    Joined:
    Mar 30, 2015
    Posts:
    121
    me to,I'm about 5 seconds slower than version 1.3.8.
     
  3. m-nakayama

    m-nakayama

    Joined:
    Jun 12, 2018
    Posts:
    14
    ver 1.4.0
    "Preparing Addressables Data" does not finish.
     
  4. Colin_MacLeod

    Colin_MacLeod

    Joined:
    Feb 11, 2014
    Posts:
    251
    @unity_bill Is there anything we can do to reduce editor startup time with 1.4.0?
     
  5. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    736
    Hm, this is interesting. So for 1.4 we took out a bunch of unnecessary asset gathering (mainly for dependency calculations which isn't required in fast mode) when creating the Fast Mode content catalog. In our test project this actually made things quite a bit faster. Does anyone mind sharing their Addressables setup? Are you using a deep folder structure that you've added to Addressables? Do you have assets across many groups or few? I'm trying to figure out what the difference could be in our test project vs. what you guys are seeing.
     
  6. MFG-jkhoo

    MFG-jkhoo

    Joined:
    Jul 15, 2016
    Posts:
    19
    @DavidUnity3d So I think that I found the culprit:

    Code (CSharp):
    1.             foreach (var entry in assetGroup.entries)
    2.             {
    3.                 EditorUtility.DisplayProgressBar($"Preparing Addressables Data ({assetGroup.Name})", entry.AssetPath, index / assetGroup.entries.Count);
    It's the call to
    EditorUtility.DisplayProgressBar
    in this for loop that's causing a massive slowdown. For my project, if I comment-out that line, then the startup performance is restored to 1.3.8 levels.

    According to an old Tweet by Unity Engineer @superpig, EditorUtility.DisplayProgressBar should be used with caution in a for loop:
    https://twitter.com/superpig/status/215135902211641346
     
    dirty-rectangle and nih_ like this.
  7. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    736
    Yeah, I think you're right. I looked into it yesterday some and saw that when removing that it appeared to speed back up.

    I'd like to have some sort of progress indicator so projects that could take a few seconds (or longer) don't get stuck in that "Is the editor frozen?" mentality. But yeah the progress bar as it is now needs to be removed/changed. Thanks for the heads up.

    Just curious, when entering playmode when you're using the fast mode build script would you expect to see a progress bar of some kind when Addressables is building your catalog? Are you ok with not seeing anything and feel confident the editor isn't hanging? Anyone feel free to chime in. I'm curious what you'd like to see.
     
  8. rg_johnokane

    rg_johnokane

    Joined:
    Oct 10, 2018
    Posts:
    11
    Code (CSharp):
    1.             //intentionally for not foreach so groups can be added mid-loop.
    2.             for(int index = 0; index < aaContext.settings.groups.Count; index++)
    3.             {
    4.                 AddressableAssetGroup assetGroup = aaContext.settings.groups[index];
    5.                 EditorUtility.DisplayProgressBar("Preparing Addressables Data", assetGroup.Name, (float)index / aaContext.settings.groups.Count);
    6.                 var errorString = ProcessGroup(assetGroup, aaContext);
    7.                 if (!string.IsNullOrEmpty(errorString))
    8.                 {
    9.                     EditorUtility.ClearProgressBar();
    10.                     return errorString;
    11.                 }
    12.             }
    13.             EditorUtility.ClearProgressBar();
    14.  
    This in BuildScriptBase.cs works better for me. I've approx 100 groups. Also, the constant flickering that happens by putting the ClearProgressBar in BuildScriptFastMode:processGroup doesn't look good on my screen.
     
    davidla_unity likes this.
  9. MFG-jkhoo

    MFG-jkhoo

    Joined:
    Jul 15, 2016
    Posts:
    19
    @DavidUnity3d For my own project, I would be okay with returning to the 1.3.8 behavior with no progress bar. Because hitting play happens all the time, anything that increases the time spent in startup would be a negative. Personally it's acceptable if the editor "hangs" after hitting play as long as it's under 5 seconds which is the case for me.

    Perhaps another option would be a pair of console outputs:
    Addressables Building Catalog: Begin...
    Addressables Building Catalog: End - Elapsed 4.2 seconds
     
  10. MagicDesignEmerick

    MagicDesignEmerick

    Joined:
    Oct 4, 2017
    Posts:
    26
    Glad to see we're not the only ones with this behavior.
    Concerning the display bar, I agree with others, as long as it's not too long I don't need to see it, but if you find a way to display one without it slowing down the whole process then why not.

    Additionally, there's another kind of progress bar unity uses for lightmapping that feels better integrated to the engine, maybe that's an area worth looking into?
     
  11. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    736
    @MagicDesignEmerick Interesting, I'll have to check into the one for lightmapping. In the meantime we've implemented the fix suggested by @rg_johnokane so hopefully that isn't slowing anything down like the other implementation was.