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 Difference between "Bundle Dependencies" and "Expanded Bundle Dependencies" in buildlayout.txt?

Discussion in 'Addressables' started by Peter77, Aug 15, 2021.

  1. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,444
    The buildlayout.txt contains sections for
    Bundle Dependencies
    and
    Expanded Bundle Dependencies
    .

    What's the difference between them? What's an "expanded" bundle dependency?

    Code (CSharp):
    1. Archive r-level-metagame_assets_assets/scenes/metagame/content_a896343d0e652254a366918dc009d2f2.bundle (Size: 1.9MB, Compression: Lz4HC, Asset Bundle Object Size: 2.66KB)
    2.     Bundle Dependencies: defaultlocalgroup_unitybuiltinshaders_ef4f4760a7f78f4f8bb2c5d0644f4c8c.bundle, lr-shaders_assets_assets/shaders/diffuse_0ec2c1ff425aab90bae7b7c79f964d1e.bundle, lr-shaders_assets_assets/shaders/skybox_d462d33dcf229743347514b3f7561b1f.bundle
    3.     Expanded Bundle Dependencies: r-theme-shared_assets_assets_all_6f5ec336d1378dc9910d3b9871c4a2fb.bundle, lr-shaders_assets_assets/shaders/shaderforge_3b90b9f4ad2cef942e7b83e2df31fc6e.bundle, defaultlocalgroup_monoscripts_48eef9bf5ed5a3584cd1e8dd9725f4e1.bundle
     
    Jonas-Neuston likes this.
  2. TreyK-47

    TreyK-47

    Unity Technologies

    Joined:
    Oct 22, 2019
    Posts:
    1,796
    I'll ping the team for some insight.
     
    Peter77 likes this.
  3. davidla_unity

    davidla_unity

    Unity Technologies

    Joined:
    Nov 17, 2016
    Posts:
    736
    Bundle dependencies should be the dependencies one layer deep, the expanded dependencies should just be the rest of the dependency tree in a flattened list.

    So if A depends on B, C and C depends on D, E, F then Dependencies for A would just be B, C but the Expanded Dependencies for A would include D, E, F.
     
    phobos2077 and Peter77 like this.
  4. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,444
    Thank you for the answer.

    Your explanation makes perfect sense for me, but it's somehow not what I see in the buildlayout file.

    I tested it in a new project where I can test it in isolation, because in my actual project, it's way too difficult to understand.

    I created 4 Prefabs:
    1. Prefab_A with a hard-reference to Prefab_B
    2. Prefab_B with a hard-reference to Prefab_C
    3. Prefab_C with a hard-reference to Prefab_D
    4. Prefab_D has no reference
    I created 4 bundles:
    1. Bundle_A contains Prefab_A
    2. Bundle_B contains Prefab_B
    3. Bundle_C contains Prefab_C
    4. Bundle_D contains Prefab_D
    According to your reply, I assumed the dependencies for Bundle_A are:
    Code (CSharp):
    1. Bundle Dependencies: bundle_b_assets_all.bundle
    2. Expanded Bundle Dependencies: bundle_c_assets_all.bundle, bundle_d_assets_all.bundle
    However, the dependencies are actually this:
    Code (CSharp):
    1. Bundle Dependencies: bundle_c_assets_all.bundle, bundle_d_assets_all.bundle, bundle_b_assets_all.bundle
    2. Expanded Bundle Dependencies:
    Is this a bug or is my assumption wrong and I didn't understand what you were saying? I've attached my test project in case you want to take a look at it.

    upload_2021-8-19_17-26-22.png
     

    Attached Files:

    Last edited: Aug 20, 2021
  5. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    Maybe he meant transitive dependencies on an asset level, not on a bundle level? Trying maybe having some explicit entry in Bundle A reference an implicit entry in Bundle B (asset not directly added to group).
     
    Peter77 likes this.
  6. Peter77

    Peter77

    QA Jesus

    Joined:
    Jun 12, 2013
    Posts:
    6,444
    Thanks for your reply. This lead me to do more trial&error.

    I found what seems to cause something to become an "expanded dependency". It's complicated to describe, but let me try.

    Prefab setup:
    1. Prefab_A has a hard-reference to Prefab_B
    2. Unused_A has a hard-reference to Sprite_A
    3. Unused_B has a hard-reference to Sprite_B
    Bundles:
    1. Bundle_A contains Prefab_A and Unused_A
    2. Bundle_B contains Prefab_B and Unused_B
    3. Bundle_Sprite_A contains Sprite_A
    4. Bundle_Sprite_B contains Sprite_B
    The prefabs Unused_A and Unused_B are not referenced, but they are stored in a bundle that contains an asset that is referenced and thus pull in an "expanded dependency" to their assets stored in another bundle.

    Bundle_A has these dependencies:
    Code (CSharp):
    1. Bundle Dependencies: bundle_b_assets_all.bundle, bundle_sprite_a_assets_all.bundle
    2. Expanded Bundle Dependencies: bundle_sprite_b_assets_all.bundle
    It seems the "expanded dependencies" list represents bundles whose assets are not referenced by the entire dependency chain of any explicit asset in the bundle, but are pulled in because they are dependencies of non-referenced assets in the same bundle.

    However, this behavior is not what @davidla_unity described in my opinion.
     

    Attached Files:

    phobos2077 likes this.
  7. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    Based on what I see in buildlayout of my project, it looks to be fairly accurate. I'll try to put it this way:
    - If any of the explicit or implicit entries in the Bundle A have hard references to entries in Bundle B, then Bundle B is a "direct" bundle dependency.
    - If, in turn, Bundle B has a direct bundle dependency to Bundle C, but Bundle A is not dependent on Bundle C directly, then Bundle C will be an "Expanded" bundle dependency on Bundle A.

    This explains your first experiment. Because you had a long chain of hard references between your prefabs, to load the Prefab A in memory you need to load all other bundles, because they have required asset-level dependencies. However in the second example, to load Prefab A you only need Bundle B (which contains Prefab B), but you don't need Unused A/B. So there is no direct bundle dependency. But if you were to load Unused B by it's address, Unity will require both Bundle B and Bundle_Sprite_B to be loaded in order to do that. So it makes sense to load both direct and expanded dependencies before you can load anything.

    So in the end I think @davidla_unity description was accurate. If you first calculate direct dependencies between bundles based on asset dependency graph, and then consider the result on a bundle-level, it all makes sense. Expanded dependencies are transitive dependencies on bundle-level, not asset-level.
     
  8. einWikinger

    einWikinger

    Joined:
    Jul 30, 2013
    Posts:
    93
    I have *way* too many expanded dependencies for my bundles. If the theory is right, I should end up with the same list of bundles as the expanded dependencies by walking through the direct dependencies and noting down every bundle I encounter. But that list is much smaller (like, 5 bundles instead of 200) than the expanded dependencies suggest.