WWW retry problem

I’m trying to create a retry mechanism for asset bundle with the WWW class. When an error is detected, in this case, the internet connection is not available, I create a new WWW object.

However, if I unplug the network to force retry then plug it in again, the retry always fail until I restart the game, or stop and replay in the Editor.
This does not seem to happen with WebClient. Anyone has the same problem?
The code to create WWW is very simple:
WWW www = new WWW(url);
yield return www;

Can you post the error handling code as well?

2 Answers

2

Try this

IEnumerator DownloadAssetBundle()
	{
	        while (!Caching.ready)
	                yield return null;

		var www = WWW.LoadFromCacheOrDownload(url,version);
		yield return www;
		if(!string.IsNullOrEmpty(www.error))
		{
			Debug.Log(www.error);
                    StartCoroutine ("DownloadAssetBundle");
			yield break;
		}
		var assetBundle = www.assetBundle;    
		var asset = assetBundle.mainAsset;
	}

Sorry, it turned out to be our logic issue, not WWW’s.

"WaitForPresent" is vsync -- it's waiting to reach a target framerate. Check your Application.targetFrameRate.

Yeah this actually looks like 30FPS is your target framerate. If you're setting Application.targetFrameRate to 30 in your code, then don't. If not then look at your quality settings and change vsync to "don't vsync" or "every v blank" and make sure it is not set to "every other v blank"