Search Unity

Scriptable Build Pipeline with Asset Bundles issues

Discussion in 'Addressables' started by jnoffke, Mar 18, 2019.

  1. jnoffke

    jnoffke

    Joined:
    Nov 26, 2013
    Posts:
    31
    I've run into some issues with the Scriptable Build Pipeline (SBP) and am not sure if this is intended behavior, or will be fixed in the future.

    I wanted to use the SBP with our current Asset Bundle work-flow. So after reading through the documentation, I switched over to using the CompatibilityAssetBundleManifest class. However, it seems it's assumed that this file will live inside your unity project somewhere, as it is a ScriptableObject. In our project though, it lives on a server or on disk somewhere not in the Unity build. The old AssetBundleManifest class was always contained in an AssetBundle, so loading it was relatively easy. The new one is not however. I can get around this just by creating an instance of CompatibilityAssetBundleManifest and adding an extension method to parse the file manually. It's doable, but seems like there should be built in functionality for reading the file from a Stream. Also, there seems to be a bug when the CompatibilityAssetBundleManifest gets serialized to file in which it does not insert a new line for asset bundles that have dependencies. So the next info entry item ends up on the same line as the last entries dependencies. I can parse around this, but seems like it should be fixed on your side.

    The next issue I ran into is folders marked as an Asset Bundle are not built. I had to explicitly set each asset in the folder to be in the asset bundle. This differs from the old system, where I could just mark an entire folder as a bundle. This may be an intentional change, if so it was not clear to me. I know the Asset loading path behavior changed and now requires a full path to avoid naming collisions. If this is an intentional change, I believe that should be noted in the SBP documentation explicitly as lot's of people may be using folders as Asset Bundles.

    The last issue I ran into was that asset names now seem to be case sensitive. Where as using the old system, all asset names seem to be converted to lower case on the build of the asset bundle. Not sure if this is intended behavior or not either.
     
  2. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    > CompatibilityAssetBundleManifest
    Thanks for the feedback on this item, it definitely needs some additional work as you said to make it easier to migrate.

    > The next issue I ran into is folders marked as an Asset Bundle are not built.
    That's definitely a bug that I fixed recently. Required an editor change however that went out in 2019.2.0a6, 2019.1.0b5, and 2018.3.8f1

    > The last issue I ran into was that asset names now seem to be case sensitive.
    Hmm, I thought I made that fairly clear in the documentation. I'll review the docs and clarify it where it isn't clear already. As for restoring the older behavior, use the example here to change how you want to load: https://docs.google.com/document/d/...rwPu6ak0kfELz6ilc/edit#heading=h.9bib8u2laqcx
    In that example we changed it to load just by filename itself, but you can change it to just ToLower() the path instead.
     
    mepkatatsu and MNNoxMortem like this.
  3. jnoffke

    jnoffke

    Joined:
    Nov 26, 2013
    Posts:
    31
    Thanks for the reply. I was using 2018.3.7. So after updating to 2018.3.9, I was able to confirm the folders marked as asset bundles were built properly.

    I guess I just missed the part about case sensitivity. I do it see it now under DisableLoadAssetByFileName.

    I would like to suggest one feature for building asset bundles in the future. It would be nice to know which asset bundles were actually rebuilt. Currently, it's just kind of a black box. I tell Unity to rebuild the asset bundles, it determines which ones need to be built, and builds those. I've never been able to find a built in way to determine which bundles actually got rebuilt. I can get around it by storing the old manifest and comparing it to the new manifest now. Just always thought it'd be kind of nice to have this built in functionality though.
     
    MNNoxMortem likes this.
  4. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    Would you want knowledge of what was rebuilt just from the last time you last built bundles (or anyone if you are using Cache Server integration) or from some flagged version?

    One possible option is to inject the ProgressLoggingTracker (or a custom one) and parse the results from that as we append " (cached)" to the event when we update the tracker. So during the Archive task, you would just grab all events that don't have that appended, and that is what changed. Though thinking about it, I am not sure if I made it easy or not to inject a custom tracker...will double check the api.
     
  5. jnoffke

    jnoffke

    Joined:
    Nov 26, 2013
    Posts:
    31
    All I need to know is just what was built from the last time bundles were built. I just want to know so I know what changed and what needs to be copied or uploaded. I'm sure other users may have other needs for this as well.

    We're currently not using the cache server integration, but I had planned on looking into it at some point in the near future.

    I'm not really familiar with the PrgoressLoggingTracker. So, that's something I'll have to look into.
     
  6. tkslan

    tkslan

    Joined:
    Sep 30, 2016
    Posts:
    28
    Hi, got some problems with upgrade to SBP. We are using Dry Run build option to determinate if bundle is outdated or not. It took around 10secs to check all bundles in project. Now seems that correct way is to rebuild outdated, but it takes far more time. Any hints how to check bundle state and not to rebuild it ?
     
  7. tkslan

    tkslan

    Joined:
    Sep 30, 2016
    Posts:
    28
    Edit: Made some research and seems that good option is to call build tasks only till post packing event, then grab Hash128 from this point. But...seems like there is difference in Post Packing hash and hash generated from cooked bundle... In case of ~10k files packed in bundles still there is not the best option to build from scratch each time, looks like Library/BuildCache also growing fast in size...
     
  8. mepkatatsu

    mepkatatsu

    Joined:
    Jun 8, 2023
    Posts:
    2
    You can achieve a case-insensitive Scriptable Build Pipeline by utilizing AssetBundleBuild.addressableNames.
    However, keep in mind that this method loads assets in lowercase, which may lead to case-sensitivity issues compared to using BuildPipeline.
    Here's the code to apply:

    Code (CSharp):
    1. var assetBundleBuilds = ContentBuildInterface.GenerateAssetBundleBuilds();
    2. for (var i = 0; i < assetBundleBuilds.Length; ++i)
    3. {
    4.     assetBundleBuilds[i].addressableNames = assetBundleBuilds[i].assetNames
    5.         .Select(e => e.ToLower()).ToArray();
    6. }
    By using this code, you can build and load assets with their paths converted to lowercase.
    While you could call ToLower() each time you load, doing so would generate a significant amount of garbage and negatively impact performance.
    Therefore, after minimizing cases of accidental incorrect calls by converting to lowercase during the build of tables and similar components, we adopted a strategy of checking if the load was successful (null check) when loading and, in case of failure, loading in lowercase as a backup.

    Thank you so much, Ryanc_unity.