Skip to content
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

fix: NetworkManager.ShutdownInProgress not being reset #2661

Merged

Conversation

NoelStephensUnity
Copy link
Collaborator

This resolves the issue where invoking NetworkManager.Shutdown within NetworkManager.OnClientStopped or NetworkManager.OnServerStopped would force NetworkManager.ShutdownInProgress to remain true after completing the shutdown process.

Changelog

  • Fixed: Issue where invoking NetworkManager.Shutdown within NetworkManager.OnClientStopped or NetworkManager.OnServerStopped would force NetworkManager.ShutdownInProgress to remain true after completing the shutdown process.

Testing and Documentation

  • Includes additions to integration test NetworkManagerTests.ValidateShutdown
  • No documentation changes or additions were necessary.

This resolves the issue where the NetworkManager.m_ShuttingDown property could be set to true again if the shutdown method is invoked within OnClientStopped or OnServerStopped.
This validates that if you invoke shutdown within OnClientStopped or OnServerStopped that NetworkManager.ShutdownInProgress remains false once completing the shutdown process.
Adding the changelog entry for this fix.
Making the changelog entry for v1.6.0 branch match #2657
@NoelStephensUnity NoelStephensUnity marked this pull request as ready for review August 10, 2023 20:09
@NoelStephensUnity NoelStephensUnity requested a review from a team as a code owner August 10, 2023 20:09
@@ -1013,6 +1013,9 @@ internal void ShutdownInternal()
OnServerStopped?.Invoke(ConnectionManager.LocalClient.IsClient);
}

// In the event shutdown is invoked within OnClientStopped or OnServerStopped, set it to false again
m_ShuttingDown = false;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not just move the existing place where it's set to false, instead of setting it twice? Is there a reason it should always be false in OnServerStopped and OnClientStopped?

Copy link
Collaborator Author

@NoelStephensUnity NoelStephensUnity Aug 10, 2023

Choose a reason for hiding this comment

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

If someone is checking ShutdownInProgress it would return true if it was not set to false...
Yeah... it is a weird thing... so... OnServerStopped and OnClientStopped could invoke other (generic) methods that depend upon that value being false (i.e. validating that the shutdown has completed...which it really hasn't 100% completed...but we are invoking those callbacks at that point in time... so... one of those scenarios... keep it true and someone will complain that it still thinks it is shutting down when it is notifying that it stopped...set it to false...and someone might invoke shutdown again... for--->insert various reasons here<---... 😹 )

The compromise was to just make sure it was no longer shutting down after potentially invoking user code.

Copy link
Collaborator

Choose a reason for hiding this comment

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

That feels like it could use some conceptual rework... but not for 1.6. We can go with this for now...

Copy link
Collaborator Author

@NoelStephensUnity NoelStephensUnity Aug 10, 2023

Choose a reason for hiding this comment

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

Yep... 💯%

@@ -10,8 +10,11 @@ Additional documentation and release notes are available at [Multiplayer Documen

### Added

- Added a protected virtual method `NetworkTransform.OnInitialize(ref NetworkTransformState replicatedState)` that just returns the replicated state reference.
Copy link
Collaborator

Choose a reason for hiding this comment

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

This seems unrelated to the PR, is it supposed to be here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Well, it makes it easier if we merge this into the changelog now since that adjustment was made to #2657

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I could take it out... it should just collapse when merged.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Don't think we need it in two PRs... but either way, can you add the PR number for this changelog entry?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Eh.. you are right... no point in having it in two places and it might be confusing being in this PR... your initial gut reaction is probably the right way...
"This is the way..."

Removing the adjusted changelog entry
@SamuelBellomo SamuelBellomo merged commit 4ee8da0 into release/1.6.0 Aug 14, 2023
22 checks passed
@SamuelBellomo SamuelBellomo deleted the fix/networkmanager-shuttingdown-not-being-reset branch August 14, 2023 20:19
SamuelBellomo added a commit that referenced this pull request Aug 29, 2023
* release/1.6.0:
  fix: NetworkManager.ShutdownInProgress not being reset (#2661)
  chore: version bump for changelog and package (#2657)

# Conflicts:
#	com.unity.netcode.gameobjects/CHANGELOG.md
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.

None yet

3 participants