Skip to content

fix: Client RPCs always reporting all RPCs as going to all clients, even when limited by ClientRpcParams [MTT-4468] #2144

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged

Conversation

ShadauxCat
Copy link
Collaborator

Changelog

  • Fixed: Fixed ClientRpcs always reporting in the profiler view as going to all clients, even when limited to a subset of clients by ClientRpcParams.

Testing and Documentation

  • Includes integration tests.
  • No documentation changes or additions were necessary.

@ShadauxCat ShadauxCat requested review from a team as code owners August 23, 2022 23:11
Copy link
Contributor

@JesseOlmer JesseOlmer left a comment

Choose a reason for hiding this comment

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

lgtm

rpcMethodName,
__getTypeName(),
rpcWriteSize);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

If the clientRpcParams.Send.TargetClientIdsNativeArray didn't cause Boxing allocation I would suggest using something like:

IEnumerable<ulong> enumerable;

if (clientRpcParams.Send.TargetClientIds != null)
{
    enumerable = clientRpcParams.Send.TargetClientIds;
}
else if (clientRpcParams.Send.TargetClientIdsNativeArray != null)
{
    enumerable = clientRpcParams.Send.TargetClientIdsNativeArray;
}
else
{
    enumerable = NetworkObject.Observers;
}

foreach (var networkObject in enumerable)
{
    NetworkManager.NetworkMetrics.TrackRpcSent(
        networkObject,
        NetworkObject,
        methodName,
        __getTypeName(),
        rpcWriteSize);
}

But in this case, it seems there's no other way to achieve the most efficient code without sacrificing a bit of readability.

So I believe your code is the best choice here.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, that was my thought, too.

@ShadauxCat ShadauxCat enabled auto-merge (squash) August 26, 2022 16:49
@ShadauxCat ShadauxCat merged commit 6169357 into develop Aug 26, 2022
@ShadauxCat ShadauxCat deleted the fix/profiler_showing_rpcs_as_always_going_to_all_clients branch August 26, 2022 17:16
jakobbbb pushed a commit to GooseGirlGames/com.unity.netcode.gameobjects that referenced this pull request Feb 22, 2023
…ven when limited by ClientRpcParams [MTT-4468] (Unity-Technologies#2144)

* fix: Client RPCs always reporting all RPCs as going to all clients, even when limited by ClientRpcParams

* Changelog
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.

4 participants