Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Bug [1.0.0-pre.15]NetCode RPC Entity has not been consumed or destroyed for '4' (MaxRpcAgeFrames) frames

Discussion in 'NetCode for ECS' started by optimise, Jun 29, 2022.

  1. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,029
    Looks like when u create multiple rpc entity too fast you will get the following warning. For my project I always get 4 following warnings. Maybe it's caused by the server send the rpc, but the client not ready to receive it yet I dunno. Any plan to fix it?

    In 'ClientWorld0', NetCode RPC Entity(xxx:1) has not been consumed or destroyed for '4' (MaxRpcAgeFrames) frames! Assumed unhandled. Call .Consume(), or remove the RPC component, or destroy the entity.
     
    Last edited: Jun 29, 2022
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    774
    Usually the problem is that the RPC is received by either the client or the server but no systems are consuming (by destroying the rpc entity).
    In all our sample we never get this error, so it is something wrong you are doing. If the server send and rpc and the client does not consume in 4 frame we log a warning because usually RPCs are consumed as soon as they are received.
    The warning is just informing you that the entity must be destroyed otherwise it will remain there forever (until the world is destroyed).
    If you intend to received an RPC message and keep that entity alive for some reason you should mark the rpc as consumed using the Consume() method on the ReceivedRpcRequestComponent, that will disable that check.
    Note that the warning is present only in debug or editor.
     
    Lukas_Kastern likes this.
  3. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    774
    So.. did you fix the problem?
     
  4. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,029
    Sorry for super late reply. Not yet but I guess the current implementation of RPC forces u to immediately handle RPC just received from client/server and destroy RPC entity when. But sometimes I need to do RequireForUpdate to wait for an entity to exist first then only run the receive RPC system then I will get the warning. So basically I will process received RPC entity a little bit late but I will immediately destroy it after process the RPC entity. I think official can relieve this limitation that I believe there's quite a lot of use cases for it.
     
    Last edited: Feb 6, 2023
  5. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    774
    There is a specific Consume() method that you can use for that purpose. You can use to mark the RPC has "used", even though is still present in the world and the check will not complain.
     
  6. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    224
    Another option is to change the warning itself to trigger after more than 4 frames. E.g. 1000. Do so via the NetDbg singleton.

    If you do not delete a received RPC after 1k frames (and thus, get this error), it is likely an RPC that has been missed by one of your systems (in your case, a server raised RPC not handled on the client).

    One other interesting note is the xxx,1 on the Entity. Not sure how that can happen.
     
    Last edited: Feb 6, 2023
  7. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    224
    Also, if you receive the error 4 times, that implies that you've created this RPC entity 4 more times, and each of them is unhandled. The error should only trigger once per unhandled RPC.
     
  8. morphex

    morphex

    Joined:
    Dec 18, 2012
    Posts:
    108
    I get the same error when "spamming" a bunch of RPC calls to the server ( for example, press pace to generate a RPC, and it gets consume on server by just displaying a log.

    Eventually I get a bunch of these warning - but my entities actually get destroyed. Changing the delay on the debug tools does fix the issue, though.
     
  9. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,029
    Actually my use case is at client/server I need to RequireForUpdate waiting for ghost entity to stream in first to setup some data getting from RPC entity but when I receive RPC entity earlier before ghost entity then RPC entity stay at there for awhile then I will get the warning
     
    CMarastoni likes this.
  10. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    774
    I think both are pretty common pattern scenario, especially the one described by @optimise.
    We are going to work on major improvement and changes for the RPC this year (no ETA yet). So feedback in these are really welcome and important.
    Thanks both.
     
    Occuros and optimise like this.