[1.0.0-pre.15] A ghost changed type, ghost must keep the same serializer type ...

Looks like it’s another regression at dots netcode 1.0 release that it’s quite bug when I get it the entire game will not running properly and can’t continue to play anymore but I believe at 0.51 release it’s working nicely. Seems like 1.0 now can’t handle a couple of same ghosts that will spawn and despawn frequently anymore properly.

System.InvalidOperationException: A ghost changed type, ghost must keep the same serializer type throughout their lifetime
This Exception was thrown from a job compiled with Burst, which has limited exception support.
0x00007ff9b0c0535f (69fc70c3e020eac9d5e44459426eb7d) Unity.NetCode.GhostChunkSerializer::Unity.NetCode.GhostChunkSerializer.SerializeEntities (at C:/Backend/Unity/Library/PackageCache/com.unity.netcode@1.0.0-pre.15/Runtime/Snapshot/GhostChunkSerializer.cs:857)
0x00007ff9b0bfa186 (69fc70c3e020eac9d5e44459426eb7d) Unity.NetCode.GhostChunkSerializer::Unity.NetCode.GhostChunkSerializer.SerializeChunk (at C:/Backend/Unity/Library/PackageCache/com.unity.netcode@1.0.0-pre.15/Runtime/Snapshot/GhostChunkSerializer.cs:1590)
0x00007ff9b0c146a0 (69fc70c3e020eac9d5e44459426eb7d) Unity.NetCode.GhostSendSystem/SerializeJob::Unity.NetCode.GhostSendSystem.SerializeJob.sendEntities (at C:/Backend/Unity/Library/PackageCache/com.unity.netcode@1.0.0-pre.15/Runtime/Snapshot/GhostSendSystem.cs:1014)
0x00007ff9b0bf0d38 (69fc70c3e020eac9d5e44459426eb7d) Unity.Jobs.IJobParallelForDeferExtensions.JobParallelForDeferProducer`1<Unity.NetCode.GhostSendSystem.SerializeJob>.Execute(ref Unity.NetCode.GhostSendSystem.SerializeJob jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) → void_c8f33d8311b05a719af63ba3c6df9340 from Unity.Collections, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null (at C:/Backend/Unity/Library/PackageCache/com.unity.collections@2.1.0-pre.2/Unity.Collections/Jobs/IJobParallelForDefer.cs:64)
0x00007ff9b0bd91d6 (69fc70c3e020eac9d5e44459426eb7d) af7dabd0549a381e501936043c336ba5
0x00007ff7e070ba80 (Unity) ExecuteJob
0x00007ff7e070bde4 (Unity) ExecuteJobCopyData
0x00007ff7e070cbd5 (Unity) ForwardJobForEachToManagedDefer
0x00007ff7e07095da (Unity) ujob_execute_job
0x00007ff7e0708e27 (Unity) lane_guts
0x00007ff7e070acd4 (Unity) worker_thread_routine
0x00007ff7e0922bb7 (Unity) Thread::RunThreadWrapper
0x00007ff9fa2374b4 (KERNEL32) BaseThreadInitThunk
0x00007ff9fab026a1 (ntdll) RtlUserThreadStart

Missing EndSend, calling BeginSend without calling EndSend will result in a memory leak
UnityEngine.Debug:LogError (object)
Unity.Logging.Sinks.ManagedUnityEngineDebugLogWrapper:WriteFunc (Unity.Logging.LogLevel,byte*,int) (at Library/PackageCache/com.unity.logging@1.0.0-pre.11/Runtime/TestSinks/UnityDebugLogSink.cs:154)

System.InvalidOperationException: Failed to send a snapshot to a client
This Exception was thrown from a job compiled with Burst, which has limited exception support.
0x00007ff9b0bf11de (69fc70c3e020eac9d5e44459426eb7d) Unity.Jobs.IJobParallelForDeferExtensions.JobParallelForDeferProducer`1<Unity.NetCode.GhostSendSystem.SerializeJob>.Execute(ref Unity.NetCode.GhostSendSystem.SerializeJob jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, ref Unity.Jobs.LowLevel.Unsafe.JobRanges ranges, int jobIndex) → void_c8f33d8311b05a719af63ba3c6df9340 from Unity.Collections, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null (at C:/Backend/Unity/Library/PackageCache/com.unity.collections@2.1.0-pre.2/Unity.Collections/Jobs/IJobParallelForDefer.cs:66)
0x00007ff9b0bd91d6 (69fc70c3e020eac9d5e44459426eb7d) af7dabd0549a381e501936043c336ba5
0x00007ff7e070ba80 (Unity) ExecuteJob
0x00007ff7e070bde4 (Unity) ExecuteJobCopyData
0x00007ff7e070cbd5 (Unity) ForwardJobForEachToManagedDefer
0x00007ff7e07095da (Unity) ujob_execute_job
0x00007ff7e0708e27 (Unity) lane_guts
0x00007ff7e070acd4 (Unity) worker_thread_routine
0x00007ff7e0922bb7 (Unity) Thread::RunThreadWrapper
0x00007ff9fa2374b4 (KERNEL32) BaseThreadInitThunk
0x00007ff9fab026a1 (ntdll) RtlUserThreadStart

