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

Question After recompile RPCs fail the first time I enter playmode if "Reload Scene" is unchecked

Discussion in 'Netcode for GameObjects' started by CodeSmile, Oct 3, 2022.

  1. CodeSmile

    CodeSmile

    Joined:
    Apr 10, 2014
    Posts:
    4,013
    I have a simple setup where I Host and Join in two editor instances (thanks to ParrelSync).

    Every time I make a script change, recompile, start a host and connect the client on the other instance, the RPC calls fail with a warning message on the server side:

    Code (CSharp):
    1. [Netcode] Deferred messages were received for a trigger of type OnSpawn with key 0, but that trigger was not received within within 1 second(s).
    I then exit playmode in both editors, and do the exact same thing again, and then it is working. I've gotten into the habit of start host, join client, exit playmode, start host, join client and THEN do my tests.

    I did some digging and figured out that the behaviour is "fixed" by enabling Reload Scene under Enter Play Mode Settings (I used to have scene reload disabled):
    upload_2022-10-3_18-1-0.png

    What could be causing such a behaviour?

    I'm aware of domain reload issues, specifically with statics and events. But I didn't expect t̶h̶e̶ ̶s̶p̶a̶n̶i̶s̶h̶ ̶i̶n̶q̶u̶i̶s̶i̶t̶i̶o̶n̶ Reload Scene to be an issue in this case.

    Here's the scene hierarchy:
    upload_2022-10-3_17-48-3.png

    NetworkManager (in Bootstrap) has one Player prefab and connection approval enabled (currently always approves and passes the player name in the payload). I use Unity Transport, and connection info (address, port) are provided via the StartMenu GUI.

    QuickStartMenu is just a GUI that eventually calls StartHost/Client.

    DataTransfer is in-scene placed network object which fails to send/receive RPC calls.
    It has a NetworkFileTransfer (MonoBehaviour) and three NetworkBehaviour (NetworkDataTransfer*) and the NetworkObject.

    ServerRPC calls are set to RequireOwnership = false

    upload_2022-10-3_17-53-21.png

    I would post code but I wouldn't even know where to begin looking for the root cause of an issue like this. Like I said, it always works the second (and third etc) time entering playmode but never the first time AFTER a recompile / assembly reload when Reload Scene is unchecked.

    I had this issue both in 2022.2.9 (beta) and now I'm in 2020.3.40 with the same behaviour.

    Any ideas? I just like to understand the issue, I don't mind having Reload Scene enabled.
     
  2. slosk

    slosk

    Joined:
    May 20, 2017
    Posts:
    1
    I have the exact same issue except mine doesn't print any logs it just silently fails.

    Also when I try to host and start a game with only the host it also fails meaning that I have this issue without ParrelSync as well. (in fact I'm on a new machine right now where I have not even setup parrelsync yet.)

    I have a close to as minimal as possible networking template that I can share here, as well as reproduction steps if someone from Unity comes across this post just ask :)