Skip to content

Conversation

@NoelStephensUnity
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity commented Nov 4, 2025

Purpose of this PR

This includes a fix for the forum reported issue-1693204 where spawning with ownership in a distributed authority topology where the owner is not the spawn authority, and the network prefab being spawned has NetworkBehaviour script that sets a NetworkVariable during OnNetworkSpawn, then the changes made would not be synchronized.

Jira ticket

MTTB-1735

Changelog

  • Fixed: WIP

Documentation

  • No documentation changes or additions were necessary.

Testing & QA (How your changes can be verified during release Playtest)

Functional Testing

Manual testing :

Above replication project used for testing

Verifying the fix:
image

  • Open the project.
  • Enable at least 1 MPPM virtual client.
  • Enter play mode.
  • Enter play mode and start the editor instance as the DAHost.
  • Start the virtual client as a DAClient.

Note:
The player colors are correct (green highlighted) and the log output shows that a follow up NetworkVariableDeltaMessage is sent when the owning client updates the CurrentPlayerColor network variable during OnNetworkSpawn (green highlight bottom right of the above screenshot).

Replicating the issue:

  • Close any MPPM virtual clients prior to downgrading to v2.7.0
  • Open package manager and add package by name:
    • Name: com.unity.netcode.gameobjects
    • Version: 2.7.0
  • Upon the downgrade completing, enable at least 1 MPPM virtual client.
  • Once the virtual client is finished loading:
    • Enter play mode and start the editor instance as the DAHost.
    • Start the virtual client as a DAClient.

Note the following issues:
image

  • The color for the joined client is not applied on the DAHost (session owner) side.
  • The log output shows that no follow up NetworkVariableDeltaMessage is sent when the owning client updates the CurrentPlayerColor network variable during OnNetworkSpawn.

Automated tests:

  • Covered by existing automated tests
  • Covered by new automated tests

Does the change require QA team to:

  • Review automated tests?
  • Execute manual tests?
  • Provide feedback about the PR?

If any boxes above are checked the QA team will be automatically added as a PR reviewer.

Backports

No back port is required.

This includes a fix for the forum reported issue where spawning with ownership in a distributed authority topology where the owner is not the spawn authority, the owner/authority sets a NetworkVariable during OnNetworkSpawn, then the changes made would not be synchronized.
This adds an integration test to validate the fix for this PR.
@NoelStephensUnity NoelStephensUnity marked this pull request as ready for review November 4, 2025 23:57
@NoelStephensUnity NoelStephensUnity requested a review from a team as a code owner November 4, 2025 23:57
removing an IDE injected namespace that is never usedd.
This migrates the NetworkList specific script from NetworkBehaviour.InternalOnNetworkSpawn into NetworkList itself.

It also provides (currently) two internal virtual methods, NetworkVariableBase.OnSpawned and NetworkVariableBase.OnPreDespawn, to provide a means for NetworkList to handle cleaning its dirty state up after the instance with write permissions has finished running through the spawn stages (pre-spawn, spawning, post-spawn, gets invoked).
Adding some debug information to NetworkShowHideTests.
Replacing m_ServerNetworkManager in OwnerModifiedTests with GetAuthorityNetworkManager() to become CMB service testing compatible.
Fixing the race condition test instability when running OwnershipPermissionsTests against CMB service until the order in which a message is received will reflect the order in which it is sent relative to messages received prior to and after the given message.
further clarifying the change made here.
Some more instability related fixes.
Copy link
Collaborator

@noellie-velez noellie-velez left a comment

Choose a reason for hiding this comment

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

Looks good to me! 🚀

@NoelStephensUnity NoelStephensUnity merged commit 710a63a into develop-2.0.0 Nov 14, 2025
30 checks passed
@NoelStephensUnity NoelStephensUnity deleted the fix/networkvariable-clearing-dirty-flags-after-onnetworkspawn branch November 14, 2025 15:55
@sentinel-u3d sentinel-u3d bot requested a review from noellie-velez November 14, 2025 16:49
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