Hi,
I originally posted this within the following thread Experimental Entities 0.51 is Available
However, it was suggested it might be worth its own thread.
I updated to 0.51 and 2021.3.6 LTS and during game play I constantly receive errors similar to the following:
IndexOutOfRangeException: Index 15 is out of range of '15' Length.
Unity.Collections.NativeArray`1[T].FailOutOfRangeError (System.Int32 index) (at <4a31731933e0419ca5a995305014ad37>:0)
Unity.Collections.NativeArray`1[T].CheckElementReadAccess (System.Int32 index) (at <4a31731933e0419ca5a995305014ad37>:0)
Unity.Collections.NativeArray`1[T].get_Item (System.Int32 index) (at <4a31731933e0419ca5a995305014ad37>:0)
Unity.Rendering.SimpleCullingJob.Execute (Unity.Entities.ArchetypeChunk archetypeChunk, System.Int32 chunkIndex, System.Int32 firstEntityIndex) (at Library/PackageCache/com.unity.rendering.hybrid@0.51.0-preview.32/Unity.Rendering.Hybrid/HybridV2Culling.cs:351)
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.51.0-preview.32/Unity.Entities/IJobChunk.cs:401)
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.51.0-preview.32/Unity.Entities/IJobChunk.cs:368)
Since these errors are all occurring within the Entities/HybridV2 packages and the stack trace does not lead back to my code I have no idea what is causing it or how to fix it.
The issue appears to be due to an invalid index reference for the variable finalindex into the chunkInstanceBounds array within the SimpleCullingJob struct of HybridV2Culling.cs. See below:
var finalIndex = (j << 6) + bitIndex;
scratch[instanceOutputOffset] = processedInstanceCount + finalIndex;
// IndexList[batchOutputOffset + batchOutputCount] = processedInstanceCount + finalIndex;
// Debug.Log($"DEBUGCULLING Partial {externalBatchIndex}: [{batchOutputOffset + batchOutputCount}] = {processedInstanceCount + finalIndex}");
int advance = FrustumPlanes.Intersect2(Planes, chunkInstanceBounds[finalIndex].Value) !=
FrustumPlanes.IntersectResult.Out
? 1
: 0;
Not sure if this is a bug or something I am simply doing wrong.
Has anyone else had this issue and were able to fix?