Skip to content

fix: SceneEventProgress was triggering twice when running a host and no clients were connected #2292

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

When running as a host with no other clients connected and loading or unloading a scene via NetworkSceneManager, SceneEventProgress would trigger twice causing NetworkSceneManager to invoke notifications of the same scene event having completed twice.

MTT-5010
Issue #2283.

Changelog

  • Fixed: Issue where the host would receive more than one event completed notification when loading or unloading a scene only when no clients were connected.

Testing and Documentation

  • Includes integration tests.
  • No documentation changes or additions were necessary.

MTT-5010
Exclude the host-client from being processed as one of the clients to test for when the scene event has completed.
MTT-5010
This integration test validates the fix for this PR.
@NoelStephensUnity NoelStephensUnity requested a review from a team as a code owner November 1, 2022 22:04
MTT-5010
The changelog entry
@NoelStephensUnity NoelStephensUnity enabled auto-merge (squash) November 1, 2022 22:35
GetClientsWithStatus needed to add the host-client to the list of clients that completed once the scene event was completed.
Also fixed a bug in GetClientsWithStatus where, when checking for clients that did  not complete, it would include the clients that completed and the clients that did not complete in the list of client identifiers it returned.
Removing unnecessary check for a null AsyncOperation and adding additional comments
Fixing issue where integration tests could lag by more than 1 network tick and the AsyncOperation could not yet be assigned.
Updating virtual methods to be able to gain access to a newly created client (via NetcodeIntegrationTest.CreateAndStartNewClient) when it is first created, started, and when it has been connected.
The updates to SceneEventProgress exposed an issue with this integration test.
It was written before many NetcodeIntegrationTest helpers, so there are adjustments here to leverage from those which greatly simplifies the test.

Also, once this test and SceneEventProgress issues were resolved it exposed a potential QoL item where if a client does not validate a scene that contains in-scene placed NetworkObjects then it will cause a soft synchronization error on the client side.

I switched the scene that was not validated by the client-side to one that did not contain an in-scene placed NetworkObject to avoid this issue and to validate that a client can ignore loading a scene (as long as it does not have any in-scene placed NetworkObjects in it).
@NoelStephensUnity NoelStephensUnity merged commit 8770f9d into develop Nov 3, 2022
@NoelStephensUnity NoelStephensUnity deleted the fix/sceneeventprogress-triggerstwice-onhost-noconnectedclients branch November 3, 2022 01:26
jakobbbb pushed a commit to GooseGirlGames/com.unity.netcode.gameobjects that referenced this pull request Feb 22, 2023
…no clients were connected (Unity-Technologies#2292)

* fix
Exclude the host-client from being processed as one of the clients to test for when the scene event has completed.
GetClientsWithStatus needed to add the host-client to the list of clients that completed once the scene event was completed. Also fixed a bug in GetClientsWithStatus where, when checking for clients that did  not complete, it would include the clients that completed and the clients that did not complete in the list of client identifiers it returned.
Fixing issue where integration tests could lag by more than 1 network tick and the AsyncOperation could not yet be assigned.

* test
Added HostReceivesOneLoadEventCompletedNotification integration test to validate the fix for this PR.
Updated NetcodeIntegrationTest virtual methods to be able to gain access to a newly created client (via NetcodeIntegrationTest.CreateAndStartNewClient) when it is first created, started, and when it has been connected.

The updates to SceneEventProgress exposed an issue with ClientSynchronizationValidationTest. It was written before many NetcodeIntegrationTest helpers, so there are adjustments here to leverage from those which greatly simplifies the test.
Switched the scene that was not validated by the client-side to one that did not contain an in-scene placed NetworkObject.

Co-authored-by: Unity Netcode CI <74025435+netcode-ci-service@users.noreply.github.com>
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.

3 participants