matias avatar image
matias asked

Playfab PlayFabUnityHttp error

Hi, i launch my app and this problems start showing up in Crashlytics. They are all related to PlayFab and wanted to know how can i fix them. (They happen from time to time, they are not consistant)

For Example I have a button that only shows up when you have "x" ammount of currency:

            new GetUserInventoryRequest { },
            GetResult =>
                virtualCurrency = GetResult.VirtualCurrency;
                var value = (virtualCurrency["TK"] - ticketAmount);
                if (value >= 5)
            GetError => { });

And i'm getting this error:

 UnityEngine.UI.Graphic.SetVerticesDirty (UnityEngine.UI.Graphic)
 UnityEngine.UI.Text.set_text (UnityEngine.UI.Text)
 PlayButton.<Awake>b__10_2 (PlayButton)
 System.Action`1[T].Invoke (System.Action`1[T])
 System.Action.Invoke (System.Action)
 PlayFab.Internal.PlayFabUnityHttp.OnResponse (PlayFab.Internal.PlayFabUnityHttp)
 PlayFab.Internal.PlayFabUnityHttp+<Post>d__12.MoveNext (PlayFab.Internal.PlayFabUnityHttp+<Post>d__12)
 UnityEngine.SetupCoroutine.InvokeMoveNext (UnityEngine.SetupCoroutine)
 PlayFab.Internal.PlayFabUnityHttp:OnResponse (PlayFab.Internal)
 PlayFab.Internal.<Post>d__12:MoveNext (PlayFab.Internal)
 UnityEngine.SetupCoroutine:InvokeMoveNext (UnityEngine)

 Non-fatal Exception: java.lang.Exception: NullReferenceException : Object reference not set to an instance of an object.
        at UnityEngine.UI.Graphic.SetVerticesDirty(UnityEngine.UI.Graphic)
        at UnityEngine.UI.Text.set_text(UnityEngine.UI.Text)
        at PlayButton.<Awake>b__10_2(PlayButton)
        at System.Action`1[T].Invoke(System.Action`1[T])
        at System.Action.Invoke(System.Action)
        at PlayFab.Internal.PlayFabUnityHttp.OnResponse(PlayFab.Internal.PlayFabUnityHttp)
        at PlayFab.Internal.PlayFabUnityHttp+<Post>d__12.MoveNext(PlayFab.Internal.PlayFabUnityHttp+<Post>d__12)
        at UnityEngine.SetupCoroutine.InvokeMoveNext(UnityEngine.SetupCoroutine)
        at PlayFab.Internal.PlayFabUnityHttp:OnResponse(PlayFab.Internal)
        at PlayFab.Internal.<Post>d__12:MoveNext(PlayFab.Internal)
        at UnityEngine.SetupCoroutine:InvokeMoveNext(UnityEngine)

This is just one example there are plenty more errors like this with different things (getting data from Data Title, setting a score to the leaderbord, sending a request to a cloud script, etc) I'm not able to recreate them, this only happens to certain people downloading the app.

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Xiao Zha avatar image
Xiao Zha answered

According to your error message, the issue may be caused by the network connection. And "NullReferenceException: Object reference not set to an instance of an object." is a common error that can occur when a variable has not been assigned a value (for example, some APIs cannot successfully get a response because of the bad network connection, so you cannot use the response to initialize other variables).

10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

matias avatar image matias commented ·

When that occurs is the error sent in "GetError => { });" ? So if the error occurs i can run the same function again til its loaded correctly?

0 Likes 0 ·
Xiao Zha avatar image Xiao Zha matias commented ·

If the API request is unsuccessful, an error message will be sent to the GetError() callback, and you can re-request. Also, can you provide a complete test code that reproduces the issue. And which version of Unity and PlayFab SDK are you using?

0 Likes 0 ·
matias avatar image matias Xiao Zha commented ·

The one i posted is a complete one... i just turn on/off a game object if successful I called this function in Awake. But i will post another one in another answer since i have char limits Unity Version 2020.3.26f1 Playfab: 2.155.221207

0 Likes 0 ·
Show more comments
matias avatar image
matias answered

This one i use to load a URL in a title data and the user can open it from clicking a banner:

 [SerializeField]private RawImage luzuImg;
     [SerializeField] private GameObject loading;
     [SerializeField] private OpenLink linkOpener;
     private string url;
     void Awake()
     void GetBannerData()
         PlayFabClientAPI.GetTitleData(new GetTitleDataRequest(),
         result =>
             if (result.Data == null || !result.Data.ContainsKey("Banner"))
             var info = JsonHelper.FromJson<BannerInfo>(result.Data["Banner"]);
             foreach (var item in info)
                 url = item.URLBanner;
         }, error => {  });
     IEnumerator DownloadImageIcon(string MediaUrl)
         UnityWebRequest request = UnityWebRequestTexture.GetTexture(MediaUrl);
         yield return request.SendWebRequest();
         if (request.isNetworkError || request.isHttpError)
             Debug.Log("TEST: " + request.error);
             luzuImg.texture = ((DownloadHandlerTexture)request.downloadHandler).texture;
     public void OpenUrl()
        if (string.IsNullOrEmpty(link))
         string linkNoSpaces = link.Replace(" ", "");

This one also has the same issue as the one in the main post

1 comment
10 |1200

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Xiao Zha avatar image Xiao Zha commented ·

Your code is correct. We were unable to reproduce your issue.

0 Likes 0 ·

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.