MacOS. Unity web request. Streaming assets. Resource blocked by content blocker

Hello. Trying to read file from streaming assets on mac os unity editor and reseive an error Resource blocked by content blocker. Same on WebGL build on Mac os. On windows machine all fine in editor and builds.
Why? How to fix?
Code:

private IEnumerator LoadProcess(string fileName, Action<string> onComplete, Action onFailed)
    {
        var path = Path.Combine(Application.streamingAssetsPath, fileName + ".csv");
        using(UnityWebRequest.Get(path))
        {
            yield return www.SendWebRequest();

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log($"error msg = {www.error.ToString()}");
                onFailed?.Invoke();
            }
            else
                onComplete?.Invoke(www.downloadHandler.text);
        }
    }

Can you try reading the same file using File class?

It works fith file class for MacOs editor. Why UWR doesnt? and most important - i need it in Web build.

Ah, you are passing path to UWR, while you should pass URI. Wrap it with System.Uri and it should work in Editor.
As for web, how are you hosting the game? It should be server thingy.

1 Like

what about hosting? backend team put the build in place and provide a link.

how to wrap? when i google for the UWR from streaming assets i only solutions similar to mine. No system.url involved

using(UnityWebRequest.Get(new System.Uri(path)))

Check the URL you web build accesses and the error you get from UWR. Likely either resulting URL is incorrect or access to those resources is blocked by the server.

the error appears on running webgl build on local machine (simple web server as chrome extention)

I’ll try as this

using (UnityWebRequest www = UnityWebRequest.Get(new System.Uri(path).ToString()))
        {
            yield return www.SendWebRequest();

            if (www.isNetworkError || www.isHttpError)
            {
                Debug.Log($"error msg = {www.error.ToString()}");
                onFailed?.Invoke();
            }
            else
                onComplete?.Invoke(www.downloadHandler.text);
        }

UWR doesn’t like when i try to put there system.uri with no ToString.

You probably are on an older version of Unity?
The Uri class has a property AbsoluteUri, I recommend using that instead of ToString().

I ran into this as well. Isn’t this something that Unity could fix under the hood with a #define? Seems odd that I have to go through my codebase and change all my WebRequests to use a URI now that I’m trying to add mac support, when Unity could fix this via:

UnityWebRequest(string path)
{
#if mac/ios/iosx_editor
return UnityWebRequest(new System.Uri(path);
#else
// do standard web request.
#endif
}