tufanuyguner avatar image
tufanuyguner asked

PlayFab JSON Deserializer breaks on WebGL

Hello, I'm having trouble getting WebGL builds to work. It throws NullRef after LoginWithCustomID request, this never happens in Editor.

This is the error I'm getting:

NullReferenceException: Object reference not set to an instance of an object.
  at PlayFab.Json.PocoJsonSerializerStrategy.DeserializeObject (System.Object value, System.Type type) [0x00000] in <00000000000000000000000000000000>:0 
  at PlayFab.Json.SimpleJsonInstance+PlayFabSimpleJsonCuztomization.DeserializeObject (System.Object value, System.Type type) [0x00000] in <00000000000000000000000000000000>:0 
  at PlayFab.Json.PlayFabSimpleJson.DeserializeObject (System.String json, System.Type type, PlayFab.Json.IJsonSerializerStrategy jsonSerializerStrategy) [0x00000] in <00000000000000000000000000000000>:0 
  at PlayFab.Json.PlayFabSimpleJson.DeserializeObject[T] (System.String json, PlayFab.Json.IJsonSerializerStrategy jsonSerializerStrategy) [0x00000] in <00000000000000000000000000000000>:0 
  at PlayFab.Json.SimpleJsonInstance.DeserializeObject[T] (System.String json) [0x00000] in <00000000000000000000000000000000>:0 
  at PlayFab.Internal.PlayFabUnityHttp.OnResponse (System.String response, PlayFab.Internal.CallRequestContainer reqContainer) [0x00000] in <00000000000000000000000000000000>:0 
  at PlayFab.Internal.PlayFabUnityHttp+<Post>d__12.MoveNext () [0x00000] in <00000000000000000000000000000000>:0 
  at UnityEngine.SetupCoroutine.InvokeMoveNext (System.Collections.IEnumerator enumerator, System.IntPtr returnValueAddress) [0x00000] in <00000000000000000000000000000000>:0 
UnityEngine.DebugLogHandler:Internal_LogException(Exception, Object)
UnityEngine.DebugLogHandler:LogException(Exception, Object)
UnityEngine.Logger:LogException(Exception, Object)
PlayFab.Internal.PlayFabUnityHttp:OnResponse(String, CallRequestContainer)
UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)
(Filename: currently not available on il2cpp Line: -1)

This is the API response

<id> Response:

10 |1200

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

Gosen Gao avatar image
Gosen Gao answered

First, the PlayFabSimpleJson has been replaced by PlayFab.PluginManager.GetPlugin<ISerializerPlugin>(PluginContract.PlayFab_Serializer), you may try it to see if this issue still happens. For more information, please refer to

“Object reference not set to an instance of an object” is a general error which is often caused by something missing. I can’t reproduce this issue, can you figure out in which step does this error occur?

10 |1200

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

tufanuyguner avatar image tufanuyguner commented ·

Hi, I haven't changed the default serializer plugin, but PlayFab.PluginManager.GetPlugin<ISerializerPlugin>(PluginContract.PlayFab_Serializer) returns SimpleJson

plugin = this.CreatePlugin<PlayFab.Json.SimpleJsonInstance>();

It only happens in Windows and WebGL builds and never in editor. It might be happening in other builds as well but I haven't tried them yet. Both IL and Mono backends has this issue.

Here's the line that throws the null reference:


and here's what I do to get the NullReference

PlayFabClientAPI.LoginWithCustomID(new LoginWithCustomIDRequest { CreateAccount = true, CustomId = Guid.NewGuid().ToString() },OnLoginSuccess, OnPlayFabError);
0 Likes 0 ·
Gosen Gao avatar image Gosen Gao tufanuyguner commented ·

I didn’t see anything about SimpleJson in your LoginWithCustomID call. So I can’t reproduce this issue. Would you mind providing us some detailed code on how and where you are using SimpleJson for further research?

0 Likes 0 ·
tufanuyguner avatar image tufanuyguner Gosen Gao commented ·

I'm not using PlayFab's JSON stuff anywhere, PlayFab uses it internally to deserialize API responses.

0 Likes 0 ·
Show more comments
Niall Muldoon avatar image
Niall Muldoon answered

Old thread, but it does show up on google...

This is usually caused by stripping and I see it on iOS quite a bit. You can make use of the link.xml file to preserve a class that is being stripped, but I have also seen it where I've done this and the constructor is still being stripped, adding the [Serializable] tag prevents that.

Example link.xml file:

 <assembly fullname="Assembly-CSharp">
     <type fullname="Namespace.ClassName" preserve="all"/>
 <assembly fullname="PlayFab" preserve="all"/>
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.