Search Unity

  1. Unity 2018.3 is now released.
    Dismiss Notice
  2. The Unity Pro & Visual Studio Professional Bundle gives you the tools you need to develop faster & collaborate more efficiently. Learn more.
    Dismiss Notice
  3. We've updated our Terms of Service. Please read our blog post from Unity CTO and Co-Founder Joachim Ante here
    Dismiss Notice
  4. Want to provide direct feedback to the Unity team? Join the Unity Advisory Panel.
    Dismiss Notice
  5. Improve your Unity skills with a certified instructor in a private, interactive classroom. Watch the overview now.
    Dismiss Notice

UnityWebRequest has no Error following CRC Mismatch

Discussion in 'Asset Bundles' started by TitanUnity, Nov 14, 2018.

  1. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    174
    Hi,

    We recently implemented CRC values instead of Version numbers for our AssetBundle versioning. The system is working ok so far but we're having a problem capturing and displaying CRC mismatch errors when they occur.

    Take this simple example below. Assume the passed in CRC value is incorrect. What we're finding is that the 'test' UnityWebRequest object contains no errors following a CRC mismatch. Specifically none of the Debug.LogError statements fire if a mismatch occurs in the code below:

    Code (CSharp):
    1. UnityWebRequest test = UnityWebRequestAssetBundle.GetAssetBundle("http://www.oursite.com/bundle.unity3d",123456789);
    2. yield return test.SendWebRequest();
    3.  
    4. if(!test.isDone)
    5. {
    6.     Debug.LogError("LOAD NOT DONE");
    7. }
    8.  
    9. if (test.error != null)
    10. {
    11.     Debug.LogError("ERROR");
    12. }
    13.  
    14. if (test.isHttpError)
    15. {
    16.     Debug.LogError("HTTP ERROR");
    17. }
    18.  
    19. if (test.isNetworkError)
    20. {
    21.     Debug.LogError("NETWORK ERROR");
    22. }
    23.  
    The weird part is that we do find an error in our console like this:
    CRC_ERROR.JPG

    But it seems like the error originates from somewhere else. Ultimately, all I'm trying to do is capture mismatches when they occur so our team can easily find and fix them. Any help here would be great!
     
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    1,921
    Are you loading asset bundle later?
    I suspect this error is printed when you do DownloadHandlerAssetBundle.GetContent() or acceess assetBundle property. It should return null in both cases.
     
  3. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    174
    Actually in the example above, we are not calling DownloadHandlerAssetBundle.GetContent(). I can generate a mismatch error above without attempting to get content or access the AssetBundle.

    In normal conditions calling GetContent() would be the next step to take, but I specifically created this simple example to illustrate the point that it seems the error gets thrown from another source.
     
  4. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    1,921
    You are right. Looking at the code we are detecting AssetBundle load failure and print the error, however we don't report error back to UnityWebRequest because old implementation considered only network errors as errors.
    I think the request should fail. Could you report a bug for this?

    Note that I don't think we are going to backport the fix anywhere, so for now you should check UWR for error and returned bundle for null. No error in UWR and null bundle would mean the download (of bytes) was successful, but bundle could not be loaded for some reason.
     
  5. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    174
    I double confirmed this to be true. I've add a break after this code to ensure nothing else fires and I've determined specifically that it only requires these 2 lines to trigger cause the error in the console but I'm not sure how to capture the error to handle it.

    Code (CSharp):
    1. UnityWebRequest test = UnityWebRequestAssetBundle.GetAssetBundle("http://www.oursite.com/bundle.unity3d",123456789);
    2. yield return test.SendWebRequest();
     
  6. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    174
    Ah ok thank you, you posted just as I was typing my last message!
    Submitting bug report now.
     
  7. TitanUnity

    TitanUnity

    Joined:
    May 15, 2014
    Posts:
    174
  8. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    1,921