Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

Does Addressables fix any of the issue I have with AssetBundles?

Discussion in 'Addressables' started by LightStriker, Jan 13, 2021.

  1. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,662
    There's a long list of issue with AssetBundles, and while I looked over the Addressable documentation, there's no mention if the new system fixes any of the major flaws the old system has. Our game has all its inventory in asset bundles, but we are making our first major expansion pack. So I'm giving the Addressable a look.

    • Asset Duplication: The biggest issue, if you have 2 bundles, each with a prefab, they will each fully package their dependencies in their bundle. Meaning if 2 bundles reference say the same animation, that animation will exists in those 2 bundles. And once loading those 2 bundles, I'll have twice the same animation in memory. This issue explodes very quickly when you start factoring in shaders, material, textures, etc.
    • SpriteAtlas: For some reason SpriteAtlas and AssetBundles never worked well with each other. The "Include in Build" flag is a big source of headache. Ether the atlas works in game and not in the editor, or vice versa... or end up duplicated in memory in the build. Why would you package your SpriteAtlas? Because if one bundle reference it, it get duplicated. If 20 bundles references it, you run out of memory. Our only solution was to bundle our atlas, then load them up at boot.
    • AudioMixer: Oh God. Where to begin. Well... read SpriteAtlas. It's the same garbage, except you blow up your audio thread with hundreds of mixers instead of blowing up your RAM.
    • Reference by Path: In AssetBundle, when scripting your build pipeline, you reference an asset by path. Which means if it's a mesh - say a FBX - you end up packaging everything at that path, not just the specific asset you want, like an animation. If you package hundred of animation, you also package hundred of mesh exported in those FBX. Nice.
    • Load by Type: Haha! Never do that. Not in AssetBundles, nor in Ressources. Everything is loaded, then discarded when it's not the right type. There's no header to know what's in a bundle or the ressources package. You have a 250Mb ressources package? Everything is loaded. Yeah... no. Does Addressable handles typing without loading?
    • Platforms: You know how you need to package the same AssetBundle for every. single. damn. platform? And when you place them in StreamingAssets, they get built with every. single. damn. platform. So you need to erase the wrong platform and rebuild the one you're building. In our case, it's 15 mins of bundle building added. The Asset Pipeline v2 was supposed to make switching platform a breeze! But nope. I still have 6 different version of the game on my drive. One for every. single. damn. platform. Because otherwise I could forget the wrong bundles for the wrong platform. There's no way to tell Unity to only package a set of bundle from the StreamingAssets; everything is copied.
    How's the Addressables fairing with those issues?
     
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,614
    Hey there! I'll flag these with the team, and will be in touch with any insight.
     
  3. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    606
    Hey @LightStriker, so to address your points:
    • Asset Duplication: If you have assets A and B, both Addressable and in different groups (or in the same group but with Pack Separately mode set), that both point to animation C then C will get pulled into both of those bundles if only A and B are marked Addressable. However, if you make C Addressable and put it in it's own group/AssetBundle then the data will not be duplicated. The AssetBundles for A and B will have a dependency on the AssetBundle that contains C. We actually have some Analyze tools that will show you what is getting duplicated in various bundles and give you a (dumb) option to pull all duplicates out into their own bundle. From there you can, of course, organize the assets any way you see fit.
    • SpriteAtlas: For the SpriteAtlas issue it sounds like having your SpriteAtlas pulled into its own Addressable group, like the animation C example above, would solve most of the trouble you're experiencing with the SpriteAtlas getting duplicated to the point of running out of memory. I can't guarantee that there no headache involved with SpriteAtlas, though.
    • Audio Mixer: If I understand the issues correctly this sounds like it could be solved by following the examples already discussed.
    • Reference by Path: In most cases you'll likely find that this still happens. There are cases where if a prefab directly references a sub-object then only the sub object will get pulled in. So if you direct reference those animation in a prefab that's marked Addressable it should work.
    • Load by Type: The way our content catalog works should mitigate this issue. We store key/type pairs into our catalogs which get stored in our Resource Locators. We iterate through our resource locators to find key/type matches before requesting the asset. Now, it may such that when the asset bundle is requested the entire asset bundle gets loaded. I believe this depends on the compression used to the asset bundles.
    • Platforms: so for this one you will still need to build your Addressable content for every platform, no way around that. However, we actually store the result of the build into a platform specific folder in the Library. Then when you build your actual player we copy the correct Addressable content build into streaming assets for you and clean it up at the end. So, not a total win on that one but it should be a lot more convenient than doing it all manually.
    I hope that helps!
     
  4. LightStriker

    LightStriker

    Joined:
    Aug 3, 2013
    Posts:
    2,662
    So... The big issues; asset duplication is still a big underlying issue in Addressable, and requires lot of manual operation to make sure it doesn't blow up in more limited platforms. It still fights with SpriteAtlas with that dumb "Include in Build" flag. There's still no way to flag asset as being part of the game because the game and the bundle pipeline doesn't talk to each other, so bundles never know that say... Standard Shaders are already part of the game.

    Guess I'll stick with scripted bundle pipeline for now, even if I deeply hate it.
     
unityunity