PlayFab / PlayFabMultiplayerUnreal

PlayFab Online Subsystem Plugin for Unreal Engine
https://learn.microsoft.com/en-us/gaming/playfab/features/multiplayer/networking/party-unreal-engine-oss-overview
39 stars 35 forks source link

Initialization race condition #22

Closed bwagstaff closed 1 year ago

bwagstaff commented 1 year ago

When multiple networking libraries are used in a solution, this initialization is a race condition. If other socket subsytems are initialized, the playfab socket subsystem will not initialize. As a local fix we're adding the condition: static_cast<FPlayFabSocketSubsystem*>(ISocketSubsystem::Get(PLAYFAB_SOCKET_SUBSYSTEM)) == nullptr

https://github.com/PlayFab/PlayFabMultiplayerUnreal/blob/7e146a22a4adf81301a89f367756dc0b7c347a4e/Source/Private/OnlineSubsystemPlayFab.cpp#L108

nassosterz-ms commented 1 year ago

I am not quite sure I understand how your added condition helps. Are you saying that the PlayFabSubsystem can be initialized from another networking library?

Leonardo-Rocha commented 1 year ago

I believe he's suggesting the following. Changing from:

https://github.com/PlayFab/PlayFabMultiplayerUnreal/blob/7e146a22a4adf81301a89f367756dc0b7c347a4e/Source/Private/OnlineSubsystemPlayFab.cpp#L108

To:

if (static_cast<FPlayFabSocketSubsystem*>(ISocketSubsystem::Get(PLAYFAB_SOCKET_SUBSYSTEM)) == nullptr)
{
    UE_LOG_ONLINE(Log, TEXT("Initializing PlayFabPartSocketSubsystem"));
    CreatePlayFabSocketSubsystem();
}

IMO the original condition doesn't make sense, since this line https://github.com/PlayFab/PlayFabMultiplayerUnreal/blob/7e146a22a4adf81301a89f367756dc0b7c347a4e/Source/Private/OnlineSubsystemPlayFab.cpp#L107

actually returns the PlayFabSDK plugin which has no sockets subsystem at all. Maybe it had at some point in the past, but it doesn't work now.