Skip to content

Commit 529419b

Browse files
authored
fix: Fixed an issue where BatchedSendQueue was including the HeadIndex twice when copying data, which was causing stream corruption when the data exceeded a certain throughput. [NCCBUG-187] (#2332)
fix: Fixed an issue where BatchedSendQueue was including the HeadIndex twice when copying data, which was causing stream corruption when the data exceeded a certain throughput. [NCCBUG-187] (#2332)
1 parent ade8ce5 commit 529419b

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

com.unity.netcode.gameobjects/CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ Additional documentation and release notes are available at [Multiplayer Documen
1717

1818
### Fixed
1919
- Fixed server side issue where, depending upon component ordering, some NetworkBehaviour components might not have their OnNetworkDespawn method invoked if the client side disconnected. (#2323)
20+
- Fixed a case where data corruption could occur when using UnityTransport when reaching a certain level of send throughput. (#2332)
2021

2122
- Fixed an issue in `UnityTransport` where an exception would be thrown if starting a Relay host/server on WebGL. This exception should only be thrown if using direct connections (where WebGL can't act as a host/server). (#2321)
2223

com.unity.netcode.gameobjects/Runtime/Transports/UTP/BatchedSendQueue.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ public int FillWriterWithMessages(ref DataStreamWriter writer)
226226
{
227227
writer.WriteInt(messageLength);
228228

229-
var messageOffset = HeadIndex + reader.GetBytesRead();
229+
var messageOffset = reader.GetBytesRead();
230230
WriteBytes(ref writer, (byte*)m_Data.GetUnsafePtr() + messageOffset, messageLength);
231231

232232
writerAvailable -= sizeof(int) + messageLength;

com.unity.netcode.gameobjects/Tests/Editor/Transports/BatchedSendQueueTests.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,12 @@ public void BatchedSendQueue_FillWriterWithMessages_PartialPushedMessages()
229229
var writer = new DataStreamWriter(data);
230230
Assert.AreEqual(messageLength, q.FillWriterWithMessages(ref writer));
231231
AssertIsTestMessage(data);
232+
233+
q.Consume(messageLength);
234+
235+
writer = new DataStreamWriter(data);
236+
Assert.AreEqual(messageLength, q.FillWriterWithMessages(ref writer));
237+
AssertIsTestMessage(data);
232238
}
233239

234240
[Test]

0 commit comments

Comments
 (0)