question

Andy Maddison avatar image
Andy Maddison asked

Issues when setting PlayFabSettings properties (Unity)

I'm using the latest Unity plugin 2.11 with Unity 5.3.6.

I've been having an issue on device only (iOS) where I get an exception from PlayFabSettings.GetSharedSettingsObject.

I get this message first:

Recursive Serialization is not supported. You can't dereference a PPtr while loading. (Constructors of C# classes may not load objects either eg. EditorGUIUtility.TextContent should be moved to OnEnable. See stacktrace.)

Then an exception because the settings were not loaded:

Unhandled Exception: System.TypeInitializationException: An exception was thrown by the type initializer for PlayFab.PlayFabSettings ---> System.Exception: Either Missing PlayFabSharedSettings data file or multiple data files exist. at PlayFab.PlayFabSettings.GetSharedSettingsObject () [0x00000] in <filename unknown>:0 at PlayFab.PlayFabSettings..cctor () [0x00000] in <filename unknown>:0 --- End of inner exception stack trace ---

I've discovered it's something to do with setting the PlayFabSettings.TitleId property so I've removed the call from my code as I can set the title id in the settings asset.

As a quick test I called another property:

PlayFabSettings.LogLevel = PlayFabLogLevel.All;

And the same issue occurs. I can't reproduce at all in a test project.

Presumably I don't need to use the properties anyway as I can use the settings asset?

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

·
1807605288 avatar image
1807605288 answered

The error you're catching is in PlayFab code:

https://github.com/PlayFab/UnitySDK/blob/master/Source/PlayFabSDK/Shared/Public/PlayFabSettings.cs#L38

Sadly, the text of that error doesn't really help us, so please change it to this and rerun:

throw new Exception("Failed to load PlayFabSharedSettings: 1 != " + settingsList.Length);

If you have accidentally created more than 1 of our PlayFabSharedSettings scriptable objects, then you might be seeing this issue.

Otherwise, you're catching a behavior that we didn't expect, which is that assigning values in PlayFabSettings affects how many of those objects exist.

More information is better because we can't reproduce this issue yet.

12 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 ·

@Paul Gilmore as I said in my post, the settings are not loaded, i.e. the list length is zero. The settings asset is present.

Perhaps it's not clear, but if I don't set a PlayFabSettings property (tested with TitleId & LogLevel properties) then it all works fine.

To summarise:

Set a property, e.g. PlayFabSettings.TitleId.

Get error message about Recursive Serialization not being supported when trying to load asset.

Get exception because asset not loaded.

I can't reproduce in a test project. If you want me to investigate further I can - what do you need me to do?

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

Andy, we need some additional info from your repro case, to get us what we need to track this down. Can you please follow Paul's instructions above, adding the throw to your code and getting us the results, so that we have that data for analysis? It shouldn't take more than a few seconds to do that.

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

As I said earlier, settings are not loaded, i.e. settingsList.Length is zero.

Clearly it will now say "Failed to load PlayFabSharedSettings: 1 != 0".

The problem is something to do with using the properties in PlayFabSettings in an Awake call. Just doing a get on PlayFabSettings.LogLevel is enough to cause the problem. If I remove the call or simply delay a few seconds then there is no problem.

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

@Andy Maddison because I feel we need more information to troubleshoot this issue, I would like to setup a call with you so I can see what is going on in your project.

This is a tough issue as there is no valid reason why you should not be able to call a get on any property in PlayFabSettings if the SDK is installed correctly.

As Paul stated, there could be issues if you have more than one settings file in the project. There can also be import issues where the scriptable object is not being recognized by Unity, and that is just a unity bug that happens with Scriptable objects sometimes.

Either way, I think the fastest way to fix your issue is to jump in a Google Hangouts or skype call and we can take a look with you. You shouldn't be having this issue.

If you are in our community slack, then hit me up there or email me directly at marco@playfab.com and we'll schedule a time.


@anyone that is following this thread, I will post the solution to the issue once Andy and I work it out.

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

@marco@playfab.com I've emailed you.

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

@marco@playfab.com was the information I sent of any use?

0 Likes 0 ·
Marco Williams avatar image Marco Williams commented ·

@Andy Maddison yeah, the info was received and we are reviewing. It does make sense, and we are looking into it.

0 Likes 0 ·
tharinga avatar image tharinga commented ·

Has this been solved yet?

I am experiencing the same issue. settingsList.Length is 0

The problem started after I upgraded to the latest version of the PlayFab SDK yesterday.

Reverting my project to a previous version of the SDK solved the problem. (not sure of version, but downloaded in August)

The older SDK works fine so this is not an urgent problem for me at this time.

0 Likes 0 ·
1807605288 avatar image 1807605288 ♦ tharinga commented ·

Are you also seeing this on iOS only?

0 Likes 0 ·
tharinga avatar image tharinga 1807605288 ♦ commented ·

Yes, iOS only.

0 Likes 0 ·
1807605288 avatar image 1807605288 ♦ tharinga commented ·

The best solution right now is to NOT set your titleid, or other settings values via the static class PlayFabSettings, but rather always use the scriptable object PlayFabSharedSettings.asset.

We will resume investigating this issue next week, but the ETA for the actual fix is unknown at this time.

I'm fairly certain if you avoid assigning values to the PlayFabSettings static class, you shouldn't have the issue.

0 Likes 0 ·
tharinga avatar image tharinga 1807605288 ♦ commented ·

Indeed, no issue when using the scriptable object as you suggest. Thanks!

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.