Hello,
we. get the following Exception while testing nearly simultaneous access to title data.
Object reference not set to an instance of an object.
We assume this may be a thread bug here. We call the PlayFabServerAPI from a local azure function, to get some tile data. Thanks for your help.
The corresponding stack trace:
at System.Collections.Generic.Dictionary`2.TryInsert(TKey key, TValue value, InsertionBehavior behavior)\n at System.Collections.Generic.Dictionary`2.set_Item(TKey key, TValue value)\n at PlayFab.PluginManager.GetPluginInternal(PluginContract contract, String instanceName)\n at PlayFab.PluginManager.GetPlugin[T](PluginContract contract, String instanceName)\n at PlayFab.Internal.PlayFabHttp._DoPost(String fullPath, PlayFabRequestCommon request, String authType, String authKey, Dictionary`2 extraHeaders, PlayFabApiSettings instanceSettings)\n at PlayFab.Internal.PlayFabHttp.DoPost(String urlPath, PlayFabRequestCommon request, String authType, String authKey, Dictionary`2 extraHeaders, PlayFabApiSettings instanceSettings)\n at PlayFab.PlayFabServerAPI.GetTitleInternalDataAsync(GetTitleDataRequest request, Object customData, Dictionary`2 extraHeaders)\n at GoGBackend.Controller.MiniGameController.GetMiniGames()
May I have the code snippet that reproduces this issue? Please also specify the version of the PlayFab SDK you're using.
NuGet- PlayFabAllSDK 1.80.200901
var playerTitleData = await PlayFabServerAPI.GetTitleInternalDataAsync(new GetTitleDataRequest { Keys = new List<string> { "miniGameCollection" } });
I was not able to reproduce this error using PlayFabAllSDK 1.80.200901 in my FunctionApp project, could you please provide a complete reproduce steps so that I can investigate further?
Well we're using the ExecuteFunction script for executing the function locally. Furthermore we make two parallel calls to our "local" azure function. The exception is not always thrown. It seems to be a tricky thread-bug. The PlayFabServerAPI is generally thread safe, right?
Maybe you have a great solution for not accessing the title data on every azure function call. We thought about a static var holding the data, but what about updating this static var.. Do you have a best practice here for accessing Title Data in Azure Functions?
Yes, they're generally thread safe, and, I also tried using the ExecuteFunction script for executing the function locally and make nearly simultaneous requests to the local Function app, however, I cannot reproduce the same issue:(
Looking at the stack track you provided, looks like the error happened at:
PlayFab.PluginManager.GetPluginInternal(PluginContract contract,String instanceName)
Have you find anything regarding this issue?
And, accessing Title Data per request won't be a problem as it was designed as Global Constant/Static Data.