Skip to content

fix: NetworkSceneManager does not synchronize despawned in-scene placed NetworkObjects [MTT-2924] (backport #1898)#1968

Closed
NoelStephensUnity wants to merge 56 commits intorelease/1.0.0from
fix/backport-mtt-2924-despawned-scene-objects-dont-synchronize-late-joining-clients
Closed

fix: NetworkSceneManager does not synchronize despawned in-scene placed NetworkObjects [MTT-2924] (backport #1898)#1968
NoelStephensUnity wants to merge 56 commits intorelease/1.0.0from
fix/backport-mtt-2924-despawned-scene-objects-dont-synchronize-late-joining-clients

Conversation

@NoelStephensUnity
Copy link
Copy Markdown
Member

This is a backport of PR-1898

This resolves the issue where an in-scene placed NetworkObject could be despawned prior to a client joining and the client-side in-scene placed NetworkObject component's would not receive a despawn notification when synchronizing.

This also greatly reduces user pain by not requiring users to register in-scene placed NetworkObjets with the NetworkManager using prefab hash overrides. Instead, it just uses the table of in-scene NetworkObjects that were already being tracked by the NetworkSceneManager.

MTT-2924

Changelog

  • Fixed: NetworkSceneManager does not synchronize despawned in-scene placed NetworkObjects.
  • Changed: requirement to register in-scene placed NetworkObjects with NetworkManager in order to respawn them. In-scene placed NetworkObjects are now automatically tracked during runtime and no longer need to be registered as a NetworkPrefab.

Testing and Documentation

  • Includes manual test (Additive Scene Loading: Backspace on server spawns/despawns the green in-scene NetworkObject)
  • Includes integration test updates.
  • Includes integration test: InScenePlacedNetworkObjects

NetcodeIntegrationTest Updates:

image
The image above is an integration test that has two (2) clients and (1) host where the host loaded a scene that has in-scene placed NetworkObjects. If the in-scene NetworkObject has the TestHelper ObjectNameIdentifier component, then like in the above image you will be able to visually distinguish between each relative instance.

NoelStephensUnity and others added 30 commits May 15, 2022 14:26
MTT-2924
This is the first pass at solving the issue where late joining clients are not synchronized properly with despawned in-scene NetworkObjects.
This allows for respawning of in-scene placed NetworkObjects without having to register them with the NetworkManager.
whitespace fixes.
Passing the entire SceneObject structure as opposed to adding more parameters to the NetworkSpawnManager.HasPrefab method in order to be able to extract the NetworkSceneHandle and include the in-scene placed NetworkObjects as part of the "prefabs to search for".
This is some work towards integration tests where clients might be able to actually load scenes as opposed to fake loading them
Fixed some minor issues with tests.
Updated HiddenVariableTests as it needed some timing related adjustments.
This update allows for clients to load scenes and synchronize in-scene placed NetworkObjects during integration testing.
Now that clients are loading scenes, needed to make some minor adjustments.
Realized I don't need to simulate client loading delay unless the client is blocked from loading.
Also had to adjust whether the metrics tests waited for the client or not when loading.
Fixes an issue that can occur where this becomes enabled in test runner and will throw an exception if target is null.
GetSceneRelativeInSceneNetworkObject needed to get the sceneHandle before checking for it existing in the ScenePlacedObjects.
AddDespawnedInSceneNetworkObjects needed to only return despawned NetworkObjects belonging to the NetworkManager.
This fixes some of the last edge case scenarios such as:
- Not loading scenes for clients when a non-NetcodeIntegrationTest based integration test is running since this does require some additional management and cleanup.
- Assuring that in-scene NetworkObjects have the right NetworkManager assigned when loaded
- Added a check to assure that it didn't time out while waiting for all clients to connect
- Increased the NetcodeIntegrationTestHelpers default timeout to 2s vs 1s (clients loading scenes can slow down when things happen)
- NetcodeIntegrationTests now unload all scenes loaded (but the test runner scene) during teardown and onetimeteardown.
Just adding timeout checks in both NetworkVariableTests and TimeMultiInstanceTest
Updating some of the assets used for integration testing now that clients are loading scenes too.
Changing the scenes being loaded to avoid integration test specific SDK architecture related issues.
An early shutdown was not needed here
Disabling the audio listener in the EmptyScene to reduce console spam during integration tests.
Fixing edge case timing issue with MessageOrdering.
This is the integration test for this PR.
It tests late joining client synchronization with despawned NetworkObjects and tests that in-scene placed NetworkObjects do not need to be registered with the NetworkManager to be spawned.
Don't throw an exception when calling GetObservers or IsNetworkVisibleTo when the NetworkObject is not spawned.
fixing typo/mistake for the scene to be unloaded.
updating comments and removing LFs and some commented out code.
updating comments and minor final tweaks.
minor changes suggested by Jeffrey R.
removing scene management specific code from places where scene management is disabled.
updated some comments
Fixing an issue where CheckValueOnClient was crashing.  Integration test timing did change slightly now that clients load scenes, so it was possible that the key would not exist by the time it was being checked.
reducing the number of clients from 9 to 4 in some of the NetworkSceneManager related tests as I think it impacted performance enough to cause clients to take longer than the default timeout of 2 seconds.
Hopefully this will fix the issue with Xbox Scarlett
Removing m_CanCheckLoadUnloadEvents as that was a sanity check while I was testing clients loading scenes.  This could possibly fix an edge case scenario issue where a message might get ignored.
removing NetworkSceneHandle from NetworkObject as it was not needed.
Removing wait for clients to unload scenes and unloading them via SceneManager as the test has already completed and this is more clean up than anything else.
Removed the crazy code in ObjectNameIdentifier for adding tag information and simplified it by storing the original name and using that each time it needs to regenerate the tag information.
Moved where the NetworkManager name and tag information is applied to get the right client id.
Added additional debug information.
Testing with verbose mode to see why this passes on Windows 10 in a stand alone build and in the editor but fails on Yamato desktops.
adding more debug info.
Looks like the scene isn't really loaded when it says it is loaded.
Moving when the NetworkSceneManager's callback is invoked and adding delay before invoking.
Making some additional modifications to see if it was when the NetworkSceneManager scene Load/Unload event action is invoked and reducing the number of clients to 1.
Minor tweaks and merging develop into this branch.
Found a bug in some recent changes that would cause a crash under specific scenarios.
Went back through some of the changed files and removed some code no longer needed, extended some of the verbose debug info for any future debugging purposes, and updated some of the comments.
removing commented out code.
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.

2 participants