Search Unity

Question [LogError] NetworkPrefab hash was not found!

Discussion in 'Netcode for GameObjects' started by GuirieSanchez, Feb 9, 2023.

  1. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
    I'm trying to get a reconnection for clients that have been AFK for a few seconds and therefore lost connection. In order to do so, I'm just shutting the network via:

    Code (CSharp):
    1. var netMan = NetworkManager.Singleton;
    2.             if (netMan != null && netMan.ShutdownInProgress == false)
    3.             {
    4.                 netMan.Shutdown();
    5.             }
    And then perform a regular connection:

    Code (CSharp):
    1. public void StartClient()
    2.         {
    3.             SetTransportConnectionData(NetcodeUtils.TryResolveHostname(ConnectionAddressData.Address));
    4.  
    5.             SetConnectionPayload();
    6.  
    7.             NetworkManager.Singleton.StartClient();
    8.        
    9.         }
    Then, I elaborated some code where clients get all the information needed from the host and update their game status as soon as they reconnect. And it works fine and dandy, except for these errors that I'm getting:



    There are 7 pairs of these. The following are the full ErrorLog for one of the seven pairs:
    Code (CSharp):
    1. [Netcode] NetworkPrefab hash was not found! In-Scene placed NetworkObject soft synchronization failure for Hash: 4028500965!
    2. UnityEngine.Debug:LogError (object)
    3. Unity.Netcode.NetworkLog:LogError (string) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Logging/NetworkLog.cs:34)
    4. Unity.Netcode.NetworkSpawnManager:CreateLocalNetworkObject (Unity.Netcode.NetworkObject/SceneObject) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Spawning/NetworkSpawnManager.cs:394)
    5. Unity.Netcode.NetworkObject:AddSceneObject (Unity.Netcode.NetworkObject/SceneObject&,Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkManager) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkObject.cs:1403)
    6. Unity.Netcode.SceneEventData:SynchronizeSceneNetworkObjects (Unity.Netcode.NetworkManager) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/SceneManagement/SceneEventData.cs:877)
    7. Unity.Netcode.NetworkSceneManager:HandleClientSceneEvent (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/SceneManagement/NetworkSceneManager.cs:1781)
    8. Unity.Netcode.NetworkSceneManager:ClientLoadedSynchronization (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/SceneManagement/NetworkSceneManager.cs:1747)
    9. Unity.Netcode.NetworkSceneManager:OnClientBeginSync (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/SceneManagement/NetworkSceneManager.cs:1676)
    10. Unity.Netcode.NetworkSceneManager:HandleClientSceneEvent (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/SceneManagement/NetworkSceneManager.cs:1774)
    11. Unity.Netcode.NetworkSceneManager:HandleSceneEvent (ulong,Unity.Netcode.FastBufferReader) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/SceneManagement/NetworkSceneManager.cs:1961)
    12. Unity.Netcode.SceneEventMessage:Handle (Unity.Netcode.NetworkContext&) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Messaging/Messages/SceneEventMessage.cs:26)
    13. Unity.Netcode.MessagingSystem:ReceiveMessage<Unity.Netcode.SceneEventMessage> (Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkContext&,Unity.Netcode.MessagingSystem) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Messaging/MessagingSystem.cs:511)
    14. Unity.Netcode.MessagingSystem:HandleMessage (Unity.Netcode.MessageHeader&,Unity.Netcode.FastBufferReader,ulong,single,int) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Messaging/MessagingSystem.cs:384)
    15. Unity.Netcode.MessagingSystem:ProcessIncomingMessageQueue () (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Messaging/MessagingSystem.cs:404)
    16. Unity.Netcode.NetworkManager:OnNetworkEarlyUpdate () (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkManager.cs:1600)
    17. Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkManager.cs:1532)
    18. Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkUpdateLoop.cs:185)
    19. Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:<CreateLoopSystem>b__0_0 () (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkUpdateLoop.cs:208)
    20.  
    and
    Code (CSharp):
    1. [Netcode] Failed to spawn NetworkObject for Hash 4028500965.
    2. UnityEngine.Debug:LogError (object)
    3. Unity.Netcode.NetworkLog:LogError (string) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Logging/NetworkLog.cs:34)
    4. Unity.Netcode.NetworkObject:AddSceneObject (Unity.Netcode.NetworkObject/SceneObject&,Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkManager) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkObject.cs:1410)
    5. Unity.Netcode.SceneEventData:SynchronizeSceneNetworkObjects (Unity.Netcode.NetworkManager) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/SceneManagement/SceneEventData.cs:877)
    6. Unity.Netcode.NetworkSceneManager:HandleClientSceneEvent (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/SceneManagement/NetworkSceneManager.cs:1781)
    7. Unity.Netcode.NetworkSceneManager:ClientLoadedSynchronization (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/SceneManagement/NetworkSceneManager.cs:1747)
    8. Unity.Netcode.NetworkSceneManager:OnClientBeginSync (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/SceneManagement/NetworkSceneManager.cs:1676)
    9. Unity.Netcode.NetworkSceneManager:HandleClientSceneEvent (uint) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/SceneManagement/NetworkSceneManager.cs:1774)
    10. Unity.Netcode.NetworkSceneManager:HandleSceneEvent (ulong,Unity.Netcode.FastBufferReader) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/SceneManagement/NetworkSceneManager.cs:1961)
    11. Unity.Netcode.SceneEventMessage:Handle (Unity.Netcode.NetworkContext&) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Messaging/Messages/SceneEventMessage.cs:26)
    12. Unity.Netcode.MessagingSystem:ReceiveMessage<Unity.Netcode.SceneEventMessage> (Unity.Netcode.FastBufferReader,Unity.Netcode.NetworkContext&,Unity.Netcode.MessagingSystem) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Messaging/MessagingSystem.cs:511)
    13. Unity.Netcode.MessagingSystem:HandleMessage (Unity.Netcode.MessageHeader&,Unity.Netcode.FastBufferReader,ulong,single,int) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Messaging/MessagingSystem.cs:384)
    14. Unity.Netcode.MessagingSystem:ProcessIncomingMessageQueue () (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Messaging/MessagingSystem.cs:404)
    15. Unity.Netcode.NetworkManager:OnNetworkEarlyUpdate () (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkManager.cs:1600)
    16. Unity.Netcode.NetworkManager:NetworkUpdate (Unity.Netcode.NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkManager.cs:1532)
    17. Unity.Netcode.NetworkUpdateLoop:RunNetworkUpdateStage (Unity.Netcode.NetworkUpdateStage) (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkUpdateLoop.cs:185)
    18. Unity.Netcode.NetworkUpdateLoop/NetworkEarlyUpdate/<>c:<CreateLoopSystem>b__0_0 () (at Library/PackageCache/com.unity.netcode.gameobjects@1.2.0/Runtime/Core/NetworkUpdateLoop.cs:208)

    I've done some reading on this kind of ErrorLogs, where people refer to monobehaviours being attached to network objects, but that doesn't make total sense to me, or having to do with nested prefabs, which I think I don't have but I don't understand it completely. What could really be causing this issue? Any bad practice on my part that rings your bell?
     
    Last edited: Feb 10, 2023
  2. lavagoatGG

    lavagoatGG

    Joined:
    Apr 16, 2022
    Posts:
    229
    Do you call DontDestroyOnLoad(gameObject) for each of the network objects?
     
    GuirieSanchez likes this.
  3. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
    Yes, I do. I need to have network objects that don't get destroyed. Is there any work around it?
     
  4. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
  5. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    666
    I wouldn't like to guess at the problem but I'd recommend trying to reproduce it in a small test project. That way even if you're still none the wiser it would be easier to share for others to look at.
     
    GuirieSanchez likes this.
  6. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
    It can be reproduced in a new project:
    • Create a new GameObject with a networkbehavior and a network object component.
    • Add a DontDestroyOnLoad script to that GameObj
    • Connect your client to the host
    • Finally, you call the following on the client side:
      Code (CSharp):
      1. var netMan = NetworkManager.Singleton;
      2.             if (netMan != null && netMan.ShutdownInProgress == false)
      3.             {
      4.                 netMan.Shutdown();
      5.             }
    • and
      Code (CSharp):
      1. public void StartClient()
      2.         {
      3.             SetTransportConnectionData(NetcodeUtils.TryResolveHostname(ConnectionAddressData.Address));
      4.             SetConnectionPayload();
      5.             NetworkManager.Singleton.StartClient();
      6.      
      7.         }
    You will get these pair of errors for each Don't Destroy On Load script attached to a Network Object (in this case, 1 pair of errors since there's only 1 network obj). I found that these errors appear to be harmless. Nonetheless, it wouldn't make a lot of sense not to allow network objects to remain in between scenes.
     
  7. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    666
    I'll give it a go a bit later. :)
     
    GuirieSanchez likes this.
  8. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
    I appreciate it!

    PS: I came to the conclusion of these error logs being harmless since they didn't affect either the gameplay, connection, or reconnection at any point on the many tests I've done. But nevertheless, it'd be nice if we could get some confirmation from the NGO developers.
     
  9. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    By looking at some internal changelogs, I think this has been solved in NGO 1.3.0 (which at the time of writing isn't out yet)
     
    lavagoatGG and GuirieSanchez like this.
  10. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
    @RikuTheFuffs-U Thanks for letting us know!
     
    RikuTheFuffs-U likes this.
  11. lavagoatGG

    lavagoatGG

    Joined:
    Apr 16, 2022
    Posts:
    229
    When will it be out?
     
  12. RikuTheFuffs-U

    RikuTheFuffs-U

    Unity Technologies

    Joined:
    Feb 20, 2020
    Posts:
    440
    There's no official date yet, but I'd say in 3-4 weeks. Could be earlier, could be later.
     
    lavagoatGG likes this.
  13. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    666
    I'm not getting any errors in NGO 1.2.0. Are you switching scenes?
     
  14. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
    Hmmm, interesting...
    No, they stay on the same scene, I'm also using 1.2.0.
     
  15. cerestorm

    cerestorm

    Joined:
    Apr 16, 2020
    Posts:
    666
    Send me over your project files so I we're on the same page. You can export them with Assets -> Export Package...
     
    GuirieSanchez likes this.
  16. GuirieSanchez

    GuirieSanchez

    Joined:
    Oct 12, 2021
    Posts:
    452
    I'm afraid the package will be too extensive (also there might contain files I might not be able to share). Anyway, it's all good if it gets fixed on the 1.3.0 version. In the meanwhile, I don't think it's a big deal to get those error logs as long as they don't affect the gameplay.

    Thanks for the help! @cerestorm

    PS: I don't have time as of right now to create a new setup (I deleted the previous one (a very simple version) when I was done doing the testing). If I find time later I will try to recreate it and share the results if I'm able to reproduce it again.