Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Bug [1.0.12] ArgumentException: ArchetypeChunk xxx cannot be called on zero-sized IComponentData

Discussion in 'NetCode for ECS' started by optimise, Jul 31, 2023.

  1. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,106
    [GhostComponent(SendDataForChildEntity = true)]
    [GhostEnabledBit]
    public struct FooComponent: IComponentData, IEnableableComponent { }

    I will get the following error when I setup like this above but it seems like only able to reproduce it when I make a ghost to become prespawn ghost.

    ArgumentException: ArchetypeChunk.GetDynamicComponentDataArrayReinterpret<FooComponent> cannot be called on zero-sized IComponentData
    Unity.Entities.ArchetypeChunk.CheckZeroSizedGetDynamicComponentDataArrayReinterpret[T] (Unity.Entities.DynamicComponentTypeHandle& typeHandle) (at ./Library/PackageCache/com.unity.entities@cf6b09744d/Unity.Entities/Iterators/ArchetypeChunkArray.cs:1686)
    Unity.Entities.ArchetypeChunk.GetDynamicComponentDataArrayReinterpret[T] (Unity.Entities.DynamicComponentTypeHandle& typeHandle, System.Int32 expectedTypeSize) (at ./Library/PackageCache/com.unity.entities@cf6b09744d/Unity.Entities/Iterators/ArchetypeChunkArray.cs:1723)
    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@1.0.12/Runtime/Snapshot/GhostSerializationHelper.cs:67)
    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@1.0.12/Runtime/Snapshot/GhostSerializationHelper.cs:153)
    Unity.NetCode.PrespawnGhostSerializer.Execute (Unity.Entities.ArchetypeChunk& chunk, System.Int32 unfilteredChunkIndex, System.Boolean useEnabledMask, Unity.Burst.Intrinsics.v128& chunkEnabledMask) (at ./Library/PackageCache/com.unity.netcode@1.0.12/Runtime/Snapshot/Prespawn/PrespawnGhostJobs.cs:105)
    Unity.NetCode.PrespawnGhostSerializer.Unity.Entities.IJobChunk.Execute (Unity.Entities.ArchetypeChunk& chunk, System.Int32 unfilteredChunkIndex, System.Boolean useEnabledMask, Unity.Burst.Intrinsics.v128& chunkEnabledMask) (at <bad89b1bc999498c8366479bb2c73889>: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@cf6b09744d/Unity.Entities/IJobChunk.cs:434)
    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@cf6b09744d/Unity.Entities/IJobChunk.cs:359)
     
  2. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    286
    Hey optimise! This is a known issue (discovered internally). The fix is in-progress and has a good likelihood of landing for the next release.
     
    Last edited: Aug 1, 2023
    optimise likes this.
  3. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    286
    The fix will likely be available in the next release. If you want to patch yours locally, you can add
    if(!serializer.HasGhostFields) return;
    to line 67 in GhostSerializationHelper.CopyComponentToSnapshot(...).
     
    optimise, mitchell_unity28 and Richay like this.
  4. optimise

    optimise

    Joined:
    Jan 22, 2014
    Posts:
    2,106
    Hi. The issue is still reproducible at 1.2.0-exp.3 with the following attribute setup.

    [GhostComponent(PrefabType = GhostPrefabType.AllPredicted, SendDataForChildEntity = true, SendTypeOptimization = GhostSendType.OnlyPredictedClients,
    OwnerSendType = SendToOwnerType.SendToOwner)]
    [GhostEnabledBit]
    public struct FooComponent : IComponentData, IEnableableComponent { }

    System.ArgumentException: ArchetypeChunk.GetDynamicComponentDataArrayReinterpret<FooComponent> cannot be called on zero-sized IComponentData
    This Exception was thrown from a job compiled with Burst, which has limited exception support.
    0x00007ffffaeb21ff (511a035f76b9125999ede5b63b67d59) Unity.Entities.ArchetypeChunk.GetDynamicComponentDataArrayReinterpret<byte> (at C:/Backend/Unity/Library/PackageCache/com.unity.burst@1.8.11/.Runtime/Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Entities/Iterators/ArchetypeChunkArray.cs:1903)
    0x00007ffffaeb6005 (511a035f76b9125999ede5b63b67d59) Unity.NetCode.GhostPredictionDebugSystem.PredictionDebugJob.Execute (at C:/Backend/Unity/Library/PackageCache/com.unity.burst@1.8.11/.Runtime/Library/PackageCache/com.unity.netcode@1.2.0-exp.3/Runtime/Snapshot/GhostPredictionDebugSystem.cs:300)
    0x00007ffffaeb4515 (511a035f76b9125999ede5b63b67d59) Unity.Entities.JobChunkExtensions.JobChunkProducer`1<Unity.NetCode.GhostPredictionDebugSystem.PredictionDebugJob>.ExecuteInternal (at C:/Backend/Unity/Library/PackageCache/com.unity.burst@1.8.11/.Runtime/Library/PackageCache/com.unity.entities@1.2.0-exp.3/Unity.Entities/IJobChunk.cs:399)
    0x00007ffffaeadf16 (511a035f76b9125999ede5b63b67d59) 01abd03a3ef94310f76bd0425bd430fb
    0x00007ff7875f2382 (Unity) ExecuteJob
    0x00007ff7875f26f4 (Unity) ExecuteJobCopyData
    0x00007ff7875f342f (Unity) ForwardJobForEachToManaged
    0x00007ff7875ef88d (Unity) ujob_execute_job
    0x00007ff7875eec1d (Unity) lane_guts
    0x00007ff7875f1604 (Unity) worker_thread_routine
    0x00007ff78781b206 (Unity) Thread::RunThreadWrapper
    0x00007ff82cdd7344 (KERNEL32) BaseThreadInitThunk
    0x00007ff82db626b1 (ntdll) RtlUserThreadStart
     
  5. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    286
    Ah thanks. We may have forgotten to port it to 1.2. I'll take a look today, cheers.
     
    optimise likes this.
  6. NikiWalker

    NikiWalker

    Unity Technologies

    Joined:
    May 18, 2021
    Posts:
    286
    I've confirmed that the fix landed in 1.2 proper (i.e. non-experimental, 1.2 pre-release), which should be out relatively soon. Apologies for the disruption.
     
    Last edited: Nov 28, 2023
    optimise likes this.