Using GhostEnabledBit on an IEnableableComponent throws internal exceptions

I use a number of enableable components on my ghost entities which need to be synced, and so I add the [GhostEnabledBit] attribute.

This causes this error every frame:

System.ArgumentException: ArchetypeChunk.GetDynamicComponentDataArrayReinterpret<{0}> cannot be called on zero-sized IComponentData
This Exception was thrown from a job compiled with Burst, which has limited exception support.
0x00007ffbc70220f7 (a74322a48c1908a63b00f21b7692da3) Unity.Entities.ArchetypeChunk::Unity.Entities.ArchetypeChunk.GetDynamicComponentDataArrayReinterpret<byte> (at D:/game/Library/PackageCache/com.unity.entities@1.0.0-pre.15/Unity.Entities/Iterators/ArchetypeChunkArray.cs:1701)
0x00007ffbc717aaaa (a74322a48c1908a63b00f21b7692da3) Unity.NetCode.GhostPredictionHistorySystem/PredictionBackupJob::Unity.NetCode.GhostPredictionHistorySystem.PredictionBackupJob.Execute (at D:/game/Library/PackageCache/com.unity.netcode@1.0.0-pre.15/Runtime/Snapshot/GhostPredictionHistorySystem.cs:550)
0x00007ffbc7178291 (a74322a48c1908a63b00f21b7692da3) Unity.Entities.JobChunkExtensions.JobChunkProducer`1<Unity.NetCode.GhostPredictionHistorySystem.PredictionBackupJob>.ExecuteInternal (at D:/game/Library/PackageCache/com.unity.entities@1.0.0-pre.15/Unity.Entities/IJobChunk.cs:397)
0x00007ffbc7174cd1 (a74322a48c1908a63b00f21b7692da3) 6a0be67e85ac7492ff6114a863d33fe6
0x00007ff65ce4a620 (Unity) ExecuteJob
0x00007ff65ce4a984 (Unity) ExecuteJobCopyData
0x00007ff65ce4b6bf (Unity) ForwardJobForEachToManaged
0x00007ff65ce4817a (Unity) ujob_execute_job
0x00007ff65ce479c7 (Unity) lane_guts
0x00007ff65ce49874 (Unity) worker_thread_routine
0x00007ff65d060d97 (Unity) Thread::RunThreadWrapper
0x00007ffc99417614 (KERNEL32) BaseThreadInitThunk
0x00007ffc9a0426a1 (ntdll) RtlUserThreadStart

However, if I add a dummy field to the component, all is fine.

// Throws error.
[GhostEnabledBit]
public struct IsReadyForDeletion : IComponentData, IEnableableComponent { }

// All good.
[GhostEnabledBit]
public struct IsReadyForDeletion : IComponentData, IEnableableComponent { public bool Dummy; }

Hey Richay,

Thanks for the report. Could you disable burst temporarily and run this again please? The stacktrace may be more specific.

Cheers.

ArgumentException: ArchetypeChunk.GetDynamicComponentDataArrayReinterpret<System.Byte> cannot be called on zero-sized IComponentData
Unity.Entities.ArchetypeChunk.CheckZeroSizedGetDynamicComponentDataArrayReinterpret[T] (Unity.Entities.DynamicComponentTypeHandle& typeHandle) (at Library/PackageCache/com.unity.entities@1.0.0-pre.15/Unity.Entities/Iterators/ArchetypeChunkArray.cs:1648)
Unity.Entities.ArchetypeChunk.GetDynamicComponentDataArrayReinterpret[T] (Unity.Entities.DynamicComponentTypeHandle& typeHandle, System.Int32 expectedTypeSize) (at Library/PackageCache/com.unity.entities@1.0.0-pre.15/Unity.Entities/Iterators/ArchetypeChunkArray.cs:1682)
Unity.NetCode.GhostPredictionHistorySystem+PredictionBackupJob.Execute (Unity.Entities.ArchetypeChunk& chunk, System.Int32 unfilteredChunkIndex, System.Boolean useEnabledMask, Unity.Burst.Intrinsics.v128& chunkEnabledMask) (at Library/PackageCache/com.unity.netcode@1.0.0-pre.15/Runtime/Snapshot/GhostPredictionHistorySystem.cs:550)
Unity.NetCode.GhostPredictionHistorySystem+PredictionBackupJob.Unity.Entities.IJobChunk.Execute (Unity.Entities.ArchetypeChunk& chunk, System.Int32 unfilteredChunkIndex, System.Boolean useEnabledMask, Unity.Burst.Intrinsics.v128& chunkEnabledMask) <0x162c3d5edd0 + 0x00072> in <c747730968894f8d9b4f08e532811fe5>:0
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@1.0.0-pre.15/Unity.Entities/IJobChunk.cs:409)
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@1.0.0-pre.15/Unity.Entities/IJobChunk.cs:357)
1 Like

I’ve confirmed repro here. Fix incoming.

2 Likes

Excellent, thanks!

The fix will land in edit: an upcoming pre-release. If you need it now, see attached code, and note the two new additions (lines 548 and 620) of the if (GhostComponentCollection[serializerIdx].HasGhostFields). I.e. we only need to perform the copy if we actually have GhostFields (as they are the only fields actually rolled back).

8720373–1179117–GhostPredictionHistorySystem.cs (40 KB)

2 Likes

@Richay & @Kmsxkuse Apologies, I got my wires crossed. See my edit above. Strongly recommend you implement that change to get unblocked in the short term.

1 Like