Search Unity

Compatibility across Unity versions

Discussion in 'Asset Bundles' started by liortal, Sep 17, 2018.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Is there any way of knowing whether asset bundles are compatible across clients built with different Unity versions?

    For example, consider 2017.1.1 and 2017.4.x
    • Will a client built with 2017.1.1 be able to load asset bundles built using 2017.4.x ?
    • Will a client built with 2017.4.x be able to load asset bundles built using 2017.1.x ?
    • Is there any rule of thumb regarding this?
    • Is there any place in the release notes or some other place that publishes "changes that break compatibility" ?
    How are you handling scenarios where you must live with clients and asset bundles made with different versions? how are you managing this ?
     
    Petr777 likes this.
  2. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    332
    • Will a client built with 2017.1.1 be able to load asset bundles built using 2017.4.x ?
      • No, we do not support forward compatibility in Asset Bundles. It may work if you try it due to how our data serialization format works in Asset Bundles. (See notes below)
    • Will a client built with 2017.4.x be able to load asset bundles built using 2017.1.x ?
    • Is there any place in the release notes or some other place that publishes "changes that break compatibility" ?
      • Yes, we support backwards compatibility in Asset Bundles. However, there will be cases that we must break backwards compatibility and these should appear in the Upgrade Guides docs. Please note that sometimes the notes only state that "X must be rebuilt, or Y is not Backwards compatible" and don't call out AssetBundles specifically, however these also apply to AssetBundles usually.
    • Is there any rule of thumb regarding this?
      • Rule of thumb is: Backwards compatibility is supported and we have a page that should call out breaking changes. However, loading backwards compatible data can cause slower load times as we have to perform a safe load of the data instead of the faster stream load for compatible data.

    Technical Notes:
    Unity's binary serialization (used by player data, asset bundles, library folder, editor set to binary assets, etc) has support for backwards compatibility. This support system, type trees, basically describe how the binary data is laid out. Our loading path reads the type tree for an object, and checks if it can use the fast loading path, if the type tree matches the loading runtime exactly, or if it needs to use the safe loading path. Type trees are only built into serialized binary data for the Library folder, Editor set to binary assets, and Asset bundles by default, not player data. So you will always need to rebuild any data built with the player (plugins, resources, Scenes in Build Settings, etc). Also there is a build option to disable type trees in asset bundles, which slightly reduces memory overhead during load, but at the cost of backwards compatibility. If the serialized data does not contain type trees, the loading system falls back to looking at the Unity version number (down to the release number) used to build the data (2017.1.0f1 vs 2017.1.0f3) and if they don't match, then it says it is not compatible and fails loading, otherwise it loads using the fast path.The safe path is slower so if performance is a concern, I recommend rebuilding your bundles for the current runtime and downloading all changed bundles. The asset bundle manifest contains a type tree hash you can use to see if the data changed just due to a type tree change.
     
    Petr777 and liortal like this.
  3. mgear

    mgear

    Joined:
    Aug 3, 2010
    Posts:
    9,448
    just curious that, would it be complicated to have 'asset bundle upgrader'-feature in unity?

    so if you open project with those old asset bundles, with newer unity version,
    upgrader would use the "safe loading" to get data in, and then dump data into new fast format?

    because rebuilding bundles was pretty slow last time i tried..(when supporting 3 platforms too)
     
  4. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Thank you for the detailed reply @ryanc-unity
    Not sure it's directly related to Asset bundles, but still a concern from our side before doing the upgrade now: is the Unity serialization format compatible across Unity versions? (e.g: can scenes built on a newer unity version be opened on an earlier version?)

    For example, in our company, after upgrading to Unity 2017.4.x we would have to still support older clients built with Unity 2017.1.

    To do that, i am not sure we'll be able to upgrade our project to 2017.4 and then build the content using Unity 2017.1 from that (not sure the scenes / prefabs will still be compatible).
     
  5. thesanketkale

    thesanketkale

    Joined:
    Dec 14, 2016
    Posts:
    65
    If you are talking about asset bundles build than it is related but from your explanation of the problem seems that you are talking about a unity project's build.
    But nevertheless, you should be able to upgrade to newer unity version with much less chaos as with unity's API updater will run through your code and update obsolete APIs. Also, the scenes and prefabs should work the way they were except that you were upgrading from a really old unity version, which does not seem like your case.
     
  6. thesanketkale

    thesanketkale

    Joined:
    Dec 14, 2016
    Posts:
    65
    Is there a way to get the name of unity version from which the asset bundle was built from?
    I went through the docs, but couldn't find one. Right now it just throws an error while loading the asset bundle built from an incompatible unity version. The exception doesn't even get caught by try-catch blocks.
    Is there any way that I can put a check before loading the asset bundle and not get the game crashed?
     
    CloudyVR likes this.
  7. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,562
    Not sure there's any API for that, but you could take matters into your own hands and add some metadata into the asset bundle (e.g: include a text file that has all of the info that you need).
     
  8. GXMark

    GXMark

    Joined:
    Oct 13, 2012
    Posts:
    515
    Asset Bundle compatibility for my project means i can't use them at all. Way to risky to make assets sell them on an in world asset store and suddenly find they all need rebuilding. A Kan No Du Thing !
     
  9. Digika

    Digika

    Joined:
    Jan 7, 2018
    Posts:
    225
    3 years later not a sniff of the page. Classic.