Search Unity

Bug Asset bundle built from Unity 2021.3.9f is broken in older Unity version

Discussion in 'Asset Bundles' started by kkl888, Mar 27, 2023.

  1. kkl888

    kkl888

    Joined:
    Dec 6, 2014
    Posts:
    55
    Had this error when trying to use asset bundle built from 2021.3.9f or newer in older Unity version (2021.3.2f)

    Failed to decompress data for the AssetBundle 'Memory'.


    Steps to reproduce:
    1. Build asset bundle in 2021.3.9f or newer.
    2. Open the project in older Unity version 2021.3.2f and load the asset bundle.

    It seems like the 2021.3.9f or newer Unity version's asset bundle is not backward compatible to older Unity project built. This causes a problem for our project as we need to upload new asset bundle for our existing apps that are already in Play/App Store. This issue affects Android and iOS platform. We have not tested other OS platforms and might have the same issue as well. No issue when loading the asset bundle with 2021.3.9f or newer.

    Please help to advise if there's any workaround.
     
    Last edited: Mar 27, 2023
  2. AndrewSkow

    AndrewSkow

    Unity Technologies

    Joined:
    Nov 17, 2020
    Posts:
    91
    This sounds like a side effect from a change to the archive file format that went into 2020.3.34f1, 2021.3.2f1, 2022.1.1f1 and 2022.2.0a8

    This introduces some new padding bytes, so that data is better aligned, which helps performance and also makes patching work properly on certain platforms. https://issuetracker.unity3d.com/is...undaries-breaking-patching-on-nintendo-switch

    The fix is backward compatible, meaning that newer versions of Unity can successfully to read AssetBundles built without those padding bytes. But the change is not forward-compatible, meaning that older versions of Unity without the padding code cannot read newer AssetBundles. Normally Unity is NOT forward-compatible, otherwise we would be unable to make any improvements to the file format at all, and its quite rare that this format changes at all. However it is unfortunate when a small adjustment to the format like this causes trouble, such as in the scenario you describe. To work properly the apps should be rebuilt with the new version, or, until upgraded, you should use the same version of Unity to build bundles as you used for your player build.
     
  3. kkl888

    kkl888

    Joined:
    Dec 6, 2014
    Posts:
    55
    Thanks @AndrewSkow for the detailed information. That explains a lot why existing apps no longer works with latest asset bundle. I guess we have to force players to update app instead. We heavily refer to the Unity changelog when we upgrade the Unity version. Is it ok if this sort of info is included in the changelog, such as "forward-compatible breaking change"? We can then plan ahead to force player update apps before releasing new asset bundle.
     
  4. AndrewSkow

    AndrewSkow

    Unity Technologies

    Joined:
    Nov 17, 2020
    Posts:
    91
    Yes you make a good point. If there any further AssetBundle format changes we will do our best to flag that a lot more clearly in the change log. So far I am not aware of any bugs or improvements in our bug pile that would impact forward compatibility for AssetBundle files.
     
    kkl888 likes this.
  5. kkl888

    kkl888

    Joined:
    Dec 6, 2014
    Posts:
    55
  6. Bmco

    Bmco

    Joined:
    Mar 11, 2020
    Posts:
    54
    Hello, I have a live program built with 2021.3.6 that contains several Asset Bundles. I recently upgraded to 2021.3.34, built a new AB and the current build isn't reading them. Can you confirm the format changes are the reason for this?
     
  7. AndrewSkow

    AndrewSkow

    Unity Technologies

    Joined:
    Nov 17, 2020
    Posts:
    91
    Unity does not have forward compatibility, so a player build with an earlier version of Unity is unlikely to be able to read content built with LATER releases of Unity. What works better is the backward compatibility case, but even then its not certain to work when doing larger upgrades of Unity.