Search Unity

Addressable loading 10x slower than normal + Unknown Assembly error + Feedback

Discussion in 'Addressables' started by RakNet, Aug 7, 2019.

  1. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    116
    My game is quite large and has some resources that I don't need until later in the game, and they aren't tied to a particular scene. I load these resources asynch during loading screens.

    I was putting these assets into a /Resources directory, which worked fine until I tried making a build and found out that you can't have more than 4GB of Resources.

    The easy solution, which in hindsight I should have gone with, is to just put everything into a master scene load that scene as a substitute asset bundle. However, I am stubborn and have wasted two days trying to get a better solution.

    Which brings me to the new Addressable system. In FastMode everything works fine, load speed is good, so far so good. I can't load synchronously, which is a huge design flaw and created a lot of bad architecture but that's another topic.

    The topics for this post...

    First issue: Building assets for packed play mode, I'm spammed with

    Code (CSharp):
    1.  
    2. Unknown Assembly ModV1
    3. UnityEditor.Build.Content.ContentBuildInterface:GetPlayerDependenciesForObjects(ObjectIdentifier[], BuildTarget, TypeDB)
    4. UnityEditor.Build.Pipeline.Tasks.CalculateAssetDependencyData:Run() (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.5.2\Editor\Tasks\CalculateAssetDependencyData.cs:107)
    5. UnityEditor.Build.Pipeline.BuildTasksRunner:Run(IList`1, IBuildContext) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.5.2\Editor\Shared\BuildTasksRunner.cs:50)
    6. UnityEditor.Build.Pipeline.ContentPipeline:BuildAssetBundles(IBundleBuildParameters, IBundleBuildContent, IBundleBuildResults&, IList`1, IContextObject[]) (at Library\PackageCache\com.unity.scriptablebuildpipeline@1.5.2\Editor\ContentPipeline.cs:118)
    7. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode:DoBuild(AddressablesDataBuilderInput, AddressableAssetsBuildContext) (at Library\PackageCache\com.unity.addressables@1.1.7\Editor\Build\DataBuilders\BuildScriptPackedMode.cs:132)
    8. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptPackedMode:BuildDataImplementation(AddressablesDataBuilderInput) (at Library\PackageCache\com.unity.addressables@1.1.7\Editor\Build\DataBuilders\BuildScriptPackedMode.cs:90)
    9. UnityEditor.AddressableAssets.Build.DataBuilders.BuildScriptBase:BuildData(AddressablesDataBuilderInput) (at Library\PackageCache\com.unity.addressables@1.1.7\Editor\Build\DataBuilders\BuildScriptBase.cs:60)
    10. UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContentImpl() (at Library\PackageCache\com.unity.addressables@1.1.7\Editor\Settings\AddressableAssetSettings.cs:1608)
    11. UnityEditor.AddressableAssets.Settings.AddressableAssetSettings:BuildPlayerContent() (at Library\PackageCache\com.unity.addressables@1.1.7\Editor\Settings\AddressableAssetSettings.cs:1590)
    12. UnityEditor.AddressableAssets.GUI.AddressableAssetsSettingsGroupEditor:OnBuildPlayerData() (at Library\PackageCache\com.unity.addressables@1.1.7\Editor\GUI\AddressableAssetsSettingsGroupEditor.cs:239)
    13. UnityEditor.GenericMenu:CatchMenu(Object, String[], Int32) (at C:\buildslave\unity\build\Editor\Mono\GUI\GenericMenu.cs:121)
    14.  

    ModV1 among other assemblies are used by my game to hold external code.

    I created a link.xml to try to include this, not sure if it's needed, the docs aren't really very helpful as to when to use link.xml, why I would use it, or even how to use it or where to put it.
    <linker>
    <assembly fullname="ModV1" preserve="all"/>
    </linker>

    Anyway, if I ignore the error and run the game it does appear to load.

    Here is part of link.xml at Client\Library\com.unity.addressables\StreamingAssetsCopy\aa\Windows\link.xml

    <assembly fullname="ModV1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null">
    <type fullname="ModV1.AI2.AI2Ambience_SV1" preserve="all" />
    <type fullname="ModV1.AI2.AI2AmbienceAnimationEventListener" preserve="all" />
    <type fullname="ModV1.AI2.AI2AudioTrigger" preserve="all" />
    <type fullname="ModV1.Source.AIAllianceConditionalEvent" preserve="all" />

    Second issue:
    What I'm actually loading is a custom ScriptableObject that holds a List<GameObject>.I can actually load it, the problem is instead of a list of 39 GameObjects, it's a list of 39 null pointers.

    Third issue: loading takes 10X longer in packed play mode vs. local! This totally defeats the point of loading asynch during loading screens since the total time is longer.

    I don't care about loading game data from remote systems, content updates, whatever. I just want to get around the 4 GB limit. How can I load resources dynamically that
    1. Is fast
    2. Doesn't duplicate the resource (which Addressables and AssetBundles do?
    3. Doesn't have a size limit (Which Resources does)?
     
  2. unity_bill

    unity_bill

    Unity Technologies

    Joined:
    Apr 11, 2017
    Posts:
    829
    what version of addressables and the editor are you using?

    What version of the editor are you running. There were some code stripping issues in 18.3 I believe. Maybe 19.1. In any case, if you have a recent 19.2 they should be fixed.

    What if you hand edit our generated link.xml and add preserve="all" to it?
    <assembly fullname="ModV1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">

    Is it actually a List<GameObject> or is it List<SomeComponentType>?

    I'm not sure exactly what you're comparing. Packed vs Fast mode? Packed vs having things in Resources? 99% of your dev can probably be done in Fast Mode.


    1. Addressables runtime loading shouldn't be any slower than Resources. And it's almost certainly more memory efficient. Also of note, building should be significantly faster. If you have many GB of data in Resources, then every time you build the player, it will rebuild all of that content. If you have addressables, and things are split into many asset bundles (as they should be), then it'll do incremental building and only build what's changed. Should be significant improvement.
    2. Use the Addressables Analyze functionality to find and remove duplicates. -- if you do have a bunch of dupes this probably explains your 10x loading problem.
    3. use addressables. by the way, it has the 4gb limit per file too. you can just break things up into many bundles with addressables, whereas you can't break up Resources.
     
  3. RakNet

    RakNet

    Joined:
    Oct 9, 2013
    Posts:
    116
    "what version of addressables and the editor are you using?"

    It was the latest version at the time I wrote the post, I downloaded it the day before. Probably 1.1.7. Editor 2019.2.0f1

    "What if you hand edit our generated link.xml and add preserve="all" to it?
    <assembly fullname="ModV1, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null" preserve="all">"

    I can try again, but already reverted the code in favor of using scenes as resources bundles. I load the scene that contains a game object, that contains a reference to my scriptable object. Because scenes are not ready the same frame they are loaded, I had to find every place in the game code that used a resource, which I could formerly load blocking, and change it to use IEnumerator.

    "Is it actually a List<GameObject> or is it List<SomeComponentType>? "
    List<GameObject>. I wanted to clarify this, because even if it was List<SomeComponentType> that would work if I used Resources, or used my current method of using Scenes as a fake asset bundle. I need to be able to have scripts on my assets.

    "I'm not sure exactly what you're comparing. Packed vs Fast mode? Packed vs having things in Resources? 99% of your dev can probably be done in Fast Mode. "
    Comparing packed vs. resources
     
    Last edited: Aug 17, 2019 at 3:38 AM