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. Dismiss Notice

Question about the theory of loading a asset the Addressable System.

Discussion in 'Addressables' started by MingKKK, Apr 28, 2020.

  1. MingKKK

    MingKKK

    Joined:
    Apr 13, 2019
    Posts:
    15
    The default compression mode is LZ4 in Addressable Group Setting. As far as I know, a normal AssetBundle is fully loaded into RAM for the first time when a asset is read. And then the AssetBundle will compress in chunk-based form and then written back to Disk. When any asset in the this AssetBundle are loaded later, they are loaded on Chunk-Based rather than the entire AssetBundle being loaded into memory.

    I don't kown if my description is wrong. If so, does the Addressable System load asset in the same way??

    I don't kown where I can kown more about this theory . Can anyone help me! Thx!
     
  2. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    What you describe is how bundles with LZMA compression work AFAIK. With LZMA you get a single compression stream for the entire bundle, so the result is smaller, but it is not possible to read and decompress individual files. As a result, Unity has to load and decompress the whole bundle, and then it can load specific assets on demand.
    LZ4 compresses each file separately, so Unity can (in theory) load one asset from bundle on disk without having to load the entire bundle into memory. I'm not 100% sure how it works as I'm not very experienced with AssetBundles.

    Just look at the source code: AssetBundleProvider and BundledAssetProvider. They use normal AssetBundle under the hood, there is no magic. Addressables is just an abstraction layer over asset bundles with a suite of useful features.
     
  3. MingKKK

    MingKKK

    Joined:
    Apr 13, 2019
    Posts:
    15
    Thanks for you reply. @phobos2077
    But I have a question. When an application loads a asset from an lz4 compressed AssetBundle package, does it load the entire AssetBundle package into memory and then unpack a corresponding asset into memory instead of unpacking all the assets?
    Memory consumption is a lz4 compressed AssetBundle package plus a unpacked asset?
     
  4. MingKKK

    MingKKK

    Joined:
    Apr 13, 2019
    Posts:
    15
    Waiting! Can anyone give me an accurate answer!!
     
  5. MingKKK

    MingKKK

    Joined:
    Apr 13, 2019
    Posts:
    15
    wait!
     
  6. kartoonist435

    kartoonist435

    Joined:
    Feb 14, 2015
    Posts:
    71
    I'd also like to know this info!
     
  7. sersol

    sersol

    Joined:
    Apr 7, 2020
    Posts:
    6