Skip to content

Commit 3506700

Browse files
perf: Adjust maximum reliable resend timeout in UTP (#2766)
* perf: Adjust reliable resend timeouts in UTP * Only modify maximum resend timeout * Add mention of UTP 2.0 in comment
1 parent 0f959eb commit 3506700

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

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

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1229,7 +1229,17 @@ public override void Initialize(NetworkManager networkManager = null)
12291229
// Bump the reliable window size to its maximum size of 64. Since NGO makes heavy use of
12301230
// reliable delivery, we're better off with the increased window size compared to the
12311231
// extra 4 bytes of header that this costs us.
1232-
m_NetworkSettings.WithReliableStageParameters(windowSize: 64);
1232+
//
1233+
// We also increase the maximum resend timeout since the default one in UTP is very
1234+
// aggressive (optimized for latency and low bandwidth). With NGO, it's too low and
1235+
// we sometimes notice a lot of useless resends, especially if using Relay. (We can
1236+
// only do this with UTP 2.0 because 1.X doesn't support that parameter.)
1237+
m_NetworkSettings.WithReliableStageParameters(
1238+
windowSize: 64
1239+
#if UTP_TRANSPORT_2_0_ABOVE
1240+
maximumResendTime: m_ProtocolType == ProtocolType.RelayUnityTransport ? 750 : 500
1241+
#endif
1242+
);
12331243

12341244
#if !UTP_TRANSPORT_2_0_ABOVE && !UNITY_WEBGL
12351245
m_NetworkSettings.WithBaselibNetworkInterfaceParameters(

0 commit comments

Comments
 (0)