question

Francois Boucher-Genesse avatar image
Francois Boucher-Genesse asked

SerializationException: Invalid JSON string - android issue

Hello,We recently updated the playfab SDK version in our client and are getting a few crashes since then. I see several threads about this exception, but they mostly seem to relate to LocalExecuteFunction, which we're not using. It's unclear what triggers this crash for us, since we are doing several types of calls (cloud script, functions, API calls). We're not able to repro, but at least 20 users got this crash so far. Interestingly, they are all on Android, even though we have more iOS users.

This developer seems to have had a similar problem, and the suggestion is to set "Accept-Encoding" to "identity". But this threads suggests that we should not do this, as playfab relies on the "gzip" encoding.

I'm really unsure how to debug this properly, besides adding more logging in our next version. Is Playfab aware of this issue, and do you have recommendations on how to potentially address this?Thanks.

playfab sdk version: 2.116

Unity: 2019.4.26f1

Callstack:
PlayFab.Json.PlayFabSimpleJson.DeserializeObject (System.String json) (at <00000000000000000000000000000000>:0) PlayFab.Json.PlayFabSimpleJson.DeserializeObject (System.String json, System.Type type, PlayFab.Json.IJsonSerializerStrategy jsonSerializerStrategy) (at <00000000000000000000000000000000>:0) PlayFab.Json.PlayFabSimpleJson.DeserializeObject[T] (System.String json, PlayFab.Json.IJsonSerializerStrategy jsonSerializerStrategy) (at <00000000000000000000000000000000>:0) PlayFab.Internal.PlayFabUnityHttp.OnResponse (System.String response, PlayFab.Internal.CallRequestContainer reqContainer) (at <00000000000000000000000000000000>:0) PlayFab.Internal.PlayFabUnityHttp+<Post>d__12.MoveNext () (at <00000000000000000000000000000000>:0) UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) (at <00000000000000000000000000000000>:0) PlayFab.Internal.<Post>d__12:MoveNext() UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
sdks
10 |1200

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

Francois Boucher-Genesse avatar image
Francois Boucher-Genesse answered

Adding to this - the part that surprises me is that the exception should be caught in

PlayFab.Internal.PlayFabUnityHttp.OnResponse, but for some reason it crashes the app.

3 comments
10 |1200

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

Sarah Zhang avatar image Sarah Zhang commented ·

Thanks for your sharing. We will try to reproduce and investigate this exception.

0 Likes 0 ·
Francois Boucher-Genesse avatar image Francois Boucher-Genesse Sarah Zhang commented ·

I just realized that the exception is actually caught @Sarah Zhang. It is being logged with Debug.LogException, which is not a pattern we use. Our crash handling method relies on Application.logMessageReceived to catch any exception and stop the app's flow, so any Debug.LogException will show up as a crash in our app. We will be fixing this on our end, but the fact still remains that the exception happens. This might explain why we're the only one reporting on this.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Francois Boucher-Genesse commented ·

We noticed you have posted an other thread here - Unity SDK doesn't allow developers to handle critical failures / exceptions - Playfab Community to discuss this issue of PlayFab Unity SDK. Thanks for your report for the issue, we will inform our team to investigate it.

0 Likes 0 ·
Francois Boucher-Genesse avatar image
Francois Boucher-Genesse answered

In case it's relevant, I should mention that the request type seems to be different in two different settings for us.

In the Playfab Extension it is using Unity www (instead of Http Web Request or Unity Web Request).

In the shared settings scriptable object, it is using Unity Web Request)

6 comments
10 |1200

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

Sarah Zhang avatar image Sarah Zhang commented ·

According to your description, it is an issue only appears on some models of android devices, is it right? If so, it may be relevant to the memory size or other device differences between the different Android devices. For troubleshooting, you can try to use Android application performance monitor tool to check if there is any abnormal memory usage and is there any operation caused the memory leak.

Currently, I can’t locate the specific causes of the application crash based on the known information. Could you please try to upgrade PlayFab SDK to the latest 2.120 version?

Besides, I noticed some customer in other threads, such as in this thread - Help! I get an error when opening the login window on my Android phone. - Playfab Community resolved the random crash issue on Android trough migrating the original project content to a newly created project. You can try to recompile temporary files of your Unity project too, then create and test the builds again.

0 Likes 0 ·
Francois Boucher-Genesse avatar image Francois Boucher-Genesse Sarah Zhang commented ·

Thanks for the reply @Sarah Zhang

Correct, this is only for android users for some reason. Looking at system memory size though, users are still getting the crash even with high memory devices, so that doesn't seem to be the cause.

I should also note that we can't repro this issue, so we could do the suggestion about migrating the project but we wouldn't know if that fixes it. We could also update the SDK version, but we won't know until we ship another build if that fixes it. The one we have is quite recent too - do you know that a potential fix was included in the past 4 versions?

The thread you posted was seeing this bug reproing all the time, which isn't the case for us. Some % of users are hitting this crash, but then the same users are subsequently doing calls to playfab without any problem. So it's unfortunately intermittent.

One hypothesis is that the playfab settings could cause the problem, which would explain why changing project can fix this. I'm tempted to set the Playfab Extension to use Unity Web Request, so that it's consistent with the shared settings. Could you let me know if you have thoughts on this?

0 Likes 0 ·
Francois Boucher-Genesse avatar image Francois Boucher-Genesse commented ·

@Sarah Zhang just doing a follow-up on this. Do you think changing Playfab Extension could have an impact? I'm open to any other suggestions. The main challenge on our end is that we will have to wait several weeks between each attempt at fixing this, since we need to push a new build out every time.

0 Likes 0 ·
Sarah Zhang avatar image Sarah Zhang Francois Boucher-Genesse commented ·

In fact, your configurations of “request type” in the PlayFabSharedSettings and PlayFab Unity Extension will be synchronized when you save the changes of the Unity project. There would be only one request type in your project. However, there is a known display issue in PlayFab Extension, it displays “Unity WWW” as “Unity Web Request”, and displays “Custom Http” as “Unity Web Request”. You can use the following comment to print the current actual request type of your project.

Debug.Log(PlayFabSettings.RequestType); 

Besides, PlayFab Unity Extension is a Unity Editor plugin to help configure PlayFab settings. I think it won't affect the actual game logic or cause the game crash. You can also try to remove it when you build the clients to rule out possible effects.

0 Likes 0 ·
Francois Boucher-Genesse avatar image Francois Boucher-Genesse Sarah Zhang commented ·

Ultimately all of our crashes are coming from the file PlayFabUnityHttp, which I believe is the recommended request type for unity.

I thought I'd mention that we are also seeing this crash in the editor, although it doesn't happen often so it's really hard to reproduce. So far it does not happen on iOS.

0 Likes 0 ·
Show more comments
Francois Boucher-Genesse avatar image
Francois Boucher-Genesse answered

Just an update @Sarah Zhang - while we fixed the fact that the app crashes when this exception occurs, we are now logging when this happens and now know that the json is empty when the exception is raised. We also were able to reproduce this once in the unity editor. It seems to happen on any playfab API call.

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.