fix: CleanDiffedSceneObjects was not clearing PendingSoftSyncObjects - #834
Merged
Conversation
NoelStephensUnity
requested review from
LukeStampfli,
SamuelBellomo,
TwoTenPvP and
fernando-cortez
May 15, 2021 23:43
0xFA11
reviewed
May 17, 2021
| } | ||
|
|
||
| // Make sure to clear this once done destroying all remaining NetworkObjects | ||
| PendingSoftSyncObjects.Clear(); |
Contributor
There was a problem hiding this comment.
looking at the code above, shouldn't we just iterate over PendingSoftSyncObjects, call UnityEngine.Object.Destroy on them and then do PendingSoftSyncObjects.Clear()?
I think we don't need networkObjectsToDestroy at all.
I'd suggest something like this (pseudo-code):
// Clean up any in-scene objects that had been destroyed
if (PendingSoftSyncObjects.Count > 0)
{
foreach (var pair in PendingSoftSyncObjects)
{
UnityEngine.Object.Destroy(pair.Value.gameObject);
}
// Make sure to clear this once done destroying all remaining NetworkObjects
PendingSoftSyncObjects.Clear();
}
Contributor
There was a problem hiding this comment.
Yeah that should work since it doesn't modify the actual dictionary but just makes the ghost Unity References null. Either approach works, this one being cleaner.
Member
Author
There was a problem hiding this comment.
Just applied your suggested fix @MFatihMAR
SamuelBellomo
added a commit
that referenced
this pull request
May 21, 2021
…player-object-get * develop: test: manual connection approval to fully automated connection approval testing (#839) test: manual rpc tests to automated fixed revision (#841) fix: CleanDiffedSceneObjects was not clearing PendingSoftSyncObjects (#834) feat: NetworkTransform now uses NetworkVariables instead of RPCs (#826) fix: gracefully handle exceptions in an RPC invoke (#846) fix: Fixing utp license file for legal (#843) ci: enable standards check on UTP too (#837) refactor: NetworkBehaviour.NetworkObject no longer throws an exception (#838) fix: revert #830 (#840) test: converting the manual rpc tests over to an automated unit test (#830) # Conflicts: # com.unity.multiplayer.mlapi/Tests/Runtime/MultiInstance/MultiInstanceHelpers.cs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fix is based on MTT-772:
NetworkSpawnManager.CleanDiffedSceneObjectswas cleaning remaining references to destroyed in-scene placed objects (which is detected and stored within thePendingSoftSyncObjectsdictionary), but it was never clearing thePendingSoftSyncObjectsdictionary which would result in a "key value already exists" error under the following conditions:NetworkObjectsof which some of these in-scene placedNetworkObjectsare destroyed during game play in Scene-B. Then the players transition away from Scene-B to Scene-C (post game scene because the players died or the like).NetworkObjectsdestroyed are being re-synchronized but thePendingSoftSyncObjectsstill has the sameNetworkInstanceIdas a key and its value would be null because