[Windows Universal 8.1] Invalid Geometry when loading remote image

I’ve just upgraded my game to Unity 5.2 from 4.6.7 and I have a problem when loading images remotely from Facebook on both Windows Phone 8.1 and also on Desktop/Tablet

The only error that I see in the output log is:

PxShape::setGeometry(): Invalid geometry!

The code I use to set this up is as follow:

public void SetImage(Texture2D tex)
 {
  CreateImage();

 _image.GetComponent<Renderer>().material.mainTexture = tex;
 _image.transform.localScale = GetScale(tex);
 if (this.GetComponent<Renderer>() != null)
 this.GetComponent<Renderer>().enabled = false;

 }
 private void CreateImage()
 {
 if (this._image == null)
 {
 _image = (GameObject)GameObject.CreatePrimitive(PrimitiveType.Plane);
 _image.layer = this.gameObject.layer;
 _image.transform.parent = this.gameObject.transform;
 _image.transform.localPosition = new Vector3(0, 0, -0.1f);
 _image.transform.localRotation = Quaternion.Euler(new Vector3(90, 180, 0));
 _image.transform.localScale = Vector3.zero;
 }
 else
 {
 _image.SetActive(true);
 }
 }

private Vector3 GetScale(Texture2D image)
 {
 float wRatio;
 float hRatio;

 if (image.width >= image.height)
 {
 wRatio = scale / image.width;
 hRatio = scale / image.height;
 }
 else
 {
 wRatio = scale / image.width;
 hRatio = scale / image.height;
 }

 float resizeRatio = Mathf.Min(wRatio, hRatio);

 return new Vector3(image.width * resizeRatio, image.height * resizeRatio, image.height * resizeRatio);
 }

It seems like its happening as soon as the primitive plane is created, so doesn’t seem to have anything to do with the resizing stuff that I do. When the code finishes executing, I’m left with a pink box. This code works fine in the Windows UnityEditor and on iOS and Android.

What material are you using on the mesh? If it’s the default one, try setting a custom one

Yeah, its just what ever comes on the CreatePrimitive mesh. Looking at it in the editor, its an instance of the standard shader, with the texture set on the Albedo property.

I’ll try setting a custom one and see what it does.

Yep - that fixed it. I used a legacy diffuse shader on it (what it was previously I guess) and its working fine. I still see that invalid geometry error, but it displays correctly.