Repository navigation
fix: unified transport and bootstrap memory leaks - #4219
Conversation
Dispose each connection's send queue when the connection is removed or the transport shuts down, release the safety handle created per received packet, reuse the UnifiedNetcodeTransport component across restarts, and reset the UnifiedBootstrap statics on load so a disabled domain reload does not keep the previous NetworkManager alive.
| { | ||
| unifiedTransport = gameObject.AddComponent<UnifiedNetcodeTransport>(); | ||
| } | ||
| NetworkConfig.NetworkTransport = unifiedTransport; |
There was a problem hiding this comment.
After a client-to-server/host restart, a remote connection matching the previous server’s transport ID is rejected as already connected. UnifiedNetcodeTransport.Initialize replaces m_Connections but preserves m_ServerClientId from OnClientConnectedToServer. NetworkConnectionManager.TransportIdToClientId treats that retained ID as the server, so ConnectEventHandler rejects the connection. Previously, creating another transport restored the -1 sentinel. Reset m_ServerClientId to -1 in UnifiedNetcodeTransport.Initialize before reusing the component.
🤖 Helpful? 👍/👎
Codecov ReportAttention: Patch coverage is @@ Coverage Diff @@
## develop-3.x.x #4219 +/- ##
=================================================
- Coverage 76.03% 75.95% -0.08%
=================================================
Files 159 159
Lines 27344 27378 +34
=================================================
+ Hits 20791 20795 +4
- Misses 6553 6583 +30
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 1 file with indirect coverage changes
|
Purpose of this PR
Fixes the native and managed memory a hybrid (unified) session left behind on shutdown. Over the unified PlayMode suite, leaked persistent allocations at editor exit drop from 3210 (8.87 MB of
NativeArray) to 6. The 6 left are test-only and are fixed separately.The leak is most visible with domain reload disabled, where nothing reclaims it between play sessions.
PR Scope:
UnifiedNetcodeTransportdisposes each connection's send queue when the connection is removed or replaced, and disposes all of them onShutdown. A server now also removes a client's connection once that client disconnects.DisconnectRemoteClientignores a client whose connection is already gone, instead of throwing.NetworkManagerreuses an existingUnifiedNetcodeTransportinstead of adding another component on every start.UnifiedBootstrapresets its statics on load and no longer holds the lastNetworkManagerafter initialization, so a disabled domain reload does not keep the previous session alive.Out of scope:
Posecases of the RPCNativeArray/NativeListserialization tests never run and never dispose their collections (separate PR).Jira ticket
None.
Documentation
Testing & QA (How your changes can be verified during release Playtest)
Functional Testing
Manual testing :
Manual testing doneAutomated tests:
Covered by existing automated testsCovered by new automated testsUnified PlayMode suite: 283 passed, 0 failed.
Does the change require QA team to:
Review automated tests?Execute manual tests?Provide feedback about the PR?Up-port
Not needed: hybrid mode exists on develop-3.x.x only.
Backports
None.