Skip to content

Commit 7dd6c41

Browse files
Merge branch 'develop' into vetting-test-develop
2 parents c35f8c1 + 33bb5c1 commit 7dd6c41

File tree

13 files changed

+763
-139
lines changed

13 files changed

+763
-139
lines changed

.yamato/wrench/recipe-regeneration.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,14 @@ test_-_wrench_jobs_up_to_date:
99
type: Unity::VM
1010
flavor: b1.large
1111
commands:
12-
- command: dotnet run --project Tools\CI\NGO.Cookbook.csproj
12+
- command: dotnet run --project Tools/CI/NGO.Cookbook.csproj
1313
- command: |-
1414
if [ -n "$(git status --porcelain -- .yamato/wrench)" ]; then
1515
git status
1616
echo "Your repo is not clean - diff output:"
1717
git diff
1818
echo "You must run recipe generation after updating recipes to update the generated YAML!"
19-
echo "Run 'dotnet run --project Tools\CI\NGO.Cookbook.csproj' from the root of your repository to regenerate all job definitions created by wrench."
19+
echo "Run 'dotnet run --project Tools/CI/NGO.Cookbook.csproj' from the root of your repository to regenerate all job definitions created by wrench."
2020
exit 1
2121
fi
2222
variables:

.yamato/wrench/validation-jobs.yml

Lines changed: 36 additions & 36 deletions
Large diffs are not rendered by default.

.yamato/wrench/wrench_config.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,5 @@
3333
"branch_pattern": "ReleaseSlash",
3434
"wrench_version": "0.12.2.0",
3535
"pvp_exemption_path": ".yamato/wrench/pvp-exemptions.json",
36-
"cs_project_path": "Tools\\CI\\NGO.Cookbook.csproj"
36+
"cs_project_path": "Tools/CI/NGO.Cookbook.csproj"
3737
}

Tools/CI/Settings/NGOSettings.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ public class NGOSettings : AnnotatedSettingsBase
1212
static ValidationOptions validationOptions = new ValidationOptions()
1313
{
1414
ProjectPath = "testproject",
15-
UtrTestingYamatoTimeout = 40
15+
UtrTestingYamatoTimeout = 180 // 3h This it to address the issue that we are running both package and project test and that their execution is much slower on editors below 6000
1616
};
1717

