From 3495ae2a60a45e1c4b8dc4eb03f9ad956dd5d4cf Mon Sep 17 00:00:00 2001 From: Noel Stephens Date: Fri, 17 Jul 2026 09:58:45 -0500 Subject: [PATCH 1/2] fix - test This test could be hitting a timing related issue where the test exits (i.e. finishes) prior to the late joining client having sent the expected error messages. --- ...etworkPrefabHandlerSynchronizationTests.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/Prefabs/NetworkPrefabHandlerSynchronizationTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/Prefabs/NetworkPrefabHandlerSynchronizationTests.cs index 0c5895b612..806fe83a62 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/Prefabs/NetworkPrefabHandlerSynchronizationTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/Prefabs/NetworkPrefabHandlerSynchronizationTests.cs @@ -19,6 +19,28 @@ public NetworkPrefabHandlerSynchronizationTests(HostOrServer hostOrServer) : bas private GameObject m_ClientSideValidPrefab; private GameObject m_ClientSideExceptionPrefab; + public class VerifyLastClientSentRpcToServer : NetworkBehaviour + { + public bool RpcReceived { get; private set; } + + protected override void OnNetworkPreSpawn(ref NetworkManager networkManager) + { + RpcReceived = false; + base.OnNetworkPreSpawn(ref networkManager); + } + + public void DelayUntilOneMessageReceivedRpc(RpcParams rpcParams = default) + { + RpcReceived = true; + } + } + + protected override void OnCreatePlayerPrefab() + { + m_PlayerPrefab.AddComponent(); + base.OnCreatePlayerPrefab(); + } + protected override void OnServerAndClientsCreated() { m_ValidPrefab = CreateNetworkObjectPrefab("ValidPrefab"); @@ -73,6 +95,8 @@ public IEnumerator NetworkPrefabHandlerSpawnAndSynchronizeTests() // Start and synchronize the new client yield return StartClient(newClient); + AssertOnTimeout($"Timed out waiting for the late joining client, {newClient.name}, to connect!"); + // Validate the valid prefab spawned on all clients without issue var expectedAuthorityHash = m_ValidPrefab.GetComponent().GlobalObjectIdHash; @@ -92,6 +116,21 @@ public IEnumerator NetworkPrefabHandlerSpawnAndSynchronizeTests() Assert.That(networkManager.SpawnManager.SpawnedObjects.ContainsKey(exceptionObject.NetworkObjectId), Is.False, "Non authority should not have spawned exception object!"); } } + + // Assure this test continues to run until we verify the late joining client has sent 1 message to the server + // This should be the fix for MTT-15473 where the test finishes/exits before the message from the client has been received and processed by the server. + Assert.IsTrue(authority.SpawnManager.SpawnedObjects.ContainsKey(newClient.LocalClient.PlayerObject.NetworkObjectId), $"Server does not have a player for Client-{newClient.LocalClientId}!"); + + // Get server and late joining client's VerifyLastClientSentRpcToServer NetworkBehaviour + var serverLateClientInstance = authority.SpawnManager.SpawnedObjects[newClient.LocalClient.PlayerObject.NetworkObjectId].GetComponent(); + var sendRpc = newClient.LocalClient.PlayerObject.GetComponent(); + + // Send a message from the late joining client to the server + sendRpc.DelayUntilOneMessageReceivedRpc(); + + // Wait for the server to have received this message before exiting the test. + // If the log message has not been received by the server at this point, then there is some other type of bug specific to iOS and Mac. + yield return WaitForConditionOrTimeOut(() => serverLateClientInstance.RpcReceived); } } } From bedf3f59171e6380e145a2362fbd14e6bfb8ef81 Mon Sep 17 00:00:00 2001 From: Noel Stephens Date: Fri, 17 Jul 2026 10:03:36 -0500 Subject: [PATCH 2/2] update Removing the excluded platforms for testing purposes. --- .../Runtime/Prefabs/NetworkPrefabHandlerSynchronizationTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/com.unity.netcode.gameobjects/Tests/Runtime/Prefabs/NetworkPrefabHandlerSynchronizationTests.cs b/com.unity.netcode.gameobjects/Tests/Runtime/Prefabs/NetworkPrefabHandlerSynchronizationTests.cs index 806fe83a62..bf341a45fb 100644 --- a/com.unity.netcode.gameobjects/Tests/Runtime/Prefabs/NetworkPrefabHandlerSynchronizationTests.cs +++ b/com.unity.netcode.gameobjects/Tests/Runtime/Prefabs/NetworkPrefabHandlerSynchronizationTests.cs @@ -50,7 +50,7 @@ protected override void OnServerAndClientsCreated() } [UnityTest] - [UnityPlatform(exclude = new[] { RuntimePlatform.IPhonePlayer, RuntimePlatform.OSXPlayer, RuntimePlatform.OSXEditor })] // Ignored test tracked in MTT-15473 + //[UnityPlatform(exclude = new[] { RuntimePlatform.IPhonePlayer, RuntimePlatform.OSXPlayer, RuntimePlatform.OSXEditor })] // Ignored test tracked in MTT-15473 public IEnumerator NetworkPrefabHandlerSpawnAndSynchronizeTests() { var nonAuthority = GetNonAuthorityNetworkManager();