Download

Multiplayer bugs becoming more prevalent - Harden & Improve Network / Multiplayer Support!

If folks have questions or comments, can they please put them in the thread and not PM them to me! Thanks :slight_smile:

Although for most people moving to 4.10 was relatively simple in comparison to other releases, for me personally it’s been a bit of a nightmare. I’m currently working on two Multiplayer titles that although ambitious aren’t doing anything outside the realms of a normal competitive multiplayer game. However, a lot of the time I find myself fighting issues purely because engine code hasn’t been fully tested in a Multiplayer environment, and having to come up with some pretty significant workarounds. One such example that has since been fixed was that you couldn’t change the pawn you possessed in Multiplayer - something that is pretty commonplace in a lot of MP games.

So really I’m just creating this thread to try and draw attention to some of the biggest issues I’ve been experiencing with Netcode both in 4.10 and below, in the hope that Multiplayers get’s the attention it deserves. I’ve linked a couple of the most major ones below but rather than just repeat myself, I really want to raise the issue for the need for a netcode hardening pass of some kind. As an example, here’s a couple of issues I’m hitting since 4.10:

Widgets Disappearing For Clients in Multiplayer
This is probably the most frustrating of the bunch and definitely surfaced in 4.10. Whenever a client changes the Pawn they possess in a Multiplayer game, any sort of persistent User Widget stops ticking and therefore drawing too. I am yet to figure out why this is, but brought it to Nicks attention on Slack who indicated it may be related to Widgets being “torn down and rebuilt” when a player changes a pawn. I imagine there’s a reason for this, but whatever it is, it doesn’t work at all in Multiplayer. My game has vehicles (pawns) that players can hop in and out of (via possession). All you need to do is add a widget to the screen via a HUD class and test it in MP, and they’ll stop working the minute I try to posses another object.

The workaround for this is god-awful. You have to force-tick the widget by calling it’s Tick function from another class, which completely voids the point of widgets not ticking when they’re not supposed to be rendered. Once the widget starts drawing again, it’s also ticking itself natively - so most of the time it’s double-ticking. Needless to say, this is less than desirable.

I’m trying to build a repro project for it, but it’s going to take a bit of setup because it’s Multiplayer. Nevertheless, answerhub post here: UMG Widgets stop ticking and/or drawing for Clients in Multiplayer - UE4 AnswerHub

Uint8 doesn’t trigger OnRep_ functions if value is Zero
This possibly occurs to multiple engine types and maybe even pre 4.10 - but I’ve been using uint8’s for serialization / quantization of values for replication but found that if the value is zero, they won’t trigger the Replicated Functions for clients. This doesn’t just affect me though, since a lot of engine types do this natively (such as FRotators for example in FRepMovement) and therefore there will be some bugs in engine code. Again, to most people they won’t be noticeable and there are workarounds, but this had me stumped literally for days and I feel like it’s an oversight in the Engine netcode.

Answerhub Post here: https://answers.unrealengine.com/questions/337033/uint8-doesnt-replicate-trigger-onrep-function-if-z.html

It’s also worth mentioning this; There were a fair few changes to Replication in 4.10 and yet not a single one of them was documented. For someone working on two multiplayer-focused titles this has proven to been an absolute nightmare. New options for FRepMovement for example weren’t documented in the release notes despite being a pretty significant (and useful!) change. The only way to get around this was to compare relevant files on GitHub from version to version, which isn’t foolproof - or hope you run into them at some point anyway.

I realize most people aren’t doing Multiplayer and for the majority of projects these kinds of bugs won’t surface because I can’t imagine most people don’t have to be so conscious of bandwidth as I do - but it’s already taken a significant number of releases to fix some age-old netcode bugs (such as pawn possession for example), and it would be a shame if the netcode didn’t receive the same treatment as other areas of the engine. I personally would like to see some updates that really focuses on Multiplayer in the upcoming months. AFAIK, there’s nothing planned on the trello. Most importantly - I’d appreciate it if changes that may affect multiplayer are tested in that environment as well as non-multiplayer ones. MP is after all a first-class feature of the engine.

