AssetBundleManager.LoadAssetAsync() doesn't work on some android devices (or is very slow)

Hi guys,

I’m having a strange problem with the AssetBundleManager.LoadAssetAsync() method on some android devices.

All desktop and iOS platforms work fine, with art loading close to instantly.

A samsung galaxy s5 is able to load the card art, with a very slight delay (microseconds).

But a samsung galaxy s7 and a galaxy tablet is unable to load the cardart sprites (some users report it will randomly appear, after a veeerry long wait).

I was using unity 2017.2, but went back to 5.6.2 hoping the issue would resolve. No luck.

One difference I could see between the devices is that the galaxy s5 has a microsd card, and some of the gamedata appears to be stored on there. Not sure if this is relevant, but just thought I’d mention (in case there is some performance benefit with having streamingassets on a sd card)

Here is the code of what I am trying to do:
(which is a copy of the sample from here: https://docs.unity3d.com/Manual/AssetBundles-Manager.html)

AssetBundleLoadAssetOperation request = AssetBundleManager.LoadAssetAsync("cardart", card["Art"], typeof(Sprite));

//if no cardart to load, try again next update
if (request == null)
{
	yield break;
}
else
{
	//run the method to get the card art
	yield return StartCoroutine(request);

	Sprite newimage = request.GetAsset<Sprite>();
	if (newimage != null)
	{
		cardart.sprite = newimage;
		yield break;
	}    
}

Has anyone else seen this problem? What am i doing wrong?
Is there an alternative to LoadAssetAsync() I can try?
I’m happy to post more code (The full AssetBundleManager class that I am using) if that helps with analysis?

Could someone please assist as I am going nuts trying to resolve this, and it’s holding up the android release of the game!!

Any response is much appreciated

Cheers

Navil

After many painful hours spent debugging on android, I found myself an answer.

In the hope that it helps someone, I am posting it here.

The culprit appeared to be the override call to Update() in the AssetBundleLoadOperation.cs class.
This is the original code that I had:

// Returns true if more Update calls are required.
		public override bool Update ()
		{
			if (m_Request != null)
				return false;

			LoadedAssetBundle bundle = AssetBundleManager.GetLoadedAssetBundle (m_AssetBundleName, out m_DownloadingError);
			if (bundle != null)
			{
				///@TODO: When asset bundle download fails this throws an exception...
				m_Request = bundle.m_AssetBundle.LoadAssetAsync (m_AssetName, m_Type);
				return false;
			}
			else
			{
				return true;
			}
		}

Subsequent calls to Update() for an asset would immediately return false, indicating that it is ready for cleanup, when in reality the asset could still be loading.
I updated the method to below, which waited for the asset to appear before allowing it to return false.

        //Returns true if more Update calls are required.
        public override bool Update()
        {
            if (m_Request != null)
            {
                //check if its done properly!
                var completedCheck = m_Request.isDone;

                if (completedCheck)
                {
                    //this means its finished! but still not working. let's check if the asset is there yet
                    var assetLoaded = m_Request.asset;

                    //sprite there?
                    if (assetLoaded != null)
                    {
                        //change its priority
                        m_Request.priority = 1;
                        //and return false. (allow it to complete now)
                        return !completedCheck;
                    }
                    else if (!completedCheck)
                    {
                        //if the asset it STILL not there, that means there is some more to go. keep returning true.
                        return true;
                    }
                }
                else
                {
                    //keep returning true, we haven't finished yet
                    return true;
                }
            }

            LoadedAssetBundle bundle = AssetBundleManager.GetLoadedAssetBundle(m_AssetBundleName, out m_DownloadingError);
            if (bundle != null)
            {
                //@TODO:When asset bundle download fails this throws an exception...
                m_Request = bundle.m_AssetBundle.LoadAssetAsync(m_AssetName, m_Type);

                //make it a higher priority.
                m_Request.priority = 2000;

                //don't return false here? we haven't quite finished the request yet? return true.
                return true;
            }
            else
            {
                return true;
            }
        }

Hi, it didn’t work for me!
Android still slow downloading assetbundles.