question

mrshefich avatar image
mrshefich asked

Crash: Fatal Exception: java.lang.Exception SerializationException : Invalid JSON string

I updated PlayFab Unity SDK and now I have too many such errors: With the Cutom HTTP:

     Fatal Exception: java.lang.Exception
     SerializationException : Invalid JSON string
     PlayFab.Json.PlayFabSimpleJson.DeserializeObject (PlayFab.Json.PlayFabSimpleJson)
     PlayFab.Json.PlayFabSimpleJson.DeserializeObject (PlayFab.Json.PlayFabSimpleJson)
     PlayFab.Json.PlayFabSimpleJson.DeserializeObject[T] (PlayFab.Json.PlayFabSimpleJson)
     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)

With the Unity Web Request:

     Fatal Exception: java.lang.Exception
     SerializationException : Invalid JSON string
     PlayFab.Json.PlayFabSimpleJson.DeserializeObject (PlayFab.Json.PlayFabSimpleJson)
     PlayFab.Json.PlayFabSimpleJson.DeserializeObject (PlayFab.Json.PlayFabSimpleJson)
     PlayFab.Json.PlayFabSimpleJson.DeserializeObject[T] (PlayFab.Json.PlayFabSimpleJson)
     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)

Duplicated because can't asnwer or comment there, probably some server issue.

@Gosen Gao The issue started to appear on Jun 6. On released Android app. Thousands of crashes. It has 0 such crashes before that date. Many devices, all Anroid OS versions starting with the 5th one. Probably connected to the callback after successfully updating user score/values on the PlayFab server. As I see all users are logged in by the moment of crash.

@Simon Cui same issue. I can't answer any of my questions. Already wrote administrators but no answer. Answering you: Unity 2020.3.48, 2021.3.27 Playfab SDK version, don't know how to check it, Just downloaded SDK from this link: https://learn.microsoft.com/en-us/gaming/playfab/sdks/unity3d/installing-unity3d-sdk Not sure if I need this but also have PlayFabEditorExtensions in my project. One of these requests caused the error: 1:

 PlayFabClientAPI.UpdatePlayerStatistics( new UpdatePlayerStatisticsRequest {
             Statistics = new List<StatisticUpdate> {
                 new StatisticUpdate { StatisticName = "xxx", Value = moneyValue },
                 new StatisticUpdate { StatisticName = "xxx", Value = moneyValue },
                 new StatisticUpdate { StatisticName = "xxx", Value = moneyValue },
             }
         },
         result => { Debug.Log("[PlayFabSingleton] User money statistics updated");
         },
         error => { Debug.Log(error.GenerateErrorReport()); });

2:

 PlayFabClientAPI.UpdateUserData(new UpdateUserDataRequest() {
             Data = new Dictionary<string, string>() {
                 {"xxx", highscore}
             }
         }, 
         result => Debug.Log("Successfully updated user data"),
         error => {
             Debug.Log(error.GenerateErrorReport());
         });

3:

 PlayFabClientAPI.GetAccountInfo(new GetAccountInfoRequest()
         {
             PlayFabId = localPlayerId
         }, result => {
             Debug.Log("[GetUserData] GetAccountInfo data: " + result.AccountInfo.TitleInfo.DisplayName);
             // Debug.Log("GetAccountInfo data: " + result.AccountInfo.PlayFabId);
             if (string.IsNullOrEmpty(result.AccountInfo.TitleInfo.DisplayName))
             {
                 Debug.Log("[GetUserData] string.IsNullOrEmpty(result.AccountInfo.TitleInfo.DisplayName");
                 if (PlayerPrefs.HasKey("nicknameSocial"))
                 {
                     Debug.Log("[GetUserData] PlayerPrefs.HasKey(nicknameSocial) setting display name....");
                     SetUserDisplayName(PlayerPrefs.GetString ("nicknameSocial"));
                 } else
                 {
                     Debug.Log("[GetUserData] No!!!! PlayerPrefs.HasKey(nicknameSocial)");
                     string username = "Player" + Random.Range (1, 90000000).ToString();
                     SetUserDisplayName(username);
                 }
             } else
             {
                 Debug.Log("[GetUserData] player already has display name on the account");
                 if (PlayerPrefs.HasKey("nicknameSocial"))
                 {
                     Debug.Log("[GetUserData] PlayerPrefs.HasKey(nicknameSocial) setting display name....");
                     string socialnick = PlayerPrefs.GetString ("nicknameSocial");
                     if (socialnick != result.AccountInfo.TitleInfo.DisplayName)
                     {
                         Debug.Log("[GetUserData] socialnick != result.AccountInfo.TitleInfo.DisplayName! setting display name....");
                         SetUserDisplayName(socialnick);
                     }
                 }
             }
         }, (error) => {
             Debug.Log("[GetUserData] Got error retrieving account info:");
             Debug.Log(error.GenerateErrorReport());
         });

4:

 PlayFabClientAPI.GetUserData(new GetUserDataRequest() {
             Keys = null
         }, result => {
             bool updateServer = false;
             if (result.Data == null)
             {
                 updateServer = true;
             } else
             {
                 if (!result.Data.ContainsKey("xxx")) 
                 {
                     updateServer = true;
                 } else 
                 {
                     Debug.Log("[GetUserData] moneywon: "+result.Data["xxx"].Value);
                     long highscore = long.Parse(ZPlayerPrefs.GetString ("xxx", "0"));
                     long highscoreFromServer = long.Parse(result.Data["xxx"].Value);
                     if (highscoreFromServer > highscore)
                     {
                         menuUIscript.ShowHighscore();
                     } else if (highscoreFromServer < highscore)
                     {
                         updateServer = true;
                     }
                 }
             }
             if (updateServer) SetUserData();
         }, (error) => {
             Debug.Log(error.GenerateErrorReport());
         });

Not possible to capture Fiddler traces. Btw I see that you have such errors for almost 3 years, as for Android SDK. And in your code you have try/catch and other logic to catch errors. But somehow the error still exist.

How can I fix them?

unity3dsdks
10 |1200

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

1 Answer

·
Gosen Gao avatar image
Gosen Gao answered

You can check your PlayFabSDK version on PlayFab EdEx page. I implemented a test project that calls the APIs you mentioned, build it as an Android apk and test it on an Android emulator. But I cannot reproduce this issue, this test app works fine. Can you implement a test project to see if this issue can be reproduced?

6042-image.png


image.png (22.0 KiB)
10 |1200

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

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.