Search Unity

Moving cached assetbundle to filesystem

Discussion in 'Asset Bundles' started by nilsdr, May 2, 2018.

  1. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    Hi,

    There is still a problem loading videos from assetbundle on android. When using a streamed scene which includes a videoplayer, on android this only works when the bundle is uncompressed and (more importantly) loaded from file instead of cache/memory.

    So as a workaround I'm trying to move a cached bundle to the filesystem and load it from there. For this however I need access to its raw bytes. Is there any way to get the raw bytes from an assetbundle object or the caching api?

    Also, this issue with videos and assetbundles has been around for a very very long time. Any ETA for a fix?
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    You mean if you load AssetBundle from file, it works?
    In such case your workaround would be cleaner if you simply downloaded it and saved to file bypassing the cache entirely.
    Doesn't change the fact that it's a bug though.
     
  3. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    Yes, this is a known issue thats been around for ages. I download all bundles by default using UnityWebRequest.GetAssetBundle, which works great but not for this purpose. It attached a DownloadHandlerAssetbundle which doesn't have a full native copy of the byte array (a normal UnityWebRequest.Get does), so we can't copy to file from there. The only way would be to know beforehand what the bundle contains (which in our current setup we don't) and then use a regular Get instead of GetAssetbundle. We have hundreds of assetbundles so some of them would then be in cache and some on the file system, which we will have to keep track of somehow and handle data requests accordingly.

    As I said this 'bug' has a big impact on our workflow and the only workaround is basicaly a redesign of our architecture.
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    That's because DownloadHandlerAssetBundle doesn't keep downloaded data in memory, it feeds it directly into AssetBundle system fo decompression/loading etc.
    If you are on recent enough version, DownloadHandlerFile might be useful for you.
    Do you know the case number for the bug? I might be able to look up it's status, possibly increase priority.
     
  5. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    I'm sure I remember seeing an official bug report for this before, but i cant find it now. I will file one with minimal reproduction case and post back here.

    https://forum.unity.com/threads/load-videoclip-in-assetbundle-on-android.466850/

    Here's a thread wit people testing this on different versions.
     
  6. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    Hi Aurimas, I've filed a bug report with adb logs and a project which easily recreates the situation.

    Case number: 1033212
     
  7. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Poked QA to look into it.
    Thanks.
     
    nilsdr likes this.
  8. nilsdr

    nilsdr

    Joined:
    Oct 24, 2017
    Posts:
    374
    @Aurimas-Cernius Any way I can ask for the status of this? The bug report just sais status: open