Search Unity

[bug] retry load with failed crc

Discussion in 'Addressables' started by nik_d, Jun 12, 2019.

  1. nik_d

    nik_d

    Joined:
    Apr 27, 2018
    Posts:
    66
    workaround: in AssetBundleProvider.cs WebRequestOperationCompleted(...)

    Code (CSharp):
    1.             //**addressables - fail on incorrect bundle
    2.             m_downloadHandler = webReq.downloadHandler as DownloadHandlerAssetBundle;
    3.             if (m_downloadHandler.assetBundle == null) {
    4.                 error = "failed to load asset bundle (incorrect content, crc mismatch, etc)";
    5.             }
    6.            
    7.             if (string.IsNullOrEmpty(error))
    8.             {
    9.                 //**addressables: speed up: frequent requests to AssetBundleRequestOptions.ComputeSize
    10.                 AssetBundleRequestOptions.RequiredSizes[m_ProvideHandle.Location.InternalId] = 0;
    11. .......
     
  2. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    not sure what you're after with this one. If the crc doesn't match, then the webReq.error should not be empty, and we will retry. And I don't know what this `error = ....` is. Is that supposed to be Debug.LogError(...)?
     
  3. nik_d

    nik_d

    Joined:
    Apr 27, 2018
    Posts:
    66
    UnityWebRequestAssetBundle is dark horse for me - I've never met Crc-related error in
    UnityWebRequestAsyncOperation, only crc-messages in log, but I've met null bundle without webReq.error..

    To be honest - I'll be glad to get rid of all Caching.*** / UnityWebRequestAssetBundle because their behaviour is unpredictable and uncontrollable.

    First:
    Let look - we have the same bundles (with the same Hash) but with different Crc (f.e. built via different Unity versions or with some salt). First one is already cached and what I saw:
    = Caching.IsVersionCached(Hash)=true, BUT UnityWebRequestAssetBundle.GetAssetBundle(Hash, Crc) write to log about Crc, kills cached variant and returns with error "Unable to write data"!
    = second try to GetAssetBundle(Hash, Crc) downloads and returns correctly (good retry in AssetBundleProvider)
    = !!! Implicit download without progress to the user !!! (CalcSize returns 0)
    = if I do GetAssetBundle(Hash, no-Crc) for bundle with IsVersionCached=true it is loaded correctly, BUT if I corrupt/spoil bundle is the cache (by hands for test):
    = implicit download without errors from the first GetAssetBundle attempt
    = Unity fails with exception (and even crashes editor).

    In any case - I have either a lot of implicit downloading (for different Crc), either possible crush.. =)

    Second:
    I want to pre-download even embedded and already opened bundles and only after they all are cached - reopen addressable with new catalog..
     
  4. unity_bill

    unity_bill

    Joined:
    Apr 11, 2017
    Posts:
    1,053
    us too. eventually we plan to roll a C# caching package. There's just too much to do and not enough people (yet) to do it.

    that's another one we're looking at. We're exploring both how we could add it natively in the package, and if we could give a guide for the user to add it.

    thanks for the explanation. we'll look into it.