Skip to content

feat: Allow reliable sends to go over maximum payload size #2081

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 26, 2022

Conversation

simon-lemay-unity
Copy link
Contributor

The 'Max Payload Size' setting in UnityTransport determines the largest payload that can be sent in a single Send call. Internally, we use this value to configure the fragmentation limit in UTP's fragmentation pipeline stage. This pipeline stage is only used for unreliable traffic, though. Fragmentation of reliable traffic is done directly in the send/receive queues inside UnityTransport.

So technically, reliable payload size is not bound by that 'Max Payload Size' limit (it's bound by 'Max Send Queue Size' instead). Still, UnityTransport.Send would reject reliable sends larger than 'Max Payload Size' to remain consistent with the unreliable behavior. This PR changes this behavior and now allows reliable sends to go over the configured maximum payload size.

The reason for this change is that it's now apparent (from browsing Discord and the forums) that tweaking this maximum payload size limit is a source of friction for users. Since most traffic in NGO is reliable, this PR will make it look to most users as if the limit doesn't exist. (Remains the issue of having to tweak the 'Max Send Queue Size', but solving that is a bit more complicated.)

Changelog

  • Changed: When using UnityTransport, reliable payloads are now allowed to exceed the configured 'Max Payload Size'. Unreliable payloads remain bounded by this setting.

Testing and Documentation

  • Includes unit/integration test.
  • No documentation changes or additions were necessary.

@simon-lemay-unity simon-lemay-unity requested review from a team as code owners July 26, 2022 15:55
@@ -1148,14 +1148,14 @@ public override NetcodeNetworkEvent PollEvent(out ulong clientId, out ArraySegme
/// <param name="networkDelivery">The delivery type (QoS) to send data with</param>
public override void Send(ulong clientId, ArraySegment<byte> payload, NetworkDelivery networkDelivery)
{
if (payload.Count > m_MaxPayloadSize)
var pipeline = SelectSendPipeline(networkDelivery);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😻
YAY

Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks awesome to me!

Copy link
Contributor

@JesseOlmer JesseOlmer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@JesseOlmer JesseOlmer merged commit 233cbd7 into develop Jul 26, 2022
@JesseOlmer JesseOlmer deleted the feat/allow-over-max-payload-size branch July 26, 2022 17:22
SamuelBellomo added a commit to Unity-Technologies/com.unity.multiplayer.samples.coop that referenced this pull request Jul 26, 2022
SamuelBellomo added a commit to Unity-Technologies/com.unity.multiplayer.samples.coop that referenced this pull request Oct 25, 2022
* After this PR Unity-Technologies/com.unity.netcode.gameobjects#2081 reverting MaxPayloadSize to default

* basis works, still need to debug issue with client reconnecting a second time

* setting back max payload size to default value. With recent changes, this now only applies to unreliable messages. With how little NGO uses unreliable messages, this shouldn't need any tweaking anymore.
reserializing NetworkingManager, this removes the old max send queue size value as well.

* Increasing connection approval timeout to 5 seconds, as 1 second was pretty short for a connection. If there's any packet drops or temporary lag spike, this could timeout the connection when it was actually fine. Still lower than the default 10 seconds.

* using classes instead of structs now that we have managed types available in netvars

* fixing null ref when doing reconnection flow

* deprecated note for utilities

* updating manifest and dependencies with 1.1.0 now it's released

* initializing number of reconnect attempts before starting the reconnect coroutine

* fixing player prefab being destroyed issue

Co-authored-by: Unity Netcode CI <[email protected]>
Co-authored-by: LPLafontaineB <[email protected]>
jakobbbb pushed a commit to GooseGirlGames/com.unity.netcode.gameobjects that referenced this pull request Feb 22, 2023
…hnologies#2081)

* feat: Allow reliable sends to go over maximum payload size
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants