Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Can't load images from another server in Safari

Discussion in 'WebGL' started by p0d04Va, Sep 19, 2019.

  1. p0d04Va

    p0d04Va

    Joined:
    Apr 4, 2013
    Posts:
    7
    I've stuck and don't know what to do.
    I'm using really simple code to load external image into game. Here is a test script I've made to load image and display it on screen:
    Code (CSharp):
    1. using UnityEngine;
    2. using UnityEngine.Networking;
    3. using UnityEngine.UI;
    4.  
    5. public class LoadImage : MonoBehaviour
    6. {
    7.     [SerializeField] private string _url;
    8.  
    9.     private void OnEnable()
    10.     {
    11.         StartCoroutine(LoadTexture());
    12.     }
    13.  
    14.     private IEnumerator LoadTexture()
    15.     {
    16.         var uwr = UnityWebRequestTexture.GetTexture(_url);
    17.  
    18.         yield return uwr.SendWebRequest();
    19.  
    20.         var image =  gameObject.GetComponent<Image>();
    21.         var texture = ((DownloadHandlerTexture) uwr.downloadHandler).texture;
    22.         image.sprite = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), new Vector2(0.5f, 0.5f));
    23.     }
    24. }
    Everything works fine, but in Safari image is not loading. It's not even sending request to load it.
    JS Console output:
    2019-09-19 14-37-50 z9yfv.png

    I've disabled prevent cross-site tracking in Safari setting and it works. But unfortunately be default this option is on.
    2019-09-19 14-42-01 4v6j8.png
    Looking for any suggestions here.
     
  2. p0d04Va

    p0d04Va

    Joined:
    Apr 4, 2013
    Posts:
    7
    Switching to Unity 2019.1.0f2 resolved this issue
     
  3. scorp2007

    scorp2007

    Joined:
    Aug 17, 2014
    Posts:
    42
    i use 2019.2.0f1 and i have the same problem. Can someone help?
     
  4. p0d04Va

    p0d04Va

    Joined:
    Apr 4, 2013
    Posts:
    7
    Just switch to another Unity version, in my case 2019.1.0f2 worked fine
     
  5. scorp2007

    scorp2007

    Joined:
    Aug 17, 2014
    Posts:
    42
    Have you switched from a new version to an old one? When trying to do this, I have a lot of errors.
     
  6. scorp2007

    scorp2007

    Joined:
    Aug 17, 2014
    Posts:
    42
    I just checked and found out that it works if I open applications on my site, but it doesn’t work when I try to download my application in iframe on another site (from my site), is there any solution?
     
  7. jukka_j

    jukka_j

    Unity Technologies

    Joined:
    May 4, 2018
    Posts:
    335
  8. karmatha

    karmatha

    Joined:
    Aug 25, 2012
    Posts:
    46
    Last edited: Sep 8, 2020
unityunity