From 2c34678464212b2aa59dd29de8fb612b8079f682 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Mon, 14 Jul 2025 20:32:06 -0500 Subject: [PATCH 1/3] test - fix Applying the same fix as #3547 for develop-2.0.0 branch. --- .../PlayerSpawnObjectVisibilityTests.cs | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/NetworkObject/PlayerSpawnObjectVisibilityTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/NetworkObject/PlayerSpawnObjectVisibilityTests.cs index a29361e195..29a6efe7b2 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/NetworkObject/PlayerSpawnObjectVisibilityTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/NetworkObject/PlayerSpawnObjectVisibilityTests.cs @@ -63,6 +63,25 @@ protected override void OnCreatePlayerPrefab() base.OnCreatePlayerPrefab(); } + /// + /// Bypassing this on v1.x as the deferred show message could be processed on the next + /// frame from when the client registers having connected. + /// + protected override bool ShouldWaitForNewClientToConnect(NetworkManager networkManager) + { + return false; + } + + /// + /// Validate that the player object is spawned on the client side. + /// + /// + private bool ClientSpawnedPlayer() + { + var playerObject = m_ClientNetworkManagers[0].LocalClient.PlayerObject; + return playerObject != null && playerObject.IsSpawned && playerObject.IsOwner; + } + /// /// Tests the scenario where under a client-server network topology if a player prefab /// is spawned by the server with no observers but the player prefab itself has server @@ -81,7 +100,17 @@ public IEnumerator NetworkShowOnSpawnTest([Values] PlayerSpawnStages spawnStage) yield return CreateAndStartNewClient(); - yield return new WaitForSeconds(0.25f); + // Wait for the new client to connect + yield return WaitForClientsConnectedOrTimeOut(); + AssertOnTimeout($"Timed out waiting for client to connect!"); + OnNewClientStartedAndConnected(m_ClientNetworkManagers[0]); + + // Wait for the new client to have spawned the player + yield return WaitForConditionOrTimeOut(ClientSpawnedPlayer); + AssertOnTimeout($"Timed out waiting for client to spawn its player object!"); + + // Provide some time to assure there are no additional attempts to spawn the same instance + yield return new WaitForSeconds(0.5f); NetcodeLogAssert.LogWasNotReceived(LogType.Warning, new Regex("but it is already in the spawned list!")); var client = GetNonAuthorityNetworkManager(); From 107ca14da33839f27998dd42222e0c3b344f226f Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Mon, 14 Jul 2025 20:32:34 -0500 Subject: [PATCH 2/3] test - fix Fixing issue with StopAndStartMotionTests randomly failing. --- .../NetworkTransform/InterpolationStopAndStartMotionTest.cs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/InterpolationStopAndStartMotionTest.cs b/com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/InterpolationStopAndStartMotionTest.cs index 9984ccb8a2..d064d7b3b2 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/InterpolationStopAndStartMotionTest.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/NetworkTransform/InterpolationStopAndStartMotionTest.cs @@ -270,7 +270,8 @@ public override void OnUpdate() // Add it to the table of state updates var stateEntry = new StateEntry() { - TimeAdded = Time.realtimeSinceStartup, + // Use the server time to get the valid "relative" time since the session started. + TimeAdded = NetworkManager.ServerTime.TimeAsFloat, State = m_PosInterpolator.InterpolateState, }; From 8bbb51036b283d130df3bc49e50f3c6ce492b7c3 Mon Sep 17 00:00:00 2001 From: NoelStephensUnity Date: Tue, 15 Jul 2025 00:29:29 -0500 Subject: [PATCH 3/3] test - stability Increase the BuildTests.BasicBuildTest timeout from 3 to 15 minutes. --- com.unity.netcode.gameobjects/Tests/Editor/Build/BuildTests.cs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/com.unity.netcode.gameobjects/Tests/Editor/Build/BuildTests.cs b/com.unity.netcode.gameobjects/Tests/Editor/Build/BuildTests.cs index 563c43b166..8bf2663d66 100644 --- a/com.unity.netcode.gameobjects/Tests/Editor/Build/BuildTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Editor/Build/BuildTests.cs @@ -12,6 +12,8 @@ internal class BuildTests { public const string DefaultBuildScenePath = "Tests/Editor/Build/BuildTestScene.unity"; + // Increased the Build test timeout from 3 to 10 minutes. + [Timeout(900000)] [Test] public void BasicBuildTest() {