======================================================================
Error capture with completely disable burst

InvalidOperationException: A ghost changed type, ghost must keep the same serializer type throughout their lifetime
Unity.NetCode.GhostChunkSerializer.ValidateGhostType (System.Int32 entityGhostType, System.Int32 ghostType) (at Library/PackageCache/com.unity.netcode@1.0.0-pre.15/Runtime/Snapshot/GhostChunkSerializer.cs:364)
Unity.NetCode.GhostChunkSerializer.SerializeEntities (Unity.Collections.DataStreamWriter& dataStream, System.Int32& skippedEntityCount, System.UInt32& anyChangeMask, System.Int32 ghostType, Unity.Entities.ArchetypeChunk chunk, System.Int32 startIndex, System.Int32 endIndex, System.Boolean useSingleBaseline, Unity.NetCode.GhostChunkSerializer+CurrentSnapshotState& currentSnapshot, System.Byte** baselinesPerEntity, System.Int32* sameBaselinePerEntity, System.Int32* dynamicDataLenPerEntity, System.Int32* entityStartBit) (at Library/PackageCache/com.unity.netcode@1.0.0-pre.15/Runtime/Snapshot/GhostChunkSerializer.cs:823)
Unity.NetCode.GhostChunkSerializer.SerializeChunk (Unity.NetCode.GhostSendSystem+PrioChunk& serialChunk, Unity.Collections.DataStreamWriter& dataStream, System.UInt32& updateLen, System.Boolean& didFillPacket) (at Library/PackageCache/com.unity.netcode@1.0.0-pre.15/Runtime/Snapshot/GhostChunkSerializer.cs:1590)
Unity.NetCode.GhostSendSystem+SerializeJob.sendEntities (Unity.Networking.Transport.NetworkDriver+Concurrent& driver, Unity.Collections.DataStreamWriter& dataStream, Unity.Entities.DynamicComponentTypeHandle* ghostChunkComponentTypesPtr, System.Int32 ghostChunkComponentTypesLength) (at Library/PackageCache/com.unity.netcode@1.0.0-pre.15/Runtime/Snapshot/GhostSendSystem.cs:1014)
Unity.NetCode.GhostSendSystem+SerializeJob.Execute (System.Int32 idx) (at Library/PackageCache/com.unity.netcode@1.0.0-pre.15/Runtime/Snapshot/GhostSendSystem.cs:768)
Unity.Jobs.IJobParallelForDeferExtensions+JobParallelForDeferProducer`1[T].Execute (T& jobData, System.IntPtr additionalPtr, System.IntPtr bufferRangePatchData, Unity.Jobs.LowLevel.Unsafe.JobRanges& ranges, System.Int32 jobIndex) (at Library/PackageCache/com.unity.collections@2.1.0-pre.2/Unity.Collections/Jobs/IJobParallelForDefer.cs:64)

Thank you for reporting. We recently fixed a bug like this which is scheduled to be in the next release. I can’t say for sure this is exactly the same bug and it will fix your case - but it looks like it is so please re-test with the next version once that comes out

2 Likes

It appears as if we currently observe this or a similar issue with Entities 0.51.1-preview.21.

Put very simply, it’s a funracer where you can shoot projectiles. If all projectiles shot are the same, there is no issue, but once a different type of projectile is shot, it’s a matter of time until similar error messages occur (about changed ghost type and seemingly some resulting errors). It’s a bit difficult to boil down when this issue occurs, more debugging will be necessary there.

It’s at least rather surprising to me: different projectiles are represented by different prefabs, that only differ in the material used on a child, and an enum value in the component data (not a ghost field).

@timjohansson : Besides that, there doesn’t seem to be a new release available yet. Do you have any information about when the fix you mentioned might be released?

Hiya,

I was wondering if the code is small enough to fix this bug in the package if it could be made available for us to swap out.

We’re also seeing this error happen sometimes when a level is being rest, possibly due to spawning / destroying lots of ghosts at the same time in the same frame.

The fix itself is small. It requires changes in the Entities package (expose an internal method) and some changes in the GhostSendSystem.
0.51 is not currently an LTS version we are going to support (1.0 is). However, that does not means we can’t do anything.
Let me investigate what we can do. I would say that at least a “patch” here can make sense.

If I understood @optimise right, the issue can be observed with Entities 1.0. Do I understand you right that you were able to confirm this issue exists (or existed) in a 1.0 version of Entities? If so, would a fix be contained in the next 1.0 (pre-)release?

We’ll have to upgrade at some point to 1.0, but since this will require some work to be done (and testing to ensure no new issues are introduced this way), it might take a moment until we actually tackle the upgrade.

The fix is already present in the current (releasing, if not already available) 1.0-prerelease.