www.LoadFromCacheOrDownload() fails to cache files

This happens occasionally on a small number of machines. It appears that downloaded asset bundles occasionally don’t get transferred from the temporary folder to the appropriate cache folder. As a result, users must re-download bundles twice every time they run the game.

Here’s the edited code which performs the download (error checking and debug logging stripped out for simplicity):

IEnumerator GETVersioned(string uri, int version, NetworkResultsDelegate callback)
{
	WWW www = WWW.LoadFromCacheOrDownload(uri, version);

	// perform one callback so the caller can query progress
	if (null != callback)
		callback(www);

	yield return www;

	if (null != callback)
		callback(www);
}

The callback(error checking and debug logging stripped out for simplicity):

void SendRequestScenesCallback(WWW result)
{
	if (!result.isDone)
	{
		m_scenesBundleProgress = result;
		return;
	}
	
	if (string.IsNullOrEmpty(result.error))
	{
		m_scenesBundle = result.assetBundle;
		m_scenesBundleProgress = null;
	}
}

And a small edited piece of the output_log.txt file. Note that this is a release build and the output is from the Unity engine, not from Debug.Log():

RG: All of these start at the same time

starting www download: (AssetBundle_1).unity3d

starting www download: (AssetBundle_2).unity3d

starting www download: (AssetBundle_3).unity3d

starting www download: (AssetBundle_4).unity3d

starting www download: (AssetBundle_5).unity3d

starting www download: (AssetBundle_6).unity3d

(AssetBundle_1).unity3d cached to (Cache Directory)

loading from cache: (AssetBundle_1).unity3d

RG: note cache failure and re-download

starting www download: (AssetBundle_5).unity3d

(AssetBundle_3).unity3d cached to (Cache Directory)

loading from cache: (AssetBundle_3).unity3d

(AssetBundle_4).unity3d cached to (Cache Directory)

loading from cache: (AssetBundle_4).unity3d

(AssetBundle_6).unity3d cached to (Cache Directory)

loading from cache: (AssetBundle_6).unity3d

(AssetBundle_2).unity3d cached to (Cache Directory)

loading from cache: (AssetBundle_2).unity3d

RG: This is a secondary bundle, dowloaded after the rest have completed

starting www download: (AssetBundle_2)_DEP.unity3d

RG: note cache failure and re-download

starting www download: (AssetBundle_2)_DEP.unity3d

I’m assuming what’s happening here is LoadFromCacheOrDownload() tests to see if a bundle is in the cache and if not tries to download it. Once that download is complete it then should cache it, and then runs the code a second time, which presumably would then see the cached version. However since the cacheing is failing the bundle gets downloaded twice.

Any help would be greatly appreciated, as some of our bundles are quite large and take a fair amount of time to download.

Russ Glaeser
Development Director
Cascade Game Foundry

Thanks for the reply.

This is in standalone builds (I’ve only seen it on Windows, but I really do very little testing on Mac so it’s possible it happens there too). I shouldn’t be anywhere close to the cache limit. The total size of downloaded asset bundles is under 1gb, so I don’t think I’m running up against the 4gb cache size limit.

Russ

We are getting a very similar problem on PC with what seems to be a standard asset bundle size.

Independent tests however, when we use a test bed work.

If I manually load an asset bundle it gets cached. If I load an asset bundle that has a scene with that same asset bundle being a dependency, it fails.

We are not sure yet what the issue is but will be raising it with unity.