Search Unity

Question No prespawn baseline found for entity

Discussion in 'NetCode for ECS' started by Wepner-PD, Oct 21, 2022.

  1. Wepner-PD

    Wepner-PD

    Joined:
    Jul 13, 2018
    Posts:
    32
    Hello everyone,

    we currently struggle with an issue regarding prespawned ghosts. So far, prespawned ghosts worked as expected for other occurances, but another prespawned ghost just doesn't want to work properly. Whenever there is exactly one instance of that prefab in a subscene, it works and behaves as expected. If there are 2 or more instances, first (probably the server) encounters an exception:

    Code (csharp):
    1. InvalidOperationException: Overflow writing data to dynamic snapshot memory buffer
    2. Unity.NetCode.LowLevel.Unsafe.GhostSerializeHelper.CheckValidSnapshotOffset (System.Int32 compSize) (at Library/PackageCache/com.unity.netcode@0.50.0-preview.29/Runtime/Snapshot/GhostSerializationHelper.cs:58)
    3. Unity.NetCode.LowLevel.Unsafe.GhostSerializeHelper.CopyComponentToSnapshot (Unity.Entities.ArchetypeChunk chunk, System.Int32 ent, Unity.NetCode.LowLevel.Unsafe.GhostComponentSerializer+State& serializer) (at Library/PackageCache/com.unity.netcode@0.50.0-preview.29/Runtime/Snapshot/GhostSerializationHelper.cs:67)
    4. Unity.NetCode.LowLevel.Unsafe.GhostSerializeHelper.CopyEntityToSnapshot (Unity.Entities.ArchetypeChunk chunk, System.Int32 ent, Unity.NetCode.GhostCollectionPrefabSerializer& typeData, Unity.NetCode.LowLevel.Unsafe.GhostSerializeHelper+ClearOption option) (at Library/PackageCache/com.unity.netcode@0.50.0-preview.29/Runtime/Snapshot/GhostSerializationHelper.cs:113)
    5. Unity.NetCode.PrespawnGhostSerializer.Execute (Unity.Entities.ArchetypeChunk chunk, System.Int32 chunkIndex, System.Int32 firstEntityIndex) (at Library/PackageCache/com.unity.netcode@0.50.0-preview.29/Runtime/Snapshot/Prespawn/PrespawnGhostJobs.cs:97)
    6. Unity.Entities.JobChunkExtensions+JobChunkProducer`1[T].ExecuteInternal (Unity.Entities.JobChunkExtensions+JobChunkWrapper`1[T]& jobWrapper, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/IJobChunk.cs:401)
    7. Unity.Entities.JobChunkExtensions+JobChunkProducer`1[T].Execute (Unity.Entities.JobChunkExtensions+JobChunkWrapper`1[T]& jobWrapper, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.entities@0.50.0-preview.24/Unity.Entities/IJobChunk.cs:368)
    And then the client repeatedly reports that no prespawn baseline was found for a specific entity (one of the prespawned ghosts)

    Code (csharp):
    1. No prespawn baseline found for entity 83:1 ghostId=-2147483647
    2. UnityEngine.Debug:LogError (object)
    3. Unity.NetCode.NetDebug:LogError (Unity.Collections.FixedString512Bytes&) (at Library/PackageCache/com.unity.netcode@0.50.0-preview.29/Runtime/NetDebug.cs:355)
    4. Unity.NetCode.GhostReceiveSystem/ReadStreamJob:DeserializeEntity (uint,Unity.Networking.Transport.DataStreamReader&,Unity.NetCode.GhostReceiveSystem/ReadStreamJob/DeserializeData&) (at Library/PackageCache/com.unity.netcode@0.50.0-preview.29/Runtime/Snapshot/GhostReceiveSystem.cs:656)
    5. Unity.NetCode.GhostReceiveSystem/ReadStreamJob:Execute () (at Library/PackageCache/com.unity.netcode@0.50.0-preview.29/Runtime/Snapshot/GhostReceiveSystem.cs:435)
    6. Unity.Jobs.IJobExtensions/JobStruct`1<Unity.NetCode.GhostReceiveSystem/ReadStreamJob>:Execute (Unity.NetCode.GhostReceiveSystem/ReadStreamJob&,intptr,intptr,Unity.Jobs.LowLevel.Unsafe.JobRanges&,int)
    I just don't know hot to tackle this issue.

    Entities, NetCode, etc: v0.50
    Unity: 2020.3.32f1
     
  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    900
    The problem is that the server fails to serialize the prespawned ghost baseline (the exception there). So the client will then complain as well that is missing (because it also failing I suppose).

    I don't remember now if in 0.50 we had bug in that regards. I will check the changelog and for any missing fixes there, but I don't remember of any on top of my head.

    Do you have a small sample that show the problem? Or, could you try to use 0.51 instead or 0.50? and check if the problem is still there?
     
  3. Wepner-PD

    Wepner-PD

    Joined:
    Jul 13, 2018
    Posts:
    32
    In my experience, switching the version is always a bit finicky, but I can give it a try, it just might take some time until I get to try that.

    The project we're working on might be still "small enough" (even though a repro case could be smaller than this), but I'd rather not send it around publically. Reproducing this in a "smaller project" might take some time. =(
     
  4. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    900
    If you want you can share that privately with me. It will remain confidential of course. Switching from 0.5 to 0.51 should be not really problematic though.
     
  5. Wepner-PD

    Wepner-PD

    Joined:
    Jul 13, 2018
    Posts:
    32
    I've sent you the project and steps to reproduce (as well as some information about the project) via PM. Please let me know if you need more information to investigate the problem.

    And as mentioned in the message already: thank you in advance for the help.
     
    CMarastoni likes this.
  6. Wepner-PD

    Wepner-PD

    Joined:
    Jul 13, 2018
    Posts:
    32
    You didn't happen to take a look at it in the meantime, did you?

    Well, at least I can assume that it wasn't just a stupidly simple thing that I did wrong! =D
    (Or maybe it was and it's just difficult to spot...)
     
  7. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    900
    Hey, sorry I was super busy these day. I will take a look ASAP. My apologies.
     
  8. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    900
    Hey, sorry for keep you waiting for so long.
    I investigated what happening, and this is due to an issue we fixed in 0.51 (you are still using 0.50-preview).

    Please just change line #67 in GhostSerializationHelper.cs like this:

    Code (csharp):
    1.  
    2. // previous: CheckValidSnapshotOffset(compSize);
    3. CheckValidSnapshotOffset(serializer.SnapshotSize);  
    4.  
    this should fix you problems