Search Unity

Netcode RPC reliability

Discussion in 'NetCode for ECS' started by fnuecke, Apr 5, 2020.

  1. fnuecke

    fnuecke

    Joined:
    Jul 1, 2015
    Posts:
    8
    In the current Netcode preview on the Package Manager (0.1.0-preview.6 at the time of writing), from what I've seen in both behavior and code, it appears that RPCs can silently be lost if more RPC data than can fit one packet is generated in a single frame. Aside from this happening silently, this is devious in at least two ways: once there's a decent number of systems generating RPCs, it becomes hard to reason about how many and which RPCs can theoretically be spawned in a single frame, so to design around this is... troublesome. Also, the number of bytes that can be written in a single frame appears to depend on what the underlying transport layer can accept at the current time. This, I assume, depends on the current remaining capacity of the underlying pipeline's send buffer. So it can vary.

    Since it may already be possible for RPCs to be delayed one or more frames if driver.BeginSend fails (although this might only ever happen when the connection is broken, not sure when NetworkSendInterface.BeginSendMessage may return != 0 otherwise?), and mostly because it doesn't matter for my use case, I patched the RPC logic to also track the size of pending RPCs so the send system can always send as many RPCs as possible without running into the danger of splitting RPC data up into separate packets (which could then lead to broken deserialization on the receiving end) and keep the rest for later. If anyone is interested, the patch is attached. Not rigorously tested though.

    Now, my question is: was this a deliberate design decision? I couldn't find anything in the docs about it.
    If yes, what is the suggested way of sending data in a reliable way then? E.g. current game state of non-ghost world state for clients that join in late (state that is non-ghost because it's too big for that, e.g. heightmap data).
    If no, how likely is it that this will be addressed and what could an outline of an official solution to this problem look like? Thanks!


    PS: I tried to find topics on this on the forums, but it's hard when the search doesn't allow search terms that are only three letter long, such as "rpc"... so if there is a topic on that already, apologies!
     

    Attached Files:

    CPlusSharp22, bb8_1 and Kelevra like this.
  2. pocketpair

    pocketpair

    Joined:
    Jul 7, 2015
    Posts:
    72
    @timjohansson can you answer above question? I also faced RPCs lost problem when I call rpcQueue.schedule multiple times per 1 frame.
     
    bb8_1 likes this.
  3. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    You are correct that RPCs cannot handle too much data, and it should at the very least be possible to detect and throttle the RPCs. Can you please file a bug through the unity bug reporter about it so we can track it?
     
    CPlusSharp22 and bb8_1 like this.
  4. pocketpair

    pocketpair

    Joined:
    Jul 7, 2015
    Posts:
    72
    @timjohansson Reported. I attached reproduced project. Thank you for your support.
    I would appreciate it if you could include this solution into next release.

    1261375
    RPCs can silently be lost if more RPC data than can fit one packet is generated in a single frame
     
    Orimay and bb8_1 like this.
  5. pocketpair

    pocketpair

    Joined:
    Jul 7, 2015
    Posts:
    72
  6. pocketpair

    pocketpair

    Joined:
    Jul 7, 2015
    Posts:
    72
    @timjohansson Hi, I know your are busy and sorry for rushing you.
    We really want your help to use latest 0.3.0 netcode package if possible. Thank you in advance.
     
  7. CPlusSharp22

    CPlusSharp22

    Joined:
    Dec 1, 2012
    Posts:
    111
    "You are correct that RPCs cannot handle too much data"

    What's too much data? And how would you identify this prior besides intuition?
     
  8. Cero

    Cero

    Joined:
    Jul 30, 2020
    Posts:
    1
    @timjohansson when is 0.3.0 going to be released? Or like Pocketpair askt is it possible to get a version with the RPC fix in it?
     
  9. timjohansson

    timjohansson

    Unity Technologies

    Joined:
    Jul 13, 2016
    Posts:
    473
    We are working on getting 0.3.0 out, but it is a big release with among other things a rewrite of ghost authoring so i don't know yet how long it will take to get it out
     
    optimise, pocketpair and bb8_1 like this.