Search Unity

Unity WWW.LoadFromCacheOrDownload or UnityWebRequest.GetAssetBundle is nightmare for 2017

Discussion in 'Asset Bundles' started by BoboShu, Jul 18, 2017.

  1. BoboShu

    BoboShu

    Joined:
    Nov 20, 2014
    Posts:
    38
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Can you elaborate on this one? Can you show the code you use for it?

    And what issues do you have with 2017.x?
     
  3. BoboShu

    BoboShu

    Joined:
    Nov 20, 2014
    Posts:
    38
    i use old version (5.5.2) build assetbundle. and build on ios.
    when i upgrade the unity version. and rebuild the assetbundle .
    i got crc mismatch error

    request = UnityWebRequest.GetAssetBundle(url, m_AssetBundleManifest.GetAssetBundleHash(assetBundleName), GetCRC(assetBundleName));

    res:
    https://gm.aliother.com/asset/3/AssetBundles/iOS/audio_ui_onclick
    https://gm.aliother.com/asset/3/AssetBundles/iOS/audio_ui_onclick.manifest

    here is the Log

    Error while downloading Asset Bundle: CRC Mismatch. Provided f81515b1, calculated 85e60b08 from data. Will not load AssetBundle 'https://gm.aliother.com/asset/3/AssetBundles/iOS/audio_ui_onclick'

    4162131377 == f81515b1;

    where is the 85e60b08? I Clear the All cache , i not use . i redownload all assetbundle . it also crcmimatch.

    i have to del my build on my phone .
     
  4. rockpower

    rockpower

    Joined:
    Feb 18, 2013
    Posts:
    3
    i have the same problem...that my code

    using (WWW www = WWW.LoadFromCacheOrDownload(downloadUrl, version))
    {
    yield return www;
    if (www.error != null)
    {
    throw new Exception("WWW download:" + www.error);
    }
    AssetBundleRef abRef = new AssetBundleRef(url, version);
    abRef.assetBundle = www.assetBundle;
    dictAssetBundleRefs.Add(keyName, abRef);
    www.Dispose();
    //www = null;
    }

    in Unity 5.5.1 is work right, but in Unity 2017.1.0f3...the www has error...

    at UnityEngine.SetupCoroutine.InvokeMoveNext (IEnumerator enumerator, IntPtr returnValueAddress) [0x00028] in /Users/builduser/buildslave/unity/build/Runtime/Export/Coroutines.cs:17
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    I believe we fixed this bug in patch release. Try checking for error like this:
    Code (CSharp):
    1. if (!string.IsNullOrEmpty(www.error))
     
  6. rockpower

    rockpower

    Joined:
    Feb 18, 2013
    Posts:
    3
    thanks......but there are still error, i found it come from the line
    using (WWW www = WWW.LoadFromCacheOrDownload(downloadUrl, version))

    NullReferenceException: UnityWebRequest has already been destroyed
    at (wrapper managed-to-native) UnityEngine.Networking.UnityWebRequest:GetDownloadHandler ()
    at UnityEngine.Networking.UnityWebRequest.DisposeHandlers () [0x0000e] in C:\buildslave\unity\build\artifacts\generated\common\modules\UnityWebRequest\WebRequestBindings.gen.cs:173
    at UnityEngine.Networking.UnityWebRequest.Dispose () [0x00002] in C:\buildslave\unity\build\artifacts\generated\common\modules\UnityWebRequest\WebRequestBindings.gen.cs:161
    at UnityEngine.WWW.Dispose () [0x00007] in C:\buildslave\unity\build\Runtime\WebRequestWWW\UWRWWW.cs:238
    at FireflyLib.File.AssetBundleManager+<DownloadAssetBundle>c__Iterator0.<>__Finally0 () [0x00011] in D:\Work\MiniCraft2017\client\MiniCraft\Assets\Scripts\FireflyLib\File\AssetBundleManager.cs:75

    i check the asset file is indeed inside the folder, then i clear and rebuild all AssetBundle for many times, but the problem is still......:(
    the error only found in Unity 2017.1.0f3.......i change to Unity 5.5.1, everything right=.=
     
  7. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    I believe this error with dispose is fixed in latest versions of Unity. You are probably calling Dispose() on a WWW object, that is in using block (meaning it calls Dispose() automatically for you). There was a bug where you would get exception when disposing WWW object twice.
     
    ramioooz likes this.