Many improvements to the engine could be made, a huge stack of changes and optimizations that Pete has made for Unreal Tournament being brought into the engine would be fantastic for example. ShooterGame and VehicleGame are fantastic resources that I can imagine took a lot of time and effort to put together. However, both are VERY old now (must be 2-3 years or more?) and neither scales very well past more than a handful of players. So on top of the engine improvements, a newer up-to-date MP example would also be a welcome gesture :slight_smile:

@Community - feel free to post any weirdness you are experiencing in MP, and of course share thoughts on a MP hardening pass on the engine.

List of Features / Fixes / Improvements requested thus far.

Thanks for posting this.

MP seems to be something of a red-headed stepchild in UE4. I, too, would love to see more effort put into multiplayer.

+1

I laughed :stuck_out_tongue:

Agreed!

My chat system disconnected the sending client when the message length >= 1024 characters (Fixed by implementing character limit): Client disconnects once replicated string reaches 1024 characters - UE4 AnswerHub

DateTime variables are not replicated at all :rolleyes:

I believe I’ve experienced that as well, couldn’t get my day night cycle to work, had to make my own date time struct.

I’m fairly certain that’s intentional, since the properties in that struct are not UPROPERTY’s and therefore not considered for Replication. By design you probably don’t want to replicate a struct like that anyway, it would be more efficient to replicate the float/int that all the components are derived from and have the client build their own Date-Time from that on the other side, otherwise you’re wasting a lot of bandwidth.

Here’s a bug with rep-notify data when trying to replicate a struct which has values inside changed separately.
https://answers.unrealengine.com/questions/303504/repnotify-shadow-data-is-stale-when-single-propert.html

Hi,

thanks for this information! Can you enumerate some of the bugs / issues that you found? I think it’s good to know for all the user that want to start MP games.

Best regards,
Daniel

Hey Daniel/Polygon

I posted the two major ones I found, but in terms of what’s changed there were a couple of things I’ve found so far. FRepMovement (Replicated Movement in BP) now has an option for what level of Quantization you want to apply to the FVectors and FRotators, and by default they have far less precision than they used to. For the most part you won’t notice this, but I started noticing really ‘steppy’ rotation on my vehicles and particularly any object simulating physics and replicating, so I had to up the precision to Shorts instead of Bytes. (uint16 instead of uint8). It’s a nice feature, but surprised nobody put it into the release notes.

Aside from that, the most major issue I’ve had so far has been with UMG widgets vanishing from screen.

There are the usual glitches with Audio in Multi-PIE too, some of which have been present since the beginning and/or pre-4.8, but I think the audio engine rewrite that’s going on right now should help with some of those.

Hey James,

thanks for the quick reply! I’ve not played around with the quantized movement replication so far but I’m a bit concerned that it might lead to a heavier stuttering behavior than before.
In 4.8 I’ve done some tests with movement replication in a top down moba style game and the old system caused a slight stuttering effect, too. So I hope that the new options don’t make this issue even worse :frowning:

Another thing that I’ve noticed in older releases was related to the ping of sessions. The “Get Ping” node returns always 9999 for me, even if the desired session that I joined ran smooth as hell - even via steam. Unfortunately I couldn’t manage to find some time to check this in 4.10 but I really hope that Epic puts some more effort in MP in general :slight_smile:

Best regards,
Daniel

Yeah there are a lot of problems with the Ping node, which is bizarre seeing as it seems to work perfectly fine in C++. What you can try to do is get the Ping from the PlayerState, as that seems to be nearly accurate most of the time.

The stuttering you’re experiencing - are you using a relatively small scale for your objects? It may be that they don’t send updates often enough even, and therefore the client receives a low percentage of packets. tbh, there’s any number of things it can be!

Guys, why replicated expose on spawn variables not set on clients while construction script? How is that even works, that the reason of construction script in this case at all.
Owner not set as well.

Thanks for those news.

I’m stuck in 4.9 for the moment, due to the SSL Perforce issue but I’m glad to learn those MP changes as it will highly impact our game. I must take care of those.

