Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

[5.2.1p1] UNET network out of sync, HLAPI CRC errors, BUG?

Discussion in 'UNet' started by terravires, Oct 6, 2015.

  1. terravires

    terravires

    Joined:
    Mar 27, 2013
    Posts:
    103
    I'm looking for some help in tracking down error messages that don't seem to be valid.

    Code (CSharp):
    1. HLAPI CRC channel count error local: 6 remote: 7
    2. UnityEngine.Networking.NetworkIdentity:UNetStaticUpdate()
    and
    Code (CSharp):
    1. InvalidOperationException: out of sync
    2. System.Collections.Generic.Dictionary`2+Enumerator[System.String,System.Int32].VerifyState () (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:912)
    3. System.Collections.Generic.Dictionary`2+Enumerator[System.String,System.Int32].MoveNext () (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:835)
    4. System.Collections.Generic.Dictionary`2+KeyCollection+Enumerator[System.String,System.Int32].MoveNext () (at /Users/builduser/buildslave/mono-runtime-and-classlibs/build/mcs/class/corlib/System.Collections.Generic/Dictionary.cs:1028)
    5. UnityEngine.Networking.NetworkCRC.Dump (UnityEngine.Networking.NetworkSystem.CRCMessageEntry[] remoteScripts) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkCRC.cs:106)
    6. UnityEngine.Networking.NetworkCRC.ValidateInternal (UnityEngine.Networking.NetworkSystem.CRCMessageEntry[] remoteScripts, Int32 numChannels) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkCRC.cs:75)
    7. UnityEngine.Networking.NetworkCRC.Validate (UnityEngine.Networking.NetworkSystem.CRCMessageEntry[] scripts, Int32 numChannels) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkCRC.cs:66)
    8. UnityEngine.Networking.NetworkClient.OnCRC (UnityEngine.Networking.NetworkMessage netMsg) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:713)
    9. UnityEngine.Networking.NetworkConnection.HandleReader (UnityEngine.Networking.NetworkReader reader, Int32 receivedSize, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:416)
    10. UnityEngine.Networking.NetworkConnection.HandleBytes (System.Byte[] buffer, Int32 receivedSize, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:372)
    11. UnityEngine.Networking.NetworkConnection.TransportRecieve (System.Byte[] bytes, Int32 numBytes, Int32 channelId) (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkConnection.cs:522)
    12. UnityEngine.Networking.NetworkClient.Update () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:559)
    13. UnityEngine.Networking.NetworkClient.UpdateClients () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkClient.cs:773)
    14. UnityEngine.Networking.NetworkIdentity.UNetStaticUpdate () (at C:/buildslave/unity/build/Extensions/Networking/Runtime/NetworkIdentity.cs:899)
    15.  
    The very strange thing is that if I test this using NetworkManager with both online and offline scenes set to null, the game works just fine. However, if using NetworkManager in a simple scene with connect/host buttons (it has don't destroy on load flag set) then you get the above errors.

    Worse, I can't seem to track down where these errors are coming from. If I put network manager in debug/developer mode then I get

    CRC Local/Remote Dump <script> : 0

    But they both have the same number of log entries, and all end in zero. Is this another bug?

    To any unity devs, **PLEASE** add more detail to the errors/warnings. These don't give us enough information to track down the actual problem. They don't link to a game object, nor any script. Worse, in this case, don't even appear when using a single scene.
     
  2. NotQuiteSmith

    NotQuiteSmith

    Joined:
    Oct 27, 2013
    Posts:
    92
    I'm getting this error too - since yesterday. I added a new NetworkBehaviour script to a GameObject and get this error on a client when it connects to the host. If I remove the script (and the associated NetworkIdentity that gets automatically added) the error goes away.

    A few articles suggest that it's because the object isn't being spawned by script maybe (because it already exists in the scene). I'm new to this so haven't figured out what that means exactly.
     
    Last edited: Oct 7, 2015
  3. terravires

    terravires

    Joined:
    Mar 27, 2013
    Posts:
    103
    Alright, after an entire day I think I've found the code that appears to be the problem.

    I've submitted a bug #(734097) Oddly, if I run this in once scene with network manager it works, but with two scenes (online/offline) it doesn't.

    Some quick background, I've got a generic spawner object that is part of the scene. Some of them spawn world objects and some spawn enemies that I wanted a win condition if all were destroyed. So I added the coroutine to check the list. This code works, but UNET doesn't seem to like it.

    Code (CSharp):
    1.     public override void OnStartServer()
    2.     {
    3.         base.OnStartServer();
    4.      
    5.         for (int i = 0; i < count; i++)
    6.             Spawn();
    7.  
    8.         if (doWinCheck)
    9.             StartCoroutine(WinCheck());
    10.     }
    11.  
    12.     IEnumerator WinCheck()
    13.     {
    14.         while (spawnList.Count > 0)
    15.         {
    16.             yield return new WaitForSeconds(1f);
    17.             spawnList.RemoveAll((o) => o == null);
    18.         }
    19.         RpcShowWin();
    20.     }
    21.  
    22.     [ClientRpc]
    23.     void RpcShowWin()
    24.     {
    25.         Debug.Log("====== YOU WIN ========");
    26.     }
    If you remove the RpcShowWin() the errors go away. I also tried adding [ClientCallback] above the RPC but that didn't help. Is this a false positive? I only want this code to be run on the server, and then an RPC sent to the clients that will "do stuff."
     
    Last edited: Oct 7, 2015
  4. any_user

    any_user

    Joined:
    Oct 19, 2008
    Posts:
    374
    I had a similar error: http://forum.unity3d.com/threads/hlapi-crc-channel-count-error-local-4-remote-6.334538/

    I'm still not 100% sure, but I think it's caused by having prefab instances inside the scene as scene objects. I had an object which only appears as prefab instance in scenes, but is never spawned dynamically. This script seemed to cause a CRC error. Creating a new prefab with that NetworkBehaviour script (script & net identity at root level) and adding this prefab to the spawnable prefab list fixed it. But for some reason I couldn't reproduce the problem in a small project, that's why I didn't report the issue yet.
     
  5. seanr

    seanr

    Unity Technologies

    Joined:
    Sep 22, 2014
    Posts:
    669
    in the NetworkManager UI, under NetworkInfo you can turn off Script CRC Checks.
     
  6. terravires

    terravires

    Joined:
    Mar 27, 2013
    Posts:
    103
    Well that is not the case in my project, as the spawner is not a prefab. Only the player and enemy which already are listed as spawnable prefabs. Just for the heck of it, I tried making it a prefab and listing it as a spawnable prefab, didn't seem to help.

    I was aware you could turn that off, but that only masks the problem. It also removes another layer of useful checking if we do make a mistake. Does that also effect the out-of-sync issue as well?
     
  7. LeopardX

    LeopardX

    Joined:
    May 31, 2015
    Posts:
    64
    I was getting this too at one point and i did something and no i get no errors, i cant quite remember but i think i had a object that didont have an network identity on it that was using networkbehavour.