Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inexplicably low redraw rate on multiplayer server #8219

FLHerne opened this issue Jun 12, 2020 · 7 comments

Inexplicably low redraw rate on multiplayer server #8219

FLHerne opened this issue Jun 12, 2020 · 7 comments
needs triage This issue needs further investigation before it becomes actionable


Copy link

FLHerne commented Jun 12, 2020

Version of OpenTTD


Expected result

When looking at an empty section of grass in a relatively empty server, the game renders at the normal rate.

Actual result

The drawing and video output rates are about 1.7fps, with frequent multi-second hangs, making the game unplayable.

Note that the actual times, in ms, look fine AIUI.

Output of fps:

Based on num data points: 64 128 512
Game loop rate: 36.27fps (expected: 33.33fps)
Drawing rate: 1.76fps (expected: 33.33fps)
Video output rate: 1.73fps (expected: 60.00fps)
Game loop times: 28.41ms 28.53ms 29.01ms
 GL station ticks times: 0.22ms 0.22ms 0.25ms
 GL train ticks times: 18.16ms 18.16ms 18.47ms
 GL road vehicle ticks times: 0.41ms 0.41ms 0.42ms
 GL ship ticks times: 0.01ms 0.01ms 0.00ms
 GL aircraft ticks times: 0.00ms 0.00ms 0.00ms
 GL landscape ticks times: 7.57ms 7.69ms 7.72ms
 GL link graph delays times: 0.02ms 0.02ms 0.02ms
Drawing times: 2.42ms 3.07ms 2.42ms
 Viewport drawing times: 1.02ms 1.51ms 0.88ms
Video output times: 4.52ms 3.42ms 1.12ms
Sound mixing times: 0.01ms 0.01ms 0.01ms

Steps to reproduce

  • Join Reddit S2 from my laptop (Arch Linux, Mesa r600g video drivers, dwm). Other computers may suffice, but presumably not all of them...
  • About half the time, the game will hang for a bit, then exit to main menu with "A protocol error was detected and the connection was closed".
  • Otherwise, the symptoms above will be presented.

This does not occur with local games (there's lag with a ton of vehicles etc., but that's normal).

EDIT: This also occurred with 1.10.1. It didn't with 1.9.x.

Copy link

erenes commented Jun 12, 2020

On windows I don't have any problem at all on Reddit server 2

I wonder if it's network-related?

Copy link

giordy commented Jun 29, 2020

In a game I was playing with some friends of mine I was experiencing the same issues.
The problem turned out to be the server not having enough memory available for the game. It was swapping and killing the performances.
It might be a similar problem in your case, perhaps.

Copy link

ldpl commented Jul 2, 2020

Server performance defining simulation speed is nothing new and totally expected but I doubt that's the case for Reddit servers. Also it seems that for some reason server is affecting rendering performance of clients in some cases which shouldn't really happen:

@TrueBrain TrueBrain added the needs triage This issue needs further investigation before it becomes actionable label Jan 1, 2021
Copy link

When a network game is catching up with the server, it goes into a "fast" loop where drawing isn't given any time to happen. The best thing I can think off, looking at the info you give, is that this is happening:

  • The server is clearly rather busy, and a game-loop takes your machine 28ms to handle. This is really close to what it needs to keep up (30ms), so it is not unthinkable that in burst your machine doesn't have enough time to run the game-loop
  • Your client gets behind, some frames stack up to be executed
  • Your clients wants to catch-up. It does this by running all the missed frames as fast as possible, completely blocking your screen
  • You experience this as low FPS in bursts

This is far from ideal of course, but the problem is hard to solve. When the game-loop takes close to 30ms, all kind of weird stuff starts to happen on multiplayer games. I am not sure that there is a correct solution. I do how-ever want to prevent this "blocking" of the interface a bit more, and maybe show a message, how-ever short, that this happened. I dunno yet ..

But, more importantly, do you recognize this scenario? Could this be your case, you think? Or am I wildly off?

Copy link
Contributor Author

FLHerne commented Feb 25, 2021

Closed based on IRC discussion.

When the client can't maintain normal speed in a single-player game, the game-loop and drawing simply run a bit slower; the UI may become slightly less responsive but there's no step-change in responsiveness and the FPS is generally consistent even if low.

In multiplayer, the game-loop can't be allowed to drop behind the server else the client would desync. As @TrueBrain described, the client catches up by skipping drawing on some ticks and running only the simulation:

This causes irregular groups of dropped frames rather than the smooth performance degradation seen in single-player. In the worst case the client can barely keep up with only the simulation without being desynced, so drawing may happen very intermittently or even not at all for some periods. That appears to be the case here.

Usability could be improved by showing a notice when drawing is skipped, or even by disconnecting from the server if drawing has to be skipped for many frames in some time period. The game probably can't be made playable in this case.

@FLHerne FLHerne closed this as completed Feb 25, 2021
Copy link

nielsmh commented Feb 25, 2021

In other words: Your computer is too slow to play a game of that size in multiplayer.

Copy link
Contributor Author

FLHerne commented Feb 25, 2021

That's the very short explanation, yes.

I filed a bug because the effects of being "too slow" in multiplayer are completely different and much more user-hostile than in single-player [for the reasons above], and that was unexpected to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
needs triage This issue needs further investigation before it becomes actionable
None yet

No branches or pull requests

6 participants