Search Unity

LoadFromCacheOrDownload and limiting required size for my asset bundles

Discussion in 'Editor & General Support' started by NightmareTFD, Sep 4, 2015.

  1. NightmareTFD

    NightmareTFD

    Joined:
    Feb 11, 2015
    Posts:
    39
    Hello, I am using LoadFromCacheOrDownload to download my bundles from my webserver. i do notice that my game which has asset bundle total size of approx 100meg expands out to approx 1gig when things are uncompressed from the cache after download.

    What i'm wondering is what things can i do to continue to use LoadFromCacheOrDownload however read directly from the compressed bundle and/or have the cache take up less space when things uncompress?

    thank you kindly.
     
  2. NightmareTFD

    NightmareTFD

    Joined:
    Feb 11, 2015
    Posts:
    39
    bump please. i dont want this to get lost by the 3 day weekend
     
  3. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    Your options are:
    1. Wait for 5.3, which is supposed to have the new WWW class which doesn't blow out the mono-memory when it downloads large bundles, as well as allows client side compression of the bundle data.
    2. Break your asset bundles into lots of smaller bundles, but make sure you fit inside the 256 max asset bundles open at once "feature". This has other advantages, like download retries not needing to download a full 100 megs of assets before it completes/fails.
     
  4. NightmareTFD

    NightmareTFD

    Joined:
    Feb 11, 2015
    Posts:
    39
    Hey jbooth,

    thanks for the response. we already use really small asset bundles. <20Meg each. the issue however is once this 20meg is downloaded and cached it expands out to 200 Meg (for example). i would like to be able to limit this as much as possible. for example i know that unity if a device doesn't support a texture compression on the device will uncompress the compressed texture and make a new texture from it. it seems like this is being cached. or at least i would hope it is. if i make my texture compression match the device compression will this number go down? if not why? or how can i make this number go down when building my assets?
     
  5. jbooth

    jbooth

    Joined:
    Jan 6, 2014
    Posts:
    5,461
    The bundles are cached on disk as uncompressed; You can see this size in the build logs, before the compression is applied. In 5.3, they are adding a feature to let you keep them compressed on device. Other than downloading different textures per device (via bundle variants), there's not much you can do to compress them further unless your willing to write your own caching/loading mechanism for the device.

    Note that when Unity builds the bundles, the bundles contain the device specific formats in them; so DXT for desktop, PVRTC for iOS. Android is another mess entirely. <5.2, compressed textures go to ETC1 unless they have an alpha channel, in which case they become 4444 uncompressed texture. In 5.2, the RGBA textures are compressed to ETC2, and then uncompressed to (assuming) 8888 or (possibly) 4444 on devices which don't support ETC2 texture compression. Personally, we build bundles for each of the alpha formats different android devices use and connect to the right folders at load time given the devices compression formats.

    Also, 20 megs is quite large for a bundle. Keep in mind that WWW will load some number of these at once. If it downloads 4 20 meg bundles at once, it will likely add about 140mb to your mono-heap, which you never get back and will cause low end devices to crash from running out of memory.
     
  6. NightmareTFD

    NightmareTFD

    Joined:
    Feb 11, 2015
    Posts:
    39
    jbooth,

    thanks for the info. so if i want caching i need to upgrade or pay some space. otherwise i need to convert to another system. thanks again