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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice
  3. Join us on November 16th, 2023, between 1 pm and 9 pm CET for Ask the Experts Online on Discord and on Unity Discussions.
    Dismiss Notice

Unity AssetBundle decompression not supported

Discussion in 'WebGL' started by MaT227, Apr 27, 2017.

  1. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Hi there,

    I am working on WebGL application where we use AssetBundles. We are currently facing several problems but the first one is that it seems that we can't use AssetBundles built with Unity 5.4.3f1 in a WebGL build made with Unity 5.6.0f3.
    Is it an expected behaviour ?

    Here is the error we are having in the browser console.
    This is only happening in the WebGL build, there's no problem in the Editor.

    Another issue we are oftenly facing is the serialization of the references to the shaders in our AssetBundles. We need to setup by code some properties and and sometimes reassign the shader by hand on the material.

    Any help or advice is welcome.
    Thank you.
     
  2. Fizzer

    Fizzer

    Joined:
    Nov 16, 2016
    Posts:
    40
    WebGL asset bundles need to be built for the same major (x.y) version of Unity that they'll run on. So you have to re-build your asset bundles with 5.6.

    Standalone (windows/max/linux) asset bundles are "more advanced" and can be opened even when the version mismatches, but WebGL, iOS, and Android asset bundles can't do that.
     
  3. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    We have a huge amount of assets and having to build all of them at every Unity x.y release is a huge pain. Will there be any change for this ?
     
  4. Fizzer

    Fizzer

    Joined:
    Nov 16, 2016
    Posts:
    40
    My suggestion is to automate it.

    I had the same reaction as you when I discovered this, as my project has over 10000 asset bundles. So I wrote editor scripts that do it all, then I invoke the editor from the command line for each asset. All told, it takes 5+ days to re-create all of them, but it's no big deal since I just kick it off on a PC I have in my garage and let it run until it's done.
     
  5. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Thanks for you andwer @Fizzer. Of course that's a solution of more or a workaround. What are the technical reasons to always change the AssetBundles behaviour each release ? Maybe @Marco-Trivellato and/or @jonas-echterhoff could give us a hint.
     
  6. Fizzer

    Fizzer

    Joined:
    Nov 16, 2016
    Posts:
    40
    The manual explains it in the section "Will an AssetBundle built now be usable with future versions of Unity?". The answer is that in 5.4 they didn't write the "type tree" to mobile or console versions (and I'm pretty sure webgl too, though the manual is not explicit here as the webgl target was still new in 5.4).

    It looks like in the 5.5 version of that manual page, it says it does write the type tree for all platforms except Windows Store. So it looks like they've already implemented your request in 5.5, though I haven't tested it.

    Strangely this page is missing completely in the 5.6 manual.
     
  7. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    Thanks for the precisions. According to the 5.5 Manual, as you said, it seems that the type tree is included in WebGL. But it would be cool if we have some confirmation about the assetbundles cross compatibility between Unity version in WebGL for 5.5 version and later.
    I also don't find any information about that in the [5.6 DRAFT] Asset Bundles document.
     
  8. Marco-Trivellato

    Marco-Trivellato

    Unity Technologies

    Joined:
    Jul 9, 2013
    Posts:
    1,654
    This happens because Unity 5.6 WebGL does not support LZMA compression. You need to re-build asset bundles with BuildAssetBundleOptions.ChunkBasedCompression or BuildAssetBundleOptions.UncompressedAssetBundle.
     
  9. MaT227

    MaT227

    Joined:
    Jul 3, 2012
    Posts:
    628
    @Marco-Trivellato The assetbundles built with Unity 5.4 used the ChunkBasedCompression option so this should work on Unity 5.6 no ?
     
  10. Hickna

    Hickna

    Joined:
    Mar 14, 2013
    Posts:
    26
    Sad!!! Do we need to rebuild all AB's every update?
     
  11. kognito1

    kognito1

    Joined:
    Apr 7, 2015
    Posts:
    331
    The answer is "sometimes". We had to rebuild bundles for 5.4->5.5 because the texture format changed (can't actually recall, but I do remember textures not showing up) and again for 5.5->5.6 because the shader format seemed to change (again don't really know the problem but shaders in bundles stopped successfully compiling). However so far 5.6->2017.1 seems to be fine and I want to say 5.3->5.4 was fine too. My memory gets a little fuzzy since sometimes not every platform needs to be rebuilt, so can't say for sure when we had to rebundle for WebGL.

    So yeah I would advise you to invest greatly in asset bundle automation! But there's no magic here, if (when) you have to update all of your asset bundles, it's still going to be a huge production killer. Whether a robot or a human does the building, updating ~100,000 asset bundles is going to take time. I think it took us a month to do 5.5->5.6 for all platforms and that was all automated!!! The QA and deployment overhead will be non-trivial. :eek: Having said all that, I do think (especially for WebGL) the asset bundle pros far outweigh the cons if managed correctly.
     
    Hickna likes this.