Skip to content

Commit c737a43

Browse files
fix: stale connection config hash and a batched entry skipped by a deregister
Both raised by the automated review on PR #4123. GetConfig caches, and ClearConfigHash only ran on shutdown, so a GetConfig call made before the session started cached a hash built from the default ActiveTransformSyncMode. Initialize then captured the authored mode and the server compared connecting clients against the stale hash, rejecting them for a configuration mismatch. Clear the cache where the mode is captured. RunDeltaCheck iterates by index so an instance that despawns from within its own state update callback cannot invalidate the iteration, but Deregister swaps the last registered instance into the vacated slot and the increment then stepped straight over it. Its entry was already complete, so it was a tick of delay for no reason.
1 parent dfa358c commit c737a43

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

com.unity.netcode.gameobjects/Runtime/Components/NetworkTransformStateManager.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -613,12 +613,16 @@ internal void RunDeltaCheck()
613613
var instance = m_Instances[i];
614614
var entry = Entries[i];
615615
instance.ApplyBatchedDeltaEntry(ref entry);
616-
// The instance may have deregistered while applying, in which case this slot now belongs to a
617-
// different instance and must not be written back.
618616
if (instance.StateManagerIndex == i)
619617
{
620618
Entries[i] = entry;
619+
continue;
621620
}
621+
622+
// The instance deregistered while applying, which swapped the last registered instance and
623+
// its already completed entry into this slot. Hold the index so that instance is applied on
624+
// the tick it was detected on as opposed to being skipped by the increment.
625+
i--;
622626
}
623627
}
624628

com.unity.netcode.gameobjects/Runtime/Core/NetworkManager.cs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,6 +1258,10 @@ internal void Initialize(bool server)
12581258
// session UI without a mid-session write splitting a running session across both modes.
12591259
NetworkConfig.ActiveTransformSyncMode = NetworkConfig.TransformSyncMode;
12601260

1261+
// The captured mode is part of the connection configuration hash, so drop anything GetConfig
1262+
// cached before the session started or the server compares connecting clients against it.
1263+
NetworkConfig.ClearConfigHash();
1264+
12611265
// Always create a default session config when starting a NetworkManager instance
12621266
if (DistributedAuthorityMode)
12631267
{

0 commit comments

Comments
 (0)