question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Creating too many (~85 by default) NetworkObjects causes client/server synchronization to fail

See original GitHub issue

Describe the bug Creating too many NetworkObject (meaning the sum of bytes for all objects exceeds the UNet Message Buffer Size) causes to fail synchronization between server/client.

To Reproduce Steps to reproduce the behavior:

  1. Clone https://github.com/Twin-Drums/MLAPI.Testing.Public
  2. Switch to the branch message-limit-report (the branch contains a clean new Netcode 1.0.0 project - and is not upgraded from a MLAPI project)
  3. Open MLAPI.Testing.Public and MLAPI.Testing.Public.Hardcopy
  4. Open the scene Server in one and Client in the other project
  5. Press play in the server scene, wait until it started and then press play in the client scene
  6. Check the client console for a KeyNotFoundException: The given key was not present in the dictionary. error

Actual outcome Client throws a KeyNotFoundException: The given key was not present in the dictionary. error (see screenshot below). TestNetworkObjectServer(Clone) objects that are instantiated on the server are NOT spawned on the client.

Expected outcome No error message and client should spawn TestNetworkObjectClient(Clone) object.

Screenshots grafik grafik

Environment:

  • OS: Windows 10
  • Unity Version: 2020.3.22f1
  • Netcode Version: 1.0.0-pre.3

Additional context Reducing the the amount from 85 to 80 (in the Spawner in the server scene) makes everything work as expected. Also increasing the Message Buffer Size in the UNet Transport components allows higher amounts (but with the absolute limit here being 65535 the overall NetworkObject maximum is around ~1k)

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
JackChercommented, Dec 30, 2021

Same problem. In my case I suspect it is caused by sending large amount of data in RPC during OnNetworkSpawn. Increasing UNetTransport message buffer size from default 5120 to bigger one fixes the issue.

I also tried it in UnityTransport, and have similar issue (but with no exception on the client side). In the case of UnityTransport the issue is resolved by increasing SendQueueBatchSize to a bigger one.

1reaction
vikpekcommented, Nov 25, 2021

The issue does NOT appear while using the Unity Transport layer.

I added an additional branch called: message-limit-report-unitytransport that has the exact same setup just with Unity Transport.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parenting a host NetworkObject causing soft ...
In this case, it causes anything that gets spawned using OnNetworkSpawn() on the host/server to be mistaken for an 'In-Scene placed  ...
Read more >
Object Spawning
Spawning in Netcode for GameObjects (Netcode) means to instantiate and/or spawn the object that is synchronized between all clients by the ...
Read more >
In-Scene (Placed) NetworkObjects
There are many uses for in-scene placed NetworkObjects , which ... spawned will cause soft synchronization errors with late joining clients.
Read more >
Network Director User Guide
Synchronized the time on the DLE server, Network Director server, and the devices using a ... A single event can often generate multiple...
Read more >
Time synchronization may not succeed - Windows Server
Follow these steps: Select Start, search for cmd, right-click Command Prompt, and then select Run as administrator.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found