World Initialization performed on Transition World instead of Destination World during SeamlessTravel on Clients

Our team is currently developing a multi-player game using Visual Studio 2013 and engine version 10.04. We are using the ShooterGame sample from Epic Games as a template. Below is a virtual demonstration how problems could arise in clients when we call AGameMode::RestartGame() on the server:

Preparation:

Let us attach some break points to the code before we test:

Step 1: Attach break-point to UWorld::CreateWorld(…)

Step 2: Attach break-point to AWorldSettings::NotifyBeginPlay()

Step 3: Attach break-point to APlayerController::Tick(…) and DISABLE it

Round 1 test:

Step 1: Run game as server without debugging

Step 2: Run game as client with debugging, client will be connected to server and play normally

Step 3: Call AGameMode::RestartGame() on server

Step 4: Client will trigger break-point at UWorld::CreateWorld(…). This is called by FSeamlessTravelHandler::StartTravel(…) with comment

“// If a default transition map doesn’t exist, create a dummy World to use as the transition”

Step 5: Immediately press Continue on visual studio debugger. Must be fast!

Step 6: Client will trigger break-point at AWorldSettings::NotifyBeginPlay() called by AGameState::HandleMatchIsWaitingToStart(). The value returned by GetWorld() is DIFFERENT from the AWorld from Step 4.

Step 7: Everything works. Everyone is happy.

Round 2 test:

Repeat Step 1-4 from Round 1

Step 5: Wait ~5 seconds and then press Continue on visual studio debugger.

Step 6: Client will trigger break-point at AWorldSettings::NotifyBeginPlay() called by AGameState::HandleMatchIsWaitingToStart(). The value returned by GetWorld() is THE SAME from the AWorld from Step 4.

Step 7: Activate the breakpoint at APlayerController::Tick(…).Immediately we trigger a break. If we watch the value of GetWorld(), we will find this is DIFFERENT from the AWorld from Step 6. Moreover, its member field bBegunPlay is false.

Step 8 A lot of things breaks, because the world they live in is not initialized.

Conclusion

We are worried that perhaps there is a replication timing bug in the UE4 version 10.4. When the server is restarting, the initialization signal sent to the client through AGameState may be received by the intermediate map created in seamless travel instead of the destination map.

Thank you for reading this report. We are looking forward to hearing from you.

The result of this issue is that sometimes, when we restart the match, the game completely breaks on the client side… could someone kindly give us some pointer what should we do?

Hello Victor S.C. Lui,

I’m currently looking into this issue and will get back to you as soon as I can. I just wanted to leave a message here to let you know that your post isn’t being ignored.

Thank you Mattehw. It is very nice to hear from you! Here is a short update from my end:

I tried to do a quick fix on this issue by asking the GameState to persistently try to initialize the destination UWorld when the match is in progress, which solves some issues.

However, although some issues are solved, other issue still persist. For example, the GameState member in the destination UWorld is still nullptr during the match.

Thanks for the update again!

Thank you for the information. I’ve placed a bug report in for the issue under the number UE-29388. I’ll be sure to let you know if any updates are made to the bug or if a fix is put in.

Have a nice day!

Thank you! For anyone that is interested, the fix i have in place is to override the RestartGame function and instead of calling Server-travel we simply reset all the actors in the same map!

Have a nice day!