Skip to content

Regression in 2.9.2 (PR #3878): NetworkList<T>.Add() during server-side OnNetworkSpawn delivers duplicate entry to joining client #3999

@SquidyLLC

Description

@SquidyLLC

Bug

When a NetworkList<T>.Add() is performed on the server during a newly-spawned NetworkObject's OnNetworkSpawn, the joining client receives the new entry twice — once via the spawn snapshot (WriteFieldSynchronization) and again as a queued delta (WriteDeltaEventType.Add). Other peers see the list correctly.

Why it happens

PR #3878 deleted this override from Runtime/NetworkVariable/Collections/NetworkList.cs:

internal override void OnSpawned()
{
    if (IsDirty() && CanSend() && m_NetworkObject.IsSpawnAuthority)
    {
        UpdateLastSentTime();
        ResetDirty();
        SetDirty(false);
    }
    base.OnSpawned();
}

Its own comment said it existed "to prevent duplicate entries from being sent (i.e. CreateObjectMessage will contain the changes so we don't need to send a proceeding NetworkVariableDeltaMessage)."

PR #3878 moved this logic into NetworkVariableBase.InternalOnSpawned() intending to make it universal, but the new predicate adds a CanWrite() check that wasn't in the original, and that check is what's now excluding server-write NetworkList in the spawn-time path.

Fix

Restore NetworkList<T>.OnSpawned(), or change the predicate in NetworkVariableBase.InternalOnSpawned() to match the deleted version (IsDirty() && CanSend() && IsSpawnAuthority).

Versions tested

  • 2.9.1 Works Properly
  • 2.9.2 and 2.11.2 Broken. Same Issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    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