Creating too many (~85 by default) NetworkObjects causes client/server synchronization to fail
See original GitHub issueDescribe 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:
- Clone https://github.com/Twin-Drums/MLAPI.Testing.Public
- 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) - Open MLAPI.Testing.Public and MLAPI.Testing.Public.Hardcopy
- Open the scene
Server
in one andClient
in the other project - Press play in the server scene, wait until it started and then press play in the client scene
- 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
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:
- Created 2 years ago
- Reactions:1
- Comments:9 (3 by maintainers)
Top GitHub Comments
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.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.