Search Unity

Avoid loading a huge AssetBundle on every app start

Discussion in 'Asset Bundles' started by urancle, Sep 12, 2018.

  1. urancle

    urancle

    Joined:
    Mar 28, 2018
    Posts:
    8
    Hi!

    I'm building an AR App for Android and iOS with geodata as content. The content is way too big to be built into the application itself due to the store restrictions of 100MB. So i made an assetbundle (AB) of around 160MB.
    My first idea was to download this file as a "normal" .unity3d-file to the device storage on first app start. On every next app start, if the ABis found locally, it loads the content to the scene with LoadAssetAsync(). This works as it should.
    Problem is, it takes now ~15s (even on a very fast smartphone) to load the data from AB into the application on every app start.

    After googlin' and searching this forum i tried building the AB without compression, the loading time is very fast now, around 2s. But this bloats the AB size up to 620MB, which i dont want every user have to download.
    Since the majority of time is used to uncompress the AB i think it doesnt help to use LoadFromCacheOrDownload (apart from other reasons why i dont want to use this).

    Now i'm looking for a solution or workaround.
    (As far as i've read it is not possible to add the GameObject via prefabs into the scene and "leave" it there, even if the app gets closed, so that on the next app start the data doesnt have to be loaded again. Meaning, loading the content "permanently" into the application. Is this true?)
    Another idea is to build the uncompressed AB and pack it as a zip-file to the server. Then download the zip on very first app start and unzip it to persistentDataPath. This way the download wouldn't be as big but the loading time would be very fast.

    What are your thoughts? Did anyone solve a similar problem in a (more) convenient way?
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,736
    LoadFromCacheOrDownload and the newer alternative of UnityWebRequest with DownloadHandlerAssetBundle will download the bundle once and cache it for future use. Given the size you're dealing with it sounds like you should be using that.
    And you probably should consider splitting stuff into multiple asset bundles so you can load small bundle with stuff you need rather than big bundle that contains lots of things you don't need.
     
    urancle likes this.
  3. urancle

    urancle

    Joined:
    Mar 28, 2018
    Posts:
    8
    Many thanks for your answer!
    As far as i understand the documentation it will cache it as an uncompressed file? This would be perfect, I will try this, thanks.
    In my App all the data inside that big asset bundle is used from app start and all the time, so splitting it up into multiple bundles only helps me if it would reduce the loading time on app start.