com.unity.netcode.gameobjects icon indicating copy to clipboard operation
com.unity.netcode.gameobjects copied to clipboard

Several Client connections at the same time wont perform certain Code.

Open itismarcii opened this issue 3 years ago • 3 comments

Description

If you spawn several Clients at the same time, it seems like neither the Client nor the Server perform certain code. If you spawn 100 clients at the same time, around half of them perform properly and the other half dont.

And what I mean by that, the Server wont perform all OnClientCallback's and the Clients dont perform OnNetworkSpawn. It also seems like that the Clients dont know that they themselves are LocalPlayers.

it also appears that on a higher tickrate the problem is not that severe, to a certain extend of tickrate tuning.

Reproduce Steps

  1. Setup a projekt, server starts in its own scene and the client does that too. They both join into a "worldscene" (most likely optional).
  2. Setup a Character Prefab that will be spawned as child of the Client on the Server due the OnClientCallback Method.
  3. Spawn Server on devel Server.
  4. Spawn Client in Editor -> Everything works fine and we can see in the Hierarchy all the incoming Clients.
  5. Spawn 100 Clients via bash script.

Actual Outcome

The first amount of Clients will spawn correctly with their Character attached. Around 40+ the Clients wont spawn with their Characters anymore Around 80+ a few Clients will spawn with their Characters again. The last few amount will again spawn without their Character.

Expected Outcome

All Clients should spawn with their Character.

Screenshots

image

Environment

  • OS: Server Unix - Clients Windows
  • Unity Version: 2021.2.18f1
  • Netcode Version: [e.g. 1.0.0-pre.9]

Additional Context

Server log:

output.txt

Random Client log:

output 66 .txt

itismarcii avatar Jun 14 '22 09:06 itismarcii

Hello itismarcii! With 100 clients it could be that you are exceeding a transport buffer threshold. What transport are you using (UNet or UnityTransport) and what are their buffer and/or queue sizes?

NoelStephensUnity avatar Jun 24 '22 20:06 NoelStephensUnity

Hello NoelStephensUnity, We are using the Unity Transport.

We also varied with the values.

Tickrate: 8

Test1: Default Max Packet Queue Size:128, Max Payload Size: 6144 Max Send Queue Size: 98304

Test 2: Default times 4 Max Packet Queue Size: 512 Max Payload Size: 24576 Max Send Queue Size: 393216

Test 3: Default times 36 Max Packet Queue Size: 4608 Max Payload Size: 147456 Max Send Queue Size: 2359296

Always the same issue.

The test environments just used two different prefabs. A Client and a Character that will spawn as an child of the Client.

private void Awake()
{
    NetworkManager.Singleton.OnClientConnectedCallback += SpawnCharacter;
}

private void SpawnCharacter(ulong clientID)
{
    if(!NetworkManager.Singleton.IsServer) return;

    var networkObjectClient = NetworkManager.Singleton.SpawnManager.GetPlayerNetworkObject(clientID);
    NetworkObject character = Instantiate(Prefab);
    character.SpawnWithOwnership(clientID);
    character.TrySetParent(networkObjectClient.transform);
}

The Client holds an NetworkObject. The Character holds CharacterController, MeshFilter, MeshRenderer, NetworkObject, Material.

itismarcii avatar Jun 25 '22 11:06 itismarcii

Backlog: MTT-4263

ashwinimurt avatar Aug 01 '22 20:08 ashwinimurt

@itismarcii was my intern last year and we just reevaluated his project using the updated Netcode for GameObjects version 1.5.2 and Unity LTS version 2022.3.7.

In our load tests we used one Unity server and up to 150 headless Unity clients. Everything seems fine, even when all the clients tried to connect at the same time. We don't see any problems, at least not with such an amount of clients.

We suggest to close this issue. There seems not to be a dedicated fix to this issue but all in all the stability of Netcode for GameObjects has improved since the last year.

PyrateAkananto avatar Aug 25 '23 10:08 PyrateAkananto