Skip to content

fix: Reset NetworkClient upon shutdown #3491

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

Conversation

NoelStephensUnity
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity commented Jun 9, 2025

This PR addresses some NetworkManager instance clean up when shutdown including the ConnectionManager's NetworkClient.
This PR also includes a clean up for NetworkObject upon despawning in the event one is using an object pool.

MTT-12384

Changelog

  • Fixed: Issue where NetworkClient could persist some settings if re-using the same NetworkManager instance.
  • Fixed: Issue where a pooled NetworkObject was not resetting the internal latest parent property when despawned.

Testing and Documentation

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

Backport

This requires a back port for pertinent/similar areas. (#3494)

Resetting the NetworkClient upon shutdown.
Added internal NetworkObject.ResetOnDespawn which resolves issue where m_LatestParent could still be set if using object pools.
It can now also be used to reset anything that needs to be reset at the end of a NetworkObject despawn.
@NoelStephensUnity NoelStephensUnity added the port:1.x-needed This issue needs to be ported to 1.X branch label Jun 9, 2025
Need to keep the NetworkClient around a tad longer during shutdown. Making adjustments for this.
Removing System.Text
Adding two integration tests to validate this PR
adding whitespace
Fixing issue where now spawn manager can be null sooner than expected because all references have been cleared (i.e. NetworkClient pointing to the player object possibly).
NoelStephensUnity added a commit that referenced this pull request Jun 9, 2025
Apply fixes from #3491
@NoelStephensUnity NoelStephensUnity marked this pull request as ready for review June 9, 2025 21:56
@NoelStephensUnity NoelStephensUnity requested a review from a team as a code owner June 9, 2025 21:56
@NoelStephensUnity NoelStephensUnity enabled auto-merge (squash) June 9, 2025 21:59
@NoelStephensUnity NoelStephensUnity added port:1.x-completed This issue was ported to 1.X branch and removed port:1.x-needed This issue needs to be ported to 1.X branch labels Jun 10, 2025
NoelStephensUnity added a commit that referenced this pull request Jun 10, 2025
This PR addresses some NetworkManager instance clean up when shutdown
including the ConnectionManager's NetworkClient.
This PR also includes a clean up for NetworkObject upon despawning in
the event one is using an object pool.

[MTT-12384](https://jira.unity3d.com/browse/MTT-12384)

## Changelog

- Fixed: Issue where `NetworkClient` could persist some settings if
re-using the same `NetworkManager` instance.
- Fixed: Issue where a pooled `NetworkObject` was not resetting the
internal latest parent property when despawned.

## Testing and Documentation

- Includes integration test updates.
- No documentation changes or additions were necessary.


<!-- Uncomment and mark items off with a * if this PR deprecates any
API:
### Deprecated API
- [ ] An `[Obsolete]` attribute was added along with a `(RemovedAfter
yyyy-mm-dd)` entry.
- [ ] An [api updater] was added.
- [ ] Deprecation of the API is explained in the CHANGELOG.
- [ ] The users can understand why this API was removed and what they
should use instead.
-->

## Backport
This is a back port of #3491.
<!-- If this is a backport:
 - Add the following to the PR title: "\[Backport\] ..." .
 - Link to the original PR.
If this needs a backport - state this here
If a backport is not needed please provide the reason why.
If the "Backports" section is not present it will lead to a CI test
failure.
-->
@NoelStephensUnity NoelStephensUnity merged commit c3060b4 into develop-2.0.0 Jun 10, 2025
35 checks passed
@NoelStephensUnity NoelStephensUnity deleted the fix/reset-networkclient-completely-upon-shutdown branch June 10, 2025 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
port:1.x-completed This issue was ported to 1.X branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants