Skip to content

Network RTT calculation significantly inaccurate after ServerChangeScene #3576

@Mr-Oregano

Description

@Mr-Oregano

Describe the bug
The Network RTT calculation becomes highly inaccurate after an online scene is loaded with ServerChangeScene. This is due to all messages being blocked by server and client whenever a scene is being loaded. If the scene takes a long time to load, EMA for NetworkTime.cs will be thrown off.

How can we reproduce the issue, step by step:

  • Using "Room" example...
  • In OfflineScene, add NetworkPingDisplay component to the NetworkRoomManager game object.
    -> Since the example room scene is simple, it loads really fast, so we need to artificially create a loading delay.
  • In NetworkRoomManagerExt.OnGUI() I added...
...

ServerChangeScene(GameplayScene);

// ↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓
static async void foo()
{
    loadingSceneAsync.allowSceneActivation = false;
    await System.Threading.Tasks.Task.Delay(5000);
    loadingSceneAsync.allowSceneActivation = true;
};

foo();
// ↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑↑
  • Open project on new instance of Unity editor (could use ParrelSync)
  • Run game on both Unity editors (start host on one, start client on the other)
  • Ready players on both clients, and start game on host client
  • Scene should take 5 seconds to load after which you should see the RTT on the client rise significantly (usually in the 1000s)

Expected behavior
Ideally, NetworkPingMessage should still go through while loading a scene so that server/client RTT calculation always stays as accurate as possible.

Screenshots
image

Desktop:

  • OS: Windows
  • Build target: Android, Windows
  • Unity version: v2021.3.8f1
  • Mirror branch: master

Additional context
After a while, the RTT will settle back down to a more accurate number, usually this takes a few seconds to happen.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions