From b94663eec895e8be15a30e5d015e9877870310d6 Mon Sep 17 00:00:00 2001 From: m9co Date: Wed, 17 Feb 2021 21:30:33 +0200 Subject: [PATCH] Carrier can't send large messages with data compression enabled When sending data, that exceed maximum message size, Carrier will split in into several smaller ones. Maximum message data size is defined by variable m_maxMsgDataSizeBytes, which is calculated as following: m_maxMsgDataSizeBytes = m_maxDataGramSizeBytes - GetDataGramHeaderSize() - GetMaxMessageHeaderSize(); When data compression is enabled, in addition to datagram and message headers, carrier adds additional header with compression hint flags (added in CarrierThread::SendDatagram). Compression header is not accounted in m_maxMsgDataSizeBytes and resulting split messages won't be sent due to following code from CarrierThread::GenerateOutgoingDataGram: //If this Message can fit into the remaining Datagram buffer space if ((msg.m_dataSize + GetMessageHeaderSize(msg, isWriteMessageSequenceId, isWriteReliableMessageSequenceId, isWriteChannel)) > (maxDatagramSize - writeBuffer.Size())) { break; // we can't add this message } Moreover, these messages will remain in send queue and completely block the network. Issue happens only for messages, sent through custom network channels and not for regular game synchronization performed by replica manager. Replica manager uses channel 0, which is not included in message header, freeing up a necessary byte. --- dev/Code/Framework/GridMate/GridMate/Carrier/Carrier.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/dev/Code/Framework/GridMate/GridMate/Carrier/Carrier.cpp b/dev/Code/Framework/GridMate/GridMate/Carrier/Carrier.cpp index a74d611f5a..9697a952e5 100644 --- a/dev/Code/Framework/GridMate/GridMate/Carrier/Carrier.cpp +++ b/dev/Code/Framework/GridMate/GridMate/Carrier/Carrier.cpp @@ -1300,6 +1300,8 @@ CarrierThread::CarrierThread(const CarrierDesc& desc, AZStd::shared_ptrInit(); AZ_UNUSED(isInit); AZ_Error("GridMate", isInit, "GridMate carrier failed to initialize compression\n"); + + m_maxMsgDataSizeBytes -= k_sizeOfCompressedHintHeader; } //////////////////////////////////////////////////////////////////////////