• Sign Up Login
  • Features
    • Game Services
    • Real-time Analytics
    • LiveOps
    • Add-ons
  • Game Services
  • Real-time Analytics
  • LiveOps
  • Add-ons
  • Games
  • Pricing
  • Blog
  • Support
    • Docs
    • Forums
    • Contact
  • Docs
  • Forums
  • Contact
  • Sign Up Login
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Ideas
    • Articles
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by tomgeorgin · Oct 17 at 09:11 AM · unreal

Unreal Engine 4 Plugin - Asynchronous calls

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

Comment

People who like this

0 Show 0
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
Best Answer

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.

Comment

People who like this

0 Show 1 · Share
10 |1200 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image tomgeorgin · Oct 18 at 04:06 PM 0
Share

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

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Navigation

Spaces
  • General Discussion
  • API and SDK Questions
  • Feature Requests
  • PlayStream
  • Bugs
  • Add-on Marketplace
  • LiveOps
  • Follow this Question

    Answers Answers and Comments

    3 People are following this question.

    avatar image avatar image avatar image

    Related Questions

    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

    • PlayFab

      • Features
      • Games
      • Pricing
      • Blog
    • Engineers

      • Documentation
      • Quickstarts
      • API Reference
      • SDKs
      • Usage Limits
    • Support

      • Forums
      • Videos
      • Contact
      • Service Health
      • Terms of Service
    • Social

      • Facebook
      • Twitter
      • LinkedIn
      • YouTube
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • About Microsoft
    • Jobs
    • Accessibility
    • Diversity & inclusion
    • Security
    • Company news
    • © Microsoft 2019
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Post an idea
    • Create an article
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Ideas
    • Articles
    • Users
    • Badges