Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug ServerRpc is sometimes called twice on Client ho

Discussion in 'Netcode for GameObjects' started by paatz04, Jul 21, 2023.

  1. paatz04

    paatz04

    Joined:
    Aug 1, 2013
    Posts:
    37
    Hi,

    I've been trying to debug what is going on for hours, with no luck.

    I'm calling a ServerRpc on the Client Host. 9/10 times it behaves as expected, but 1/10 times the ServerRpc is fired twice. The second invocation of the ServerRpc also doesn't show the same call stacktrace.

    upload_2023-7-21_11-21-35.png

    Code (CSharp):
    1. new Targetmove serverrpc Pos: (-6.18, 5.06, 0.00)  currentPos: -6.23011
    2. UnityEngine.Debug:Log (object)
    3. Unit:UpdateTargetMovePosServerRpc (UnityEngine.Vector3) (at Assets/_scripts/battle/units/Unit.cs:607)
    4. Unit:__rpc_handler_28887104 (Unity.Netcode.NetworkBehaviour,Unity.Netcode.FastBufferReader,Unity.Netcode.__RpcParams)
    5. Unity.Netcode.RpcMessageHelpers:Handle (Unity.Netcode.NetworkContext&,Unity.Netcode.RpcMetadata&,Unity.Netcode.FastBufferReader&,Unity.Netcode.__RpcParams&) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Messaging/Messages/RpcMessages.cs:70)
    6. Unity.Netcode.ServerRpcMessage:Handle (Unity.Netcode.NetworkContext&) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Messaging/Messages/RpcMessages.cs:117)
    7. Unity.Netcode.NetworkBehaviour:__endSendServerRpc (Unity.Netcode.FastBufferWriter&,uint,Unity.Netcode.ServerRpcParams,Unity.Netcode.RpcDelivery) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Core/NetworkBehaviour.cs:94)
    8. Unit:UpdateTargetMovePosServerRpc (UnityEngine.Vector3) (at Assets/_scripts/battle/units/Unit.cs:604)
    9. Unit:UpdateTargetMovePos (UnityEngine.Vector3) (at Assets/_scripts/battle/units/Unit.cs:597)
    10. Squad:StopUnits () (at Assets/_scripts/battle/units/Squad.cs:416)
    11. Squad:Update () (at Assets/_scripts/battle/units/Squad.cs:399)
    Code (CSharp):
    1. new Targetmove serverrpc Pos: (-6.27, 5.06, 0.00)  currentPos: -6.19011
    2. UnityEngine.Debug:Log (object)
    3. Unit:UpdateTargetMovePosServerRpc (UnityEngine.Vector3) (at Assets/_scripts/battle/units/Unit.cs:607)
    4. Unit:__rpc_handler_28887104 (Unity.Netcode.NetworkBehaviour,Unity.Netcode.FastBufferReader,Unity.Netcode.__RpcParams)
    5. Unity.Netcode.RpcMessageHelpers:Handle (Unity.Netcode.NetworkContext&,Unity.Netcode.RpcMetadata&,Unity.Netcode.FastBufferReader&,Unity.Netcode.__RpcParams&) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Messaging/Messages/RpcMessages.cs:70)
    6. Unity.Netcode.ServerRpcMessage:Handle (Unity.Netcode.NetworkContext&) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Messaging/Messages/RpcMessages.cs:117)
    7. Unity.Netcode.MessagingSystem:ReceiveMessage<Unity.Netcode.ServerRpcMessage> (Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkContext&,Unity.Netcode.MessagingSystem) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Messaging/MessagingSystem.cs:541)
    8. Unity.Netcode.MessagingSystem:HandleMessage (Unity.Netcode.MessageHeader&,Unity.Netcode.FastBufferReader,ulong,single,int) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Messaging/MessagingSystem.cs:414)
    9. Unity.Netcode.MessagingSystem:ProcessIncomingMessageQueue () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Messaging/MessagingSystem.cs:434)
    10. Unity.Netcode.NetworkManager:OnNetworkEarlyUpdate () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Core/NetworkManager.cs:1443)
    11. Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Core/NetworkManager.cs:1375)
    12. Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Core/NetworkUpdateLoop.cs:185)
    13. Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:<CreateLoopSystem>b__0_0 () (at ./Library/PackageCache/com.unity.netcode.gameobjects@1.4.0/Runtime/Core/NetworkUpdateLoop.cs:208)
    14.