Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only. On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live. Read our full announcement for more information and let us know if you have any questions.

Bug [SceneEventData- Scene Handle Mismatch] - This warning always displays for clients

Discussion in 'Netcode for GameObjects' started by ktdab, Nov 8, 2022.

  1. ktdab


    Sep 22, 2018
    Thanks for looking!

    In a simple two scene setup, and this code on the server/host:

    Code (CSharp):
    2. NetworkManager.Singleton.StartHost();
    3.         int i = 0;
    4.         while (i < 10000)
    5.         {
    6.             if (NetworkManager.Singleton.IsListening)
    7.             {
    8.                 //NetworkManager.SceneManager.LoadScene("WorldMultiDemo", LoadSceneMode.Single); //This produces same warning
    9.                 NetworkManager.Singleton.SceneManager.LoadScene("Scene2", LoadSceneMode.Single);
    10.                 Debug.Log($"NetworkManagerIsListening after i={i}");
    11.                 return;
    12.             }
    13.             i++;
    14.         }
    It always seems to be listening at i=0. The scene loads fine for the host. The client connects with:

    Code (CSharp):
    2. NetworkManager.Singleton.GetComponent<UNetTransport>().ConnectAddress = "";
    3. NetworkManager.Singleton.StartClient();
    The client connects and this warning is created. The documentation here ( says the client should automatically sync, and that looks like it's happening.

    [SceneEventData- Scene Handle Mismatch] serverSceneHandle could not be found in ServerSceneHandleToClientSceneHandle. Using the currently active scene.
    UnityEngine.Debug:LogWarning (object)
    Unity.Netcode.NetworkSceneManager:SetTheSceneBeingSynchronized (int) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0/Runtime/SceneManagement/NetworkSceneManager.cs:738)
    Unity.Netcode.SceneEventData:SynchronizeSceneNetworkObjects (Unity.Netcode.NetworkManager) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0/Runtime/SceneManagement/SceneEventData.cs:725)
    Unity.Netcode.NetworkSceneManager:HandleClientSceneEvent (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0/Runtime/SceneManagement/NetworkSceneManager.cs:1788)
    Unity.Netcode.NetworkSceneManager:ClientLoadedSynchronization (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0/Runtime/SceneManagement/NetworkSceneManager.cs:1754)
    Unity.Netcode.ISceneManagerHandler/SceneEventAction:Invoke () (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0/Runtime/SceneManagement/ISceneManagerHandler.cs:26)
    Unity.Netcode.NetworkSceneManager/DefaultSceneManagerHandler/<>c__DisplayClass0_0:<LoadSceneAsync>b__0 (UnityEngine.AsyncOperation) (at Library/PackageCache/com.unity.netcode.gameobjects@1.0.0/Runtime/SceneManagement/NetworkSceneManager.cs:344)
    UnityEngine.AsyncOperation:InvokeCompletionEvent ()

    A search on the forums and google comes up dry for specifics.
    Is there something I'm missing here?

  2. CodeSmile


    Apr 10, 2014
    Make sure host and client are running the same build, and that "Scene 2" is included in the Build Settings.

    Best way to ensure that is to use ParrelSync so you can work with two or more (readonly) Unity editor instances of the same project which is synchronized with the original (editable) project.

    This actually hurts my brain:
    Code (CSharp):
    1.         while (i < 10000)
    2.         {
    3.             if (NetworkManager.Singleton.IsListening)
    4.             {
    5.                 return;
    6.             }
    7.             i++;
    8.         }
    I don't know why you're doing that, but it's pointless. The i will either always be 0 or 10000, never anything in-between because this is neither multithreaded nor a coroutine that yields.
    d2b906 likes this.
  3. cerestorm


    Apr 16, 2020
    I get this error on a test project, I've never looked into it as it hasn't caused any issues. Here's what the comments say in the source code:
    Code (CSharp):
    1. // This could be the scenario where NetworkManager.DontDestroy is false and we are creating the first NetworkObject (client side) to be in the DontDestroyOnLoad scene
    2. // Otherwise, this is some other specific scenario that we might not be handling currently.
    IsListening is set to true in StartHost so there's no need to wait on it.
  4. ktdab


    Sep 22, 2018
    Good to know! I read in the docs that the network manager needed to be completely started before accessing the NetworkSceneManager and I wanted to rule out that causing this issue.

    I love ParrelSync! I used it all the time before I started this VR project. I think its great but I'm pretty sure there are some compatibility issues with one of the Oculus SDKs - specifically the OculusAudoSpacializer. Even reverting to previous working commits wouldn't fix the issue but it hasn't happened since I stopped using ParrelSync.

    Code (CSharp):
    2. // This could be the scenario where NetworkManager.DontDestroy is false and we are creating the first NetworkObject (client side) to be in the DontDestroyOnLoad scene
    3. // Otherwise, this is some other specific scenario that we might not be handling currently.
    In my case, one computer is running the build and the other is using play mode in the editor (this warning happens regardless of which is host/client). Perhaps that's the cause.

    Thanks for the replies!