UnityWebRequestMultimedia.GetAudioClip huge profile spike

Any better way to load BGM than the example code @

I get between 50ms and 100ms spikes on the load frames using that method, even though it’s supposedly a coroutine. (Loading single ~300kb .ogg files in StreamingAssets folder.)

As a last alternative, I guess I could run the BGM system on a permanent separate thread.
Just seeing if other simple solutions. to reduce the single frame spike that this common basic loading causes.
[EDIT]:
I am not downloading/streaming a remote file. I am simply trying to load a local file in streaming assets folder without bogging system down.

My current setup/code (Just like example code):

filename = Application.streamingAssetsPath + "/" + filename + ".ogg";
        using (var uwr = UnityWebRequestMultimedia.GetAudioClip(filename, AudioType.OGGVORBIS)) {

                yield return uwr.SendWebRequest();
                if (uwr.isNetworkError || uwr.isHttpError) {
                    Debug.LogError(uwr.error);
                    yield break;
                }
                yield return null; //tossed  in just incase it helps split effort
                
                bgmClip = DownloadHandlerAudioClip.GetContent(uwr);
            }
        audioSource.clip = bgmClip;

You can add this line before the send web request:

((DownloadHandlerAudioClip)uwr.downloadHandler).streamAudio = true;

Thanks much, Yeah, same 153 ms blue coroutine entry in profiler on a single frame. With yielding like that as well.

Looks like culprit is File.Read with the bulk of time. I’m guessing The actual loading and of file is in main thread and not interrupted?

this coded fixed a bit the issue from 200 ms to 40 ms the problem was with the Write part, so i uodated the code for using WriteAsync

private async void Test()
{
    string filename = Application.dataPath + "test.mp4";

    using (WWW www = new WWW("https://sample-videos.com/video123/mp4/720/big_buck_bunny_720p_30mb.mp4"))
    {
        while (!www.isDone)
        {
            await Task.Delay(250);
            Debug.Log("Downloading");
        }
        using (FileStream sourceStream = new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.None, 4096, true))
        {
            await sourceStream.WriteAsync(www.bytes, 0, www.bytes.Length);

            Debug.Log("YAY");
            sourceStream.Close();
        }
    }
}

I am trying to play an mp3 on the smartphone but I get this error message: “Cannot connect to destination host”.
While in the Unity editor in Windows 10 this code works:

IEnumerator LoadAudio()
	{
		string mp3File = f2SD[mp3Int - 1];
		using (var www = UnityWebRequestMultimedia.GetAudioClip(mp3File, AudioType.MPEG))
		{
			((DownloadHandlerAudioClip)www.downloadHandler).streamAudio = true;
			yield return www.SendWebRequest();
			if (www.isNetworkError || www.isHttpError)
			{
				Debug.Log(www.error);
				saveLocation.text = mp3File + " - " + www.error;
				yield break;
			}
			yield return null;

			AudioClip _clip = DownloadHandlerAudioClip.GetContent(www);

			audioSource.clip = _clip;
			audioSource.Play();
			audioSB.SetActive(true);
			stopSB.SetActive(true);
			mp3Pan.SetActive(false);
		}
	}[1]

mp3file is a path string of the mp3 file in a folder on the sd card

At the moment I’m stuck, any suggestions?