Replicated actor component inside PlayerController gets messed up after seamless travel

Bumped into this nasty issue today. I have an actor component (that replicates) added to my PlayerController derived blueprint and it consistently gets destroyed after the seamless travel and never re-created after that.

My best guess about the root cause of the problem is that PlayerController instances aren’t fully replicated but are rather created both locally and remotely, then hooked up for proper networking. That makes everything work fine when the player starts a game but after the seamless travel the proxy instance of PlayerController gets the component destroyed via replication after it’s been recreated locally. The component reconstruction simply isn’t synchronized between related PlayerController instances on the client and the server.

I had to use an ugly workaround but hopefully the issue can be fixed as we are sort of bound to having advanced client-server code executed by something that is owned by PlayerController if we want RPCs to work.

Hey bstone,

I’ve tested this by creating a player controller that has a replicated actor component (which is a separate blueprint) added to it.

Then, I checked for the actor component’s validity in the level blueprints of my starting map and the map I wanted to seamless travel to.

After executing ServerTravel and traveling to the other map, it appeared that the actor component was valid in both maps both before and after seamless travel.

Could you provide some more information regarding your setup? Screenshots of blueprints would be great as well as information regarding exactly how you’re going about testing this so I can be sure to do the same on my end.

Also, if you have a test project that experiences this issue, feel free to share that as well.

Thanks!

Hello Sean,

Thanks for looking into this. Once I realized the cause of the problem I’ve reworked my setup quite substantially so I can’t make any actual screenshots at the moment. And unfortunately I don’t have a test project with that bug isolated at the moment.

One critical thing to my setup though is that I wasn’t running the networked session inside UE4 Editor but rather a real remote server and a local client first, then two separate processes locally: one started with -server and the other one with -game. I haven’t tested it in UE4 Editor against a built-in dedicated or listen server.

I’ve also noticed that when I tried to debug the issue getting a breakpoint hit and then continuing the execution 1-2 seconds after that fixed the problem. It clearly depends on whether the delete-via-replication happens before the local Player Controller reconstructs its components or after it. So maybe account for that in your tests.

Thanks!

I’ve spent some more time testing this today, and unfortunately I’m still not able to get the same results on my end.

Unfortunately, without a repro case or a test project that showcases this issue, I’m limited as far as what action I can take with this.

If you’re able to provide anything further or spend some time and attempt to reproduce the issue on your end in a clean project, that would be extremely helpful.

Hi Sean, I’ll try to get you something!

All right. I leveraged the ShooterGame project to make a quick repro case. I’ve added three blueprints:

BP_ReplicatedComponent is a simple actor component with replication enabled:

BP_PlayerController is a derivation of ShooterPlayerController with the above component added to it. I’ve also added EventTick handler that simply displays the validity of the component each frame (the for loop there is just to push the output down a few lines so it doesn’t overlap the game output making it unreadable):

The last blueprint BP_GameMode is derived from ShooterGame_FreeForAll. It just has its PlayerController class changed to BP_PlayerController:

After launching the game with the new game mode the issue immediately shows itself up. Watch the video and you’ll see that once the game starts the component is there but right after the map is restarted it is lost:

[Replicated component in a PlayerController gets messed up after seamless travel - YouTube][5]

I’ve attached the modified files (link text). I can also zip and upload the entire project if that helps. Let me know.

Thank you for providing the repro information.

How are you running the game? Are you packaging it and running two separate instances on different PCs?

Also, when you say “right after the map is restarted it is lost”, are you restarting the map using a specific method or are you just waiting for the match to end?

If you’d prefer to just provide your specific project, feel free to do so.

You’re welcome.

For that repro I was running a Development_Editor build from the command line without packaging on the same PC but originally I caught that bug first when I was running a packaged game over the internet on different PCs.

Haven’t used any specific method to restart the map - just waited for the match to end.

What’s the best way to share a 1GB file with you? I can upload it to Dropbox or Google Drive. Let me know.

Dropbox is best for sharing a large file like that. Thanks

Uploaded the full project to Dropbox:

https://www.dropbox.com/s/n7pbkkzszr0jtyc/replication-bug-repro-full-project.zip?dl=0

So, oddly enough, even with your test project I’m still seeing the replicated actor component return true after the server is restarted. Are there any specific steps I need to follow other than running the server from a packaged game, having someone join on another pc, and waiting for the map to reset?

Nope. It’s just starting the server then the client and joining the active session. But since the bug is a race condition of sort it might not pop its head up if you’re lucky enough, i.e. if the local player controller manages to create the component after it’s been deleted via replication. In my tests though that somehow wasn’t the case unless I delayed the execution of the client with a quick breakpoint/resume.

Have you tried adding a delay before you attempt to print the name of the actor component? It’s possible that adding a short delay would help, as I’m thinking this could be a simple order of operations issue.

Let me know if that makes a difference in your project. I’ll continue testing in the meantime to see if I’m able to get it to happen in the test project you sent me.

Thanks

As you could see by looking at the screenshots I posted earlier and the test project I’ve uploaded the message is printed every tick. Obviously a delay won’t make any difference.

Yeah I actually just noticed that, my mistake. I ran into a similar issue in another project of mine earlier, but the call was on BeginPlay, obviously, in that case. Thanks for the clarification.

I’m working on testing this issue now and I’ll get back to you soon with my results.

Hey bstone,

After further testing, I’ve been unable to reproduce the issue in a clean project, as well as with the project that you’ve provided. I’ve had some of my colleagues test this as well, and they have also not seen the same results that you’re seeing, unfortunately.

At this time, without a solid repro, we are limited as far as what further action we can take with this issue. If you are able to recreate the issue in a clean project, provide a solid repro, or identify what is causing the issue in the test project you sent me so that I can reproduce it, feel free to leave a comment to reopen the thread, and I’ll be glad to continue investigating.

Let me know if you have any further questions or come across any new information regarding this.

Thanks