aws / lumberyard

Amazon Lumberyard is a free AAA game engine deeply integrated with AWS and Twitch – with full source.
Other
2.02k stars 539 forks source link

Carrier can't send large messages with data compression enabled #542

Open m9co opened 3 years ago

m9co commented 3 years ago

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.

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

trng-lmbr commented 3 years ago

Hello @m9co! We've integrated your pull request and wanted to let you know that you should be able to see your changes in our next version of the Lumberyard engine. Thank you kindly for contributing to Lumberyard!