question

Andy Maddison avatar image
Andy Maddison asked

Cannot call LoginWithFacebook on device via Unity without error

Hello. I'm just trying to get started with PlayFab on Unity. I have done some testing in the editor and things are working fine. However, on my iOS device I cannot call LoginWithFacebook without an error. I am logged into Facebook itself ok.

My app id is 197F.

I get error code 'Unknown'.

HttpCode: 200.

HttpStatus: Client failed to parse response from server.

No error details.

And this for the error message:

System.MemberAccessException: Cannot create an instance of PlayFab.Internal.ResultContainer`1[TResultType] because Type.ContainsGenericParameters is true.

  at System.Reflection.MonoCMethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0

  at System.Reflection.MonoCMethod.Invoke (BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] in <filename unknown>:0

  at System.Reflection.ConstructorInfo.Invoke (System.Object[] parameters) [0x00000] in <filename unknown>:0

  at PlayFab.Json.ReflectionUtils+<GetConstructorByReflection>c__AnonStoreyD.<>m__20 (System.Object[] args) [0x00000] in <filename unknown>:0

  at PlayFab.Json.PocoJsonSerializerStrategy.DeserializeObject (System.Object value, System.Type type) [0x00000] in <filename unknown>:0

  at PlayFab.Internal.Util+MyJsonSerializerStrategy.DeserializeObject (System.Object value, System.Type type) [0x00000] in <filename unknown>:0

  at PlayFab.Json.SimpleJson.DeserializeObject (System.String json, System.Type type, IJsonSerializerStrategy jsonSerializerStrategy) [0x00000] in <filename unknown>:0

  at PlayFab.Json.SimpleJson.DeserializeObject[ResultContainer`1] (System.String json, IJsonSerializerStrategy jsonSerializerStrategy) [0x00000] in <filename unknown>:0

  at PlayFab.SimpleJsonInstance.DeserializeObject[ResultContainer`1] (System.String json, System.Object jsonSerializerStrategy) [0x00000] in <filename unknown>:0

  at PlayFab.SimpleJson.DeserializeObject[ResultContainer`1] (System.String json, System.Object jsonSerializerStrategy) [0x00000] in <filename unknown>:0

  at PlayFab.Internal.ResultContainer`1[PlayFab.ClientModels.LoginResult].HandleResults (PlayFab.CallRequestContainer callRequest, System.Delegate resultCallback, PlayFab.ErrorCallback errorCallback, System.Action`2 resultAction)

10 |1200

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

brendan avatar image
brendan answered

So that everyone has the final info on this thread: This issue was fixed as of the July Unity SDK update, which was promoted to https://github.com/PlayFab/UnitySDK after we completed the Beta period.

10 |1200

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

Zac Bragg avatar image
Zac Bragg Deactivated answered

Hey Andy,

This issue occurs when trying to build using the Mono2x build settings. This is a bad practice and will not pass Apple certification. Please use IL2CPP build settings when building from Unity to any iOS platform. 

Let us know if this resolves your issue.

-Zac

 

 

2 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.

Andy Maddison avatar image Andy Maddison commented ·

Happy to see that updating to 160725 fixes the issue and I can now build with Mono2x Scripting Backend.

You should remove the 'Best Answer' tag from this post because it's not.

0 Likes 0 ·
brendan avatar image brendan Andy Maddison commented ·

Good point - we'll update the thread.

0 Likes 0 ·
Andy Maddison avatar image
Andy Maddison answered

Hi Zac.

Bad practice? Do you think every single build I do is for an Apple submission? The vast majority of builds I do are for development and Mono is much quicker. When compared to Mono, IL2CPP builds take at least double the time in Unity, and maybe 4 times as long to build in Xcode. For development I want a quick build.

I found this in your release notes here.

Known Issue (not resolved): SimpleJson does not serialize correctly when using the Player Setting "Scritping Backend" option: "Mono2x". Until this is fixed, please use "IL2CPP" if possible.

This tells me that the problem will be fixed. When can we expect that?

10 |1200

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

Zac Bragg avatar image
Zac Bragg Deactivated answered

Hey Andy,

The issue is already "fixed" in the sense that we have refactored our Unity SDK to allow for developers to override the default serialization library. We will be releasing a guide on how to do this in the next week or so.   

The root of the issue comes down to us not finding any one serialization library that properly works across all Unity build targets. So the only way to move forward is to allow developers to switch out libraries depending on the build target. So in this case, the developer will need to have another serialization library ready to use in place of SimpleJson.

If you are looking to move forward on using your own serializer let me know and I can walk you through the details.

 

-Zac

 

10 |1200

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

Andy Maddison avatar image
Andy Maddison answered

I use JSON .NET which works across the platforms we build for. Please explain the details.

10 |1200

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

Zac Bragg avatar image
Zac Bragg Deactivated answered

Sure thing,

Essentially you need to:

  • Implement a wrapper (using PlayFab.ISerializer) to the serialization library of your choosing.
  • Assign the instance to PlayFab.SimpleJson.Instance before making any PF calls (Awake() or Start() works well for this)

Here is an example project where we have already created the serializer override for JSON.net. Let me know if you have any questions.

 

Sorry for not having this out in a more public fashion; thanks again for your patience, 

-Zac

 

 

 

 

10 |1200

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

Andy Maddison avatar image
Andy Maddison answered

I still get the same error with the overridden JSON handling when running on MONO.

I added the implementation from your sample and made sure the instance was set. I debugged it on the device and it does hit the overridden handlers.

Why haven't you used Unity's built-in #defines to make sure your code can handle the various build targets? There are ENABLE_MONO and ENABLE_IL2CPP which you could use to provide the appropriate Json handling that worked?

10 |1200

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

Zac Bragg avatar image
Zac Bragg Deactivated answered

Thanks for the update. I was able to reproduce your error on our side. We are looking into it.

 

 

10 |1200

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

Andy Maddison avatar image
Andy Maddison answered

Ok. Hope you can fix asap.

10 |1200

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

Andy Maddison avatar image
Andy Maddison answered

Any idea of when this will be fixed. I'm getting sick of long build times just to test.

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.