Skip to content

Stale NetworkList event sent to client when its containing object is re-shown. #2306

@ezoray

Description

@ezoray

Description

I have a network object observed by a client containing a network list of structs. On direction by the client a timer is started on the server to remove the entries from the list from the bottom at half a second intervals. At any point the client can choose to deselect the object and the server hides the object from the client and continues to remove entries from the list until all are removed, all is good at this point.

The problem is, the next time the object is shown to the client a pending network list event message is also sent to the client to remove an entry from the network list and because the list is empty an exception is thrown.

Reproduce Steps

  1. Spawn object on client and populate network list
  2. Start timer to remove list entries one at a time
  3. Server hides object from client
  4. All entries in list removed, timer stops
  5. Server shows object to client
  6. NetworkList exception message logged on client

Actual Outcome

"Exception: Shouldn't be here, index is higher than list length"

Expected Outcome

No network list event message is sent to client.

Environment

  • OS: macOS Big Sur
  • Unity Version: [e.g. 2020.3]
  • Netcode Version: 1.1.0

Additional Context

This happens consistently in my main project, I wasn't able to reproduce it in a test project but it was only a simple test.

Both list.RemoveAt and list.Remove are producing the same error:

Exception: Shouldn't be here, index is higher than list length Unity.Netcode.NetworkList1[T].ReadDelta (Unity.Netcode.FastBufferReader reader, System.Boolean keepDirtyDelta) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/NetworkVariable/Collections/NetworkList.cs:365) Unity.Netcode.NetworkVariableDeltaMessage.Handle (Unity.Netcode.NetworkContext& context) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/Messages/NetworkVariableDeltaMessage.cs:200) Unity.Netcode.MessagingSystem.ReceiveMessage[T] (Unity.Netcode.FastBufferReader reader, Unity.Netcode.NetworkContext& context, Unity.Netcode.MessagingSystem system) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:457) Unity.Netcode.MessagingSystem.HandleMessage (Unity.Netcode.MessageHeader& header, Unity.Netcode.FastBufferReader reader, System.UInt64 senderId, System.Single timestamp, System.Int32 serializedHeaderSize) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:387) UnityEngine.Debug:LogException(Exception) Unity.Netcode.MessagingSystem:HandleMessage(MessageHeader&, FastBufferReader, UInt64, Single, Int32) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:391) Unity.Netcode.MessagingSystem:ProcessIncomingMessageQueue() (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Messaging/MessagingSystem.cs:407) Unity.Netcode.NetworkManager:OnNetworkEarlyUpdate() (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkManager.cs:1581) Unity.Netcode.NetworkManager:NetworkUpdate(NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkManager.cs:1513) Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage(NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkUpdateLoop.cs:185) Unity.Netcode.<>c:<CreateLoopSystem>b__0_0() (at Library/PackageCache/com.unity.netcode.gameobjects@1.1.0/Runtime/Core/NetworkUpdateLoop.cs:208)

Metadata

Metadata

Assignees

Labels

priority:mediumThis issue has medium priority and may take some time to be resolvedstat:importedStatus - Issue is tracked internally at Unitytype:bugBug Report

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions