Microsoft Azure PlayFab logo
    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Add-ons
    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA
  • Runs on PlayFab
  • Pricing
    • Blog
    • Forums
    • Contact us
  • Sign up
  • Sign in
  • Ask a question
  • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges
  • Home /
  • API and SDK Questions /
avatar image
Question by tomgeorgin · Oct 17, 2019 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, 2019 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, 2019 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

    What Blueprint in UE should I place the Update Stats calls? 0 Answers

    PlayFab Party in Unreal 1 Answer

    CurrentMatchmakerLobbyId is empty in Unreal client 1 Answer

    PlayFab

    • Multiplayer
    • LiveOps
    • Data & Analytics
    • Runs on PlayFab
    • Pricing

    Solutions

    • For Any Role

      • Engineer
      • Designer
      • Executive
      • Marketer
    • For Any Stage

      • Build
      • Improve
      • Grow
    • For Any Size

      • Solo
      • Indie
      • AAA

    Engineers

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

    Resources

    • Forums
    • Contact us
    • Blog
    • Service Health
    • Terms of Service
    • Attribution

    Follow us

    • Facebook
    • Twitter
    • LinkedIn
    • YouTube
    • Sitemap
    • Contact Microsoft
    • Privacy & cookies
    • Terms of use
    • Trademarks
    • Safety & eco
    • About our ads
    • © Microsoft 2020
    • Anonymous
    • Sign in
    • Create
    • Ask a question
    • Create an article
    • Post an idea
    • Spaces
    • PlayStream
    • Feature Requests
    • Add-on Marketplace
    • Bugs
    • API and SDK Questions
    • General Discussion
    • LiveOps
    • Explore
    • Topics
    • Questions
    • Articles
    • Ideas
    • Users
    • Badges