Skip to content

refactor: Remove exceptions from Network Spawn Manager#3933

Open
noellie-velez wants to merge 15 commits intodevelop-2.0.0from
refactor/remove-exceptions-network-spawn-manager
Open

refactor: Remove exceptions from Network Spawn Manager#3933
noellie-velez wants to merge 15 commits intodevelop-2.0.0from
refactor/remove-exceptions-network-spawn-manager

Conversation

@noellie-velez
Copy link
Copy Markdown
Collaborator

Purpose of this PR

Remove exceptions from Network Spawn Manager

Jira ticket

MTT-14791

Changelog

  • Changed: Replaced Exceptions and Debug.Log by NetworkLog logs

Documentation

  • No documentation changes or additions were necessary.

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

Functional Testing

Manual testing :

  • Manual testing done

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

Comment thread com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs Outdated
Comment thread com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs Outdated
Comment thread com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs Outdated
Comment thread com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs Outdated
Comment thread com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs Outdated
Comment thread com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs Outdated
Comment thread com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs Outdated
Comment thread com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs Outdated
Comment thread com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs Outdated
Comment thread com.unity.netcode.gameobjects/Runtime/Spawning/NetworkSpawnManager.cs Outdated
@noellie-velez noellie-velez marked this pull request as ready for review April 8, 2026 15:06
@noellie-velez noellie-velez requested a review from a team as a code owner April 8, 2026 15:06
Copy link
Copy Markdown
Member

@NoelStephensUnity NoelStephensUnity left a comment

Choose a reason for hiding this comment

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

The only suggestion I have is adding a changelog entry for this PR before merging it.
The rest looks great to me!
👍

// In distributed authority mode, we send a single message that is broadcasted to all clients
// that will be shown the object (i.e. 1 message to service that then broadcasts that to the
// targeted clients). When using a DAHost, we skip this and send like we do in client-server
// In distributed authority mode, we send a single message to the service,
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Nice clean up of this comment!
😻

return;
}

if (networkManager == null || !networkManager.IsListening)
Copy link
Copy Markdown
Collaborator Author

@noellie-velez noellie-velez Apr 14, 2026

Choose a reason for hiding this comment

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

Can networkManager be null here? If so, wouldn’t that already cause an exception on line 2299 (networkManager.ShutdownInProgres) and again on line 2312 (networkManager.DistributedAuthorityMode)?

I’d suggest either removing this null check, or checking for null at the start of the function if it can actually be empty.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah...that is a good call-out.
Moving this just under line 2298 make much more sense (especially since we do a check against it (currently) on line 2299.

Comment thread com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
Copy link
Copy Markdown
Member

@NoelStephensUnity NoelStephensUnity 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 @noellie-velez !

Added a suggested change back to the networkManager vs NetworkManagerOwner.
This was originally added to handle the issue with running multiple NetworkManager instances within the same application domain but after looking around a bit it looks like it is starting to be used a bit more than expected.
Really, the comment above this field (screenshot below) is a bit vague and only hints that it is specific to integration testing (i.e. "Multi NetworkManagers").

Image

return;
}

if (networkManager == null || !networkManager.IsListening)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Yeah...that is a good call-out.
Moving this just under line 2298 make much more sense (especially since we do a check against it (currently) on line 2299.

Comment thread com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
Comment thread com.unity.netcode.gameobjects/Runtime/Core/NetworkObject.cs
Comment thread 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.

2 participants