Skip to content

Conversation

@NoelStephensUnity
Copy link
Collaborator

@NoelStephensUnity NoelStephensUnity commented Nov 12, 2025

Purpose of this PR

Fixes the issue where __rpc_name_table was not built (yet) when an RPC, located on another NetworkBehaviour that is ordered later than the invoking NetworkBehaviour, is invoked during OnNetworkSpawn and scene management is disabled.

This PR includes some re-organization:

  • Consolidated the metrics related scripts into NetworkBehaviour.
  • Added an additional define AND condition that completely excludes the metrics associated scripts and tables from a build if the Multiplayer Tools package is not installed.

fix: #3742

Jira ticket

MTTB-1734

Changelog

  • Fixed: Issue where invoking an RPC on another NetworkBehaviour associated with the same NetworkObject that is ordered before the NetworkBehaviour with the RPC and scene management is disabled could throw an exception.

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
    • Replication project was created and posted in the GH issue thread.
    • Metrics test:
      • Open any internally used manual test.
      • Make sure MP Tools package is installed.
      • Open the profiler and enable the message metrics.
      • Start a session with at least 1 MPPM virtual client.
      • Start collecting profile information while the session is active.
      • Verify the metrics are still working as expected.

Automated tests:

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

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.

Improving our defines that determine if metrics should be gathered.
1st pass attempt at unifying this process.
The primary change is that if the __rpc_name_table is not built (yet) when an RPC is invoked that it will attempt to build it for that specific NetworkBehaviour prior to attempting to log RPC metrics.
@NoelStephensUnity NoelStephensUnity marked this pull request as ready for review November 12, 2025 22:05
@NoelStephensUnity NoelStephensUnity requested a review from a team as a code owner November 12, 2025 22:05
Missed one set of defines check.
Removing reference to NetworkBehaviour.__rpc_name_table as it is not used any longer within the codegen process.
Some additional areas in codegen that requires the extended define wrap.
Wrapping the RPC invocation tests (we will need to find a better way to get the name for this test).
@NoelStephensUnity NoelStephensUnity requested review from a team and EmandM as code owners November 12, 2025 23:39
Making sure we still have the NetworkManager.__rpc_name_table as that has become part of the public API.
This fixes the issue with invoking RPCs on other child NetworkBehaviours during OnNetworkSpawn.
Adding a test to validate this specific issue is fixed.
Removing trailing whitespace.
Marking newly added methods for aggressive in-lining.
Adding change log entry.
Fixing a comment.
Adding additional comments.
Making sure the correct ValidateRpcMessageMetrics name is used when logging an error.
Updated and added some comments to the region of code that contains the primary fix.
Copy link

@FelixWentworth-Unity FelixWentworth-Unity left a comment

Choose a reason for hiding this comment

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

Tested replication project provided with NGO 2.5.0, 2.5.1. 2.6.0, 2.7.0 & these changes and can verify that this PR fixes the issues seen in 2.6.0 and 2.7.0.

Adding target client that is being sent to.
Adding AggressiveInlining to updated method.
@NoelStephensUnity NoelStephensUnity enabled auto-merge (squash) November 14, 2025 15:54
Copy link

@FelixWentworth-Unity FelixWentworth-Unity left a comment

Choose a reason for hiding this comment

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

Tested & verified - Looks good!

@sentinel-u3d sentinel-u3d bot requested a review from noellie-velez November 14, 2025 16:49
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.

Nice fix and cleanup! 🚀

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.

The given key 'EnemyAnimations' was not present in the dictionary

5 participants