Hello,
I have been working with the Unreal Engine 4 Plugin for PlayFab and have noticed, after profiling the game, that the calls to `WritePlayerEvent` tend to generate a hitch.
They seem to be executed on the GameThread (main Thread for Unreal Engine), and are causing hitches.
I will be using
WriteEvents
instead of
WritePlayerEvent
to reduce the number of calls I make, but there will still be a problem of hitch during that single WriteEvents call.
My question is:
Is there an option I missed that enables the plugin to handle its HTTP requests asynchronously (and send the request on a separate thread), or do I have to manage my own Thread and call the functions such as WriteEvents on a separate thread to ensure it's not causing hitches on the main thread?
Thank you very much for your help!
Tom
Answer by Citrus Yan · Oct 18 at 08:36 AM
Hi @tomgeorgin,
>>or do I have to manage my own Thread and call the functions such as WriteEvents on a separate thread to ensure it's not causing hitches on the main thread?
As a matter of fact, requests to PlayFab Client APIs are asynchronous. And OnSuccess and OnError are the asynchronous callbacks that will be invoked after PlayFab Client APIs complete.
According to the unreal SDK source code, it uses FHttpModule for Http request, which is asynchronous, however, it seems to me that it won't create a new thread.
Referring to this doc, for now, the PlayFab Unreal C++ SDK maintains state with static variables which are non-atomic and are not guarded by synchronization techniques. Hence PlayFab recommends limiting PlayFab calls to within the main Unreal thread. However, as I see it, using a separate thread to call functions such as WriteEvents won’t change those static variables since you only write events to PlayFab. You can have a try and see what happens.
Hello Citrus, thank you for your answer.
To clarify, I meant multi-threaded, not asynchronous. Yes, PlayFab requests are all Asynchronous but they are on the main thread (called GameThread in Unreal), and the plugin doesn't seem to give the option to do its logic on another thread (Which was my question initially).
Regarding HTTP module in Unreal, the "ProcessRequest()" function is very CPU intensive and causes the Hitch in our game.
I think there is no way around managing our own thread and sending the PlayFab requests on that other thread to do all of this (including the HTTP request) on a separate thread.
I was just curious if there was an option already included in PlayFab Plugin to do that, after your answer + looking through their code, it does not appear so.
Thank you for your time, I'll mark you as answer.
Best regards,
Tom
Let's talk Unreal Engine(And the Entity API) 1 Answer
What's the Title Shared Secret in the GetTitlePublicKey Request (unreal engine 4) 1 Answer
CurrentMatchmakerLobbyId is empty in Unreal client 1 Answer
How can I get the logs of the server? 1 Answer
Unreal Playfab Multiplayer,Unreal Multiplayer Playfab 1 Answer