Skip to content

RPCs + Spawn calls not in order #790

Closed
@LukeStampfli

Description

@LukeStampfli

Describe the bug
When spawning an object and then trying to reference that object via an RPC it is possible that the RPC arrives before the object gets spawned. This bug happens because Spawn calls and RPCs use different ReliableSequenced channels internally and thus lose the guarantee of order.

To Reproduce
Steps to reproduce the behavior:

  1. Spawn an object using NetworkObject::Spawn
  2. Invoke a ClientRpc containing the id of the NetworkObject as a parameter immediately after spawning the object on another NetworkObject.
  3. Have the ClientRpc search for the object with NetworkSpawnManager.SpawnedObjects[objNetID]
  4. Error appears in some cases. This is a race condition.

Actual outcome
KeyNotFound Exception is thrown.

Expected outcome
Because RPCs and Spawn calls are in order I'm able to reference my NetworkObject

Environment (please complete the following information):

  • OS: any
  • Unity Version: any
  • MLAPI Version: 0.1.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    good-first-issueContributions are welcome. Good first issue for newcomers or first time contributors.type:bugBug Report

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions