Search Unity

Feedback Entering Play Mode slow due to AddressableAssetEntryCollection support in GatherAllAssets()

Discussion in 'Addressables' started by AlkisFortuneFish, Jun 27, 2019.

  1. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    972
    For a while now, we have had *incredibly* bad delays entering play mode. It got to the point where on my PC it would take 2 minutes to enter play mode.

    I attributed to having an old machine, since a little bit of profiling showed that it was just BuildScriptFastMode.BuildData() and I assumed that would have to be slow on a large project and I had other tasks to worry about.

    Nonetheless, it was still taking 40s to enter play mode on my brand new machine and I decided to have a poke. I found that out of the 40s, 28s were spend on this line in AddressableAssetEntry:

    if (AssetDatabase.GetMainAssetTypeAtPath(path) == typeof(AddressableAssetEntryCollection))


    Our project doesn't even contain any AddressableAssetEntryCollection objects! That innocuous line causes Unity to load all assets that go through that code path, textures, models, everything, only to discard the result.

    In our case, I can just comment this out and enjoy a semi-reasonable workflow, but surely this needs to be optimised?

    The AssetDatabase blatantly doesn't use an asset type cache for GetMainAssetTypeAtPath(), which means that if this has to happen like this, surely even passing down a HashSet of AddressableAssetEntryCollection asset paths, obtained via a FindAsset query with "t: AddressableAssetEntryCollection" would be preferable? I've made that modification on my end as a test and it **massively** speeds up the addressables system, all the way from opening the addressables window (which in itself was a massive slog before) to entering play mode.

    One great concern I have, is the system actually being tested on large projects on the development end? How could this have gone unnoticed? @unity_bill Please do comment, as I cannot really submit this as a bug, I'd need to somehow generate a large enough project.
     
    Last edited: Jun 28, 2019
    Zenix, christh, phobos2077 and 5 others like this.
  2. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    972
    Bump! I re-applied my patches more cleanly to 1.1.4 (by adding the set of AddressableAssetEntryCollection paths to the context) and the performance and productivity boost is maintained there. Something *really* has to be done about this before addressable can come out of preview. As far as I am concerned, while there are slowdowns as tremendous as this the system cannot be considered to be production ready.
     
    phobos2077 likes this.
  3. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    972
    I have attached my patches, for reference. If anyone wants to use them, absolutely no warranties provided, this is not fully tested. The patch file is calculated over 1.1.4
     

    Attached Files:

  4. PaulBurslem

    PaulBurslem

    Unity Technologies

    Joined:
    Oct 7, 2016
    Posts:
    79
    Hi - thanks for investigating this and bringing it to our attention - I've just added a ticket to fix this issue - It should be fixed in the next release.
     
    phobos2077, Ony, karl_jones and 3 others like this.
  5. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    972
    Thanks Paul, that's great!

    Now all I need to do is figure out how to make the next release work on our project, we've been having mystery dependency resolution issues that I've been trying to resolve since 0.6.x, last version where packed mode worked for us was 0.5.3 but I have had real issues reproducing the issues we're getting on a clean project, but that's the subject of an entire different thread once I have the time to look into it full time.
     
  6. AlkisFortuneFish

    AlkisFortuneFish

    Joined:
    Apr 26, 2013
    Posts:
    972
    Any updates on when the fix for this is going to land? Currently I have to apply my patches on every new version. Also, how is the fix being tested? Is there any performance testing being applied across the board, with a larger project with loads of assets? With my patches we're down to entering play mode in 6s or so, it would be rather jarring to go back to the original astronomical times!

    I mean, I could always keep applying my patches, but a fully endorsed fix would be better! :)
     
    Last edited: Aug 21, 2019
    phobos2077 likes this.