Search Unity

[UWP] Error while www loading

Discussion in 'Windows' started by bb_hg, Feb 9, 2017.

  1. bb_hg

    bb_hg

    Joined:
    Mar 27, 2014
    Posts:
    13
    Hello
    some time I get the error "You are trying to load data from a www stream which has not completed the download yet. You need to yield the download or wait until isDone returns true." as if I wouldn't yield it.

    At the moment I just try to avoid this problem by waiting a little longer until the asset bundle is loaded.

    Reproducable on Unity 5.4.2f2 and 5.4.4f1 (5.5.1f1 there are other problems)


    Code (CSharp):
    1.  
    2. using (WWW www = new WWW(path)) {
    3. #if UNITY_UWP
    4.             Debug.Log("try to load www path " + path);
    5. #endif
    6.             yield return www;
    7. #if UNITY_UWP
    8.             Debug.Log("after yield www.isDone " + www.isDone + ", www.progress " + www.progress+ ", www.error '" + www.error + "' , assetBundle =" +
    9. (www.assetBundle == null ? "null" : www.assetBundle.ToString()));
    10.             // Strange error on Windows Store App:
    11.             // You are trying to load data from a www stream which has not completed the download yet.
    12.             // You need to yield the download or wait until isDone returns true.
    13.             float waitTime = 0f;
    14.             while (!www.isDone || www.progress < 1f || www.assetBundle == null)
    15.             {
    16.                 yield return new WaitForSeconds(0.1f);
    17.                 waitTime += 0.1f;
    18.                 Debug.Log("www.isDone " + www.isDone + ", www.progress " + www.progress + ", assetBundle =" + (www.assetBundle == null ? "null" : www.assetBundle.ToString()));
    19.                 if(waitTime > 5f)
    20.                 {
    21.                     Debug.Log("ERROR AssetBundle couldn't be loaded!");
    22.                     yield break;
    23.                 }
    24.             }
    25. #endif
    26.  
    27.             if (!string.IsNullOrEmpty(www.error)) {
    28.                 Debug.LogWarning(www.error);
    29.                 yield break;
    30.             }
    31.  
    32.             ...
    33.         }
     
    Last edited: Feb 9, 2017
  2. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,732
    Which version of Unity do you use?
    Can you try using UnityWebRequest?
     
  3. bb_hg

    bb_hg

    Joined:
    Mar 27, 2014
    Posts:
    13
    atm Unity 5.4.4f1