1818
// update this to list all packages in this repo that you want to release.

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,19 @@ Additional documentation and release notes are available at [Multiplayer Documen
1010

1111
### Added
1212

13+
### Added
14+
15+
### Fixed
16+
17+
- Fixed issue where NetworkConfig.ConnectionData could cause the ConnectionRequestMessage to exceed the transport's MTU size and would result in a buffer overflow error. (#3565)
18+
19+
### Changed
20+
21+
22+
## [1.14.0] - 2025-07-21
23+
24+
### Added
25+
1326
- Added serializer for `Pose` (#3540)
1427
- Added mappings between `ClientId` and `TransportId`. (#3515)
1528
- Added `SinglePlayerTransport` that provides the ability to start as a host for a single player network session. (#3475)

com.unity.netcode.gameobjects/Runtime/Connection/NetworkConnectionManager.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -626,7 +626,7 @@ private void SendConnectionRequest()
626626
}
627627
}
628628

629-
SendMessage(ref message, NetworkDelivery.ReliableSequenced, NetworkManager.ServerClientId);
629+
SendMessage(ref message, NetworkDelivery.ReliableFragmentedSequenced, NetworkManager.ServerClientId);
630630
message.MessageVersions.Dispose();
631631
}
632632

com.unity.netcode.gameobjects/Tests/Editor/Messaging/MessageCorruptionTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,8 @@ public unsafe void Send(ulong clientId, NetworkDelivery delivery, FastBufferWrit
9595
for (int i = 0; i < 4; i++)
9696
{
9797
var currentByte = batchData.GetUnsafePtr()[i];
98-
batchData.WriteByteSafe((byte)(currentByte == 0 ? 1 : 0));
98+
currentByte = (byte)((currentByte + 1) % 255);
99+
batchData.WriteByteSafe(currentByte);
99100
MessageQueue.Add(batchData.ToArray());
100101
}
101102
break;

com.unity.netcode.gameobjects/Tests/Runtime/ConnectionApproval.cs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ public ConnectionApprovalTests(PlayerCreation playerCreation)
3434

3535
protected override int NumberOfClients => 1;
3636

37-
private Guid m_ValidationToken;
37+
private string m_ValidationToken;
3838

3939
protected override bool ShouldCheckForSpawnedPlayers()
4040
{
@@ -46,8 +46,13 @@ protected override void OnServerAndClientsCreated()
4646
m_ClientDisconnectReasonValidated = false;
4747
m_BypassConnectionTimeout = m_PlayerCreation == PlayerCreation.FailValidation;
4848
m_Validated.Clear();
49-
m_ValidationToken = Guid.NewGuid();
50-
var validationToken = Encoding.UTF8.GetBytes(m_ValidationToken.ToString());
49+
m_ValidationToken = string.Empty;
50+
51+
while (m_ValidationToken.Length < 2000)
52+
{
53+
m_ValidationToken += Guid.NewGuid().ToString();
54+
}
55+
var validationToken = Encoding.UTF8.GetBytes(m_ValidationToken);
5156
m_ServerNetworkManager.ConnectionApprovalCallback = NetworkManagerObject_ConnectionApprovalCallback;
5257
m_ServerNetworkManager.NetworkConfig.PlayerPrefab = m_PlayerCreation == PlayerCreation.Prefab ? m_PlayerPrefab : null;
5358
if (m_PlayerCreation == PlayerCreation.PrefabHash)

com.unity.netcode.gameobjects/Tests/Runtime/ConnectionApprovalTimeoutTests.cs

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,20 +55,28 @@ protected override void OnServerAndClientsCreated()
5555
base.OnServerAndClientsCreated();
5656
}
5757

58+
private MessageCatcher<ConnectionRequestMessage> m_ConnectionRequestCatcher;
59+
private MessageCatcher<ConnectionApprovedMessage> m_ConnectionApprovedCatcher;
5860
protected override IEnumerator OnStartedServerAndClients()
5961
{
62+
m_ClientStopped = false;
63+
m_ServerStopped = false;
64+
m_ClientNetworkManagers[0].OnClientStopped += OnClientStopped;
65+
m_ServerNetworkManager.OnServerStopped += OnServerStopped;
6066
if (m_ApprovalFailureType == ApprovalTimedOutTypes.ServerDoesNotRespond)
6167
{
6268
// We catch (don't process) the incoming approval message to simulate the server not sending the approved message in time
63-
m_ClientNetworkManagers[0].ConnectionManager.MessageManager.Hook(new MessageCatcher<ConnectionApprovedMessage>(m_ClientNetworkManagers[0]));
69+
m_ConnectionApprovedCatcher = new MessageCatcher<ConnectionApprovedMessage>(m_ClientNetworkManagers[0], m_EnableVerboseDebug);
70+
m_ClientNetworkManagers[0].ConnectionManager.MessageManager.Hook(m_ConnectionApprovedCatcher);
6471
m_ExpectedLogMessage = new Regex("Timed out waiting for the server to approve the connection request.");
6572
m_LogType = LogType.Log;
6673
}
6774
else
6875
{
6976
// We catch (don't process) the incoming connection request message to simulate a transport connection but the client never
7077
// sends (or takes too long to send) the connection request.
71-
m_ServerNetworkManager.ConnectionManager.MessageManager.Hook(new MessageCatcher<ConnectionRequestMessage>(m_ServerNetworkManager));
78+
m_ConnectionRequestCatcher = new MessageCatcher<ConnectionRequestMessage>(m_ServerNetworkManager, m_EnableVerboseDebug);
79+
m_ServerNetworkManager.ConnectionManager.MessageManager.Hook(m_ConnectionRequestCatcher);
7280

7381
// For this test, we know the timed out client will be Client-1
7482
m_ExpectedLogMessage = new Regex("Server detected a transport connection from Client-1, but timed out waiting for the connection request message.");
@@ -98,6 +106,43 @@ public IEnumerator ValidateApprovalTimeout()
98106

99107
Assert.AreEqual(0, m_ServerNetworkManager.ConnectionManager.PendingClients.Count, $"Expected no pending clients when there were {m_ServerNetworkManager.ConnectionManager.PendingClients.Count} pending clients!");
100108
Assert.True(!m_ClientNetworkManagers[0].LocalClient.IsApproved, $"Expected the client to not have been approved, but it was!");
109+
110+
if (m_ApprovalFailureType == ApprovalTimedOutTypes.ServerDoesNotRespond)
111+
{
112+
m_ConnectionApprovedCatcher.ClearMessages();
113+
}
114+
else
115+
{
116+
m_ConnectionRequestCatcher.ClearMessages();
117+
}
118+
119+
if (!m_ClientStopped)
120+
{
121+
m_ClientNetworkManagers[0].Shutdown();
122+
}
123+
124+
if (!m_ServerStopped)
125+
{
126+
m_ServerNetworkManager.Shutdown();
127+
}
128+
129+
yield return WaitForConditionOrTimeOut(() => m_ClientStopped && m_ServerStopped);
130+
AssertOnTimeout($"Timed out waiting for the client or server to stop!");
131+
}
132+
133+
private bool m_ClientStopped;
134+
private void OnClientStopped(bool obj)
135+
{
136+
m_ClientNetworkManagers[0].OnClientStopped -= OnClientStopped;
137+
m_ClientStopped = true;
101138
}
139+
140+
private bool m_ServerStopped;
141+
private void OnServerStopped(bool obj)
142+
{
143+
m_ServerNetworkManager.OnServerStopped -= OnServerStopped;
144+
m_ServerStopped = true;
145+
}
146+
102147
}
103148
}

com.unity.netcode.gameobjects/Tests/Runtime/TestHelpers/MessageCatcher.cs

Lines changed: 34 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,17 @@
11
using System;
22
using System.Collections.Generic;
33
using Unity.Collections;
4+
using UnityEngine;
45

56
namespace Unity.Netcode.RuntimeTests
67
{
78
internal class MessageCatcher<TMessageType> : INetworkHooks where TMessageType : INetworkMessage
89
{
910
private NetworkManager m_OwnerNetworkManager;
1011

11-
public MessageCatcher(NetworkManager ownerNetworkManager)
12+
private bool m_VerboseDebug;
13+
14+
public MessageCatcher(NetworkManager ownerNetworkManager, bool verboseDebug = false)
1215
{
1316
m_OwnerNetworkManager = ownerNetworkManager;
1417
}
@@ -23,9 +26,38 @@ private struct TriggerData
2326
}
2427
private readonly List<TriggerData> m_CaughtMessages = new List<TriggerData>();
2528

26-
public void ReleaseMessages()
29+
30+
private void Log(string message)
2731
{
32+
if (!m_VerboseDebug)
33+
{
34+
return;
35+
}
2836

37+
Debug.Log($"[Client-{m_OwnerNetworkManager.LocalClientId}] {message}");
38+
}
39+
40+
internal void ClearMessages()
41+
{
42+
if (m_CaughtMessages.Count == 0)
43+
{
44+
return;
45+
}
46+
Log($"Clearing messages.");
47+
foreach (var caughtSpawn in m_CaughtMessages)
48+
{
49+
if (caughtSpawn.Reader.IsInitialized)
50+
{
51+
Log($"Disposing reader (size: {caughtSpawn.Reader.Length}).");
52+
caughtSpawn.Reader.Dispose();
53+
}
54+
}
55+
56+
m_CaughtMessages.Clear();
57+
}
58+
59+
public void ReleaseMessages()
60+
{
2961
foreach (var caughtSpawn in m_CaughtMessages)
3062
{
3163
// Reader will be disposed within HandleMessage

0 commit comments

Comments
 (0)