Search Unity

Abort bundles downloading web requests

Discussion in 'Addressables' started by Azirell, Jun 5, 2020.

  1. Azirell

    Azirell

    Joined:
    Oct 16, 2015
    Posts:
    29
    Hi everyone.
    As far as I am aware Addressables still does not support abortion of current downloading bundles. This becomes a dealbreaker for my project, unfortunately. Caching is not an option. I have a dynamic system that requires remote loading and unloading at runtime and I need ability to abort current WebRequests to free up bandwidth.
    So:
    1. Do I miss something? May there is a way to do it already I'm not aware of? If so please help.
    2. Considering that current version is 1.9+ - why does it still work this way? Why by design there is no option to abort current downloading? Is there a vital reason why this not an option?
    3. I'm working on a solution to this at the moment. My current progress below.

    What I am trying to achieve: cancel all downloads associated with AsyncOperationHandle.
    Idealy I would like to have smth like this usage - AsyncOperationHandle<T>().Abort(), but Addressables.Release(AsyncOperationHandle<T>) should be just fine.
    Note: I am aware of another similar thread, but my case is slightly different, I cannot abort every request, just the ones that are associated with certain AsyncOperationHandle.

    My approach: I store reference on every AssetBundleResource that was created during LoadAssetAsync/InstantiateAsync. And on Addressables.Release(AsyncOperationHandle<T>) I abort WebRequest in AssetBundleResource in all AssetBundleResources that associated with AsyncOperationHandle.

    If my approach would work this topic would not exists, but here we are. It seems like system cannot properly handle WebRequest abortion.

    Problems: currently I have a lot of errors when I'm trying to do an abort. The system isn't stable, it can abort 2-3 times just fine, but then it will just break with a bunch of different errors. I've tried to solve them, mostly with just try/catch blocks on problematic places, but it's just getting worse. Feels like I'm going nowhere.
    I'll provide an example project if needed.

    Pls help.
     
    Last edited: Jun 6, 2020
    phobos2077 likes this.
  2. phobos2077

    phobos2077

    Joined:
    Feb 10, 2018
    Posts:
    350
    Probably because they never thought about it. Probably because they don't work on real projects themselves and have a vague idea of what this package needs to do. Like seriously, there is an Editor Hosting feature which is nice to have but kinda of a low priority extra feature compared to some more obvious stuff like download aborting and download progress reporting that are missing. Just sad.

    Anyway, you could probably try hacking this in via some custom AssetBundleProvider.