Search Issue Tracker

Fixed

Fixed in 1.0.0-pre.6

Votes

0

Found in [Package]

1.0.0-pre.5

Issue ID

NCCBUG-127

Regression

No

KeyNotFoundException is thrown when spawning multiple NetworkObjects

Package: Multiplayer Netcode for GameObjects

-

Reproduction steps:
1. Open the attached project "Case_1391002.zip"
2. Build and Run the Scene "Root"
3. In the Editor enter Play Mode for the Scene "Root" and click "Start Host"
4. In the Build Select "Start Client"
5. Observe the Player.log file and the Build window

Expected result: The build is populated with Objects and no errors are seen in the Player.log
Actual result: The Build is not populated and Player.log contains a KeyNotFoundException

Reproducible with: 1.0.0-pre.5 (2020.3.30f1, 2021.2.13f1, 2022.1.0b9, 2022.2.0a4)
Could not test with: 2022.2.0a5 (NetCode for GameObjects throws errors that prevent testing)

Notes:
- The amount of NetworkObjects that can be successfully spawned appears to vary between Package versions. If the issue does not reproduce, the number can be increased by changing the value of "Number Of Objects" in the "Object Spawner" component of the "DynamicObjects" Object in the Scene

- Full exception thrown in Player.log:
"KeyNotFoundException: The given key '38481' was not present in the dictionary.
at System.Collections.Generic.Dictionary`2\[TKey,TValue].get_Item (TKey key) \[0x0001e] in <6a4317c213884cea92dfdd5420f952f9>:0
at Unity.Netcode.NetworkManager.TransportIdToClientId (System.UInt64 transportId) \[0x00009] in <bff74651821a4ba6a1e50254a3b6f581>:0
at Unity.Netcode.NetworkManager.HandleRawTransportPoll (Unity.Netcode.NetworkEvent networkEvent, System.UInt64 clientId, System.ArraySegment`1\[T] payload, System.Single receiveTime) \[0x000e7] in <bff74651821a4ba6a1e50254a3b6f581>:0
at Unity.Netcode.NetworkManager.OnNetworkEarlyUpdate () \[0x00020] in <bff74651821a4ba6a1e50254a3b6f581>:0
at Unity.Netcode.NetworkManager.NetworkUpdate (Unity.Netcode.NetworkUpdateStage updateStage) \[0x0000d] in <bff74651821a4ba6a1e50254a3b6f581>:0
at Unity.Netcode.NetworkUpdateLoop.RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage updateStage) \[0x00021] in <bff74651821a4ba6a1e50254a3b6f581>:0
at Unity.Netcode.NetworkUpdateLoop+NetworkEarlyUpdate+<>c.<CreateLoopSystem>b__0_0 () \[0x00000] in <bff74651821a4ba6a1e50254a3b6f581>:0"

- The exception is followed by multiple messages in Player.log:
"\[Netcode] Deferred messages were received for NetworkObject #1, but it did not spawn within 1 second."

Add comment

Log in to post comment

All about bugs

View bugs we have successfully reproduced, and vote for the bugs you want to see fixed most urgently.