In MP chat did you succeed in getting all the characters send via Network? By example, “|” is not working and it truncated the following characters. I didn’t had time to dig as the Chat system in my game in low priority for the moment, but if some of you have face this I’m glad to know if it’s a bug to raise or not ^^

Speaking about Network MP, we also have stange log that I don’t know how to understand / Fix,
https://answers.unrealengine.com/questions/332523/how-to-fix-high-single-frame-packet-loss.html
https://answers.unrealengine.com/questions/332510/freplayout-history-overflow-forcing-history-dump-m.html

Also log on network that have been fix in 4.10:
https://answers.unrealengine.com/questions/329062/logsecuritywarning-invalid-data.html

They can’t be because it simply doesn’t work that way, the Constructor runs the instant the object is created in memory, not necessarily when it’s in the world - and it’s far too early to consider it for networking at that point. The actor has to be in-play to have a valid net connection / actor channel. Additionally, as soon as you introduce even a few microseconds of latency - you’re entire solution will break. The first thing to understand about MP programming is that it really is entirely different to programming a local-only game.

The correct way to set this up would be to create a struct of all the variables you feel you have to send immediately, and when the client eventually receives them from the server, they can run an update function which sets those vars accordingly and performs any tasks. You need to write your code in such a way that it can handle any networking situation, whether it be latency, packet loss, packet order etc. UE takes care of the latter two for you mostly. Owner also has to be set from the Server, and if the client has no knowledge about that actor yet, it can’t set that up.

EDIT: You can also use Deferred Actor Spawning in C++, which will allow you to setup properties before the actor sends it’s initial replication packet.

I’ll be sure to post here if I find any issues, I haven’t got as far as implementing a chat system yet! Are you using FString to replicate the data? FString shouldn’t suffer any truncation AFAIK, but FNames will since they are case-insensitive (but cost have the bandwidth of FString).

EDIT:
As for the History Dump overflow - I believe that’s caused when vars or RPC’s that are queued for replication start to overflow the buffer, and therefore you have the potential for clients to lose sync. i think that’s what it is anyway but I haven’t found an easy way to debug it. It would be quite nice actually, if the network profiler showed this kind of stuff as well. It’s super-rad for monitoring bandwidth but a little extra profiling wouldn’t go amiss.

MP, especially in PIE is just a pure nightmare to debug if you’re in Visual Studio. It’s actually easier in BP because you can select the debug object and the debug world (Client 1, Server etc.) Not easy to do in VS :frowning:

I dont understand the logic behind this. Server, the one who spawn actor, server know the expose on spawn variables in construction script. Then server call the client and Client the one who create replicated copy of the actor, but does not have access/ dosnt know expose on spawn data?

“Correct” way doesn’t work with projectile movement component initial speed.

This reminds me of a feature request I made: Networking pass-through nodes. - Feedback for Unreal Engine team - Unreal Engine Forums

What do you guys thing about something like that?

I commented on your link but I shall here also just incase. What you want is the Switch Has Authority node :slight_smile:

You can Spawn objects and set properties on them straight away, but they won’t be set in the construction script because the construction script runs before all of that happens. Think of the construction script as a “I want to create one of these” - that’s what it is really, almost like “here’s a template - go make one”. This is more apparent if you’re familiar with C++ or something but it is by design. Blueprint kind of hides that sort of thing away from you a bit.

IDK, I’m not very good at explaining it :stuck_out_tongue:

As always it depends on the situation but, in the case of a projectile, the initial speed is always the same right? Even if not it doesn’t matter, since if the projectile is spawned on the server and has it’s velocity set in that same frame, the client will also have that same velocity as soon as the object is created, so long as you’re replicating movement of course.

nope, init speed is different, i calculate in on spawn to hit the target here the vid
And i expose the target location on spawn, turns out i missed to turn in replicate movement, so after init spawn server would fix movement, but the idea is, i cannot use expose on spawn variables over network on client.

also if you know better way to fire projectile, tell me please