#Reflection data error on non-generic job (1.4.0-pre4)

1 messages · Page 1 of 1 (latest)

scarlet fog
#

i'm on 1.4.0-pre4, getting this error from a non-generic system with only non-generic jobs:

System.InvalidOperationException: System.InvalidOperationException: Reflection data was not set up by an Initialize() call. For generic job types, please include [assembly: RegisterGenericJobType(typeof(MyJob<MyJobSpecialization>))] in your source file.
This Exception was thrown from a function compiled with Burst, which has limited exception support.

the error goes away, and the code starts to work if in the editor i toggle Jobs -> Enable Compilation off and on

the only generic thing about the job on the stack is that it's an IJobEntity that takes a fully closed generic component type as one of its arguments

#

the full stack is here (SetVfxDataJob takes one fully closed generic component type as an argument)

#

and of course trying to use RegisterGenericJobType fails because the jobs are not generic

#

oh and this happens on domain reload and on editor restart every time

#

unity 6000.2.0f1

scarlet fog
#

hmm turns out it's caused by SortJobDefer

scarlet fog
#

and not even connected to entities, just jobs + burst

#

scheduling SortJobDefer from bursted code is simply broken in 6000.2.0f1

small gulch
#

pretty sure it's never worked, not related to 6.2

#

you can't schedule open generic jobs from burst as it needs to run some il preprocessing

#

i assume you're doing this through one of the 'helper' methods instead of directly scheduling SortJobDefer?

#

something like
public unsafe static SortJobDefer<T, DefaultComparer<T>> SortJobDefer<T>(this NativeList<T> list)

#

if you just schedule SortJobDefer directly yourself
the documentation specifically mentions what you need to register to get this to work

/// When RegisterGenericJobType is used on SortJobDefer, to complete registration you must register SortJobDefer&lt;T,U&gt;.SegmentSort and SortJobDefer&lt;T,U&gt;.SegmentSortMerge.

scarlet fog
#

yea i tried RegisterGenericJobType but it didn't help

#

ahh ok right so it needs additional jobs to be registered

#

and i was going through the helper methods but they don't expose the actual job types

#

looks like it can be fixed with the trick you've posted before, by adding the jobs as default arguments to the Schedule() helper function

#
diff --git a/Unity.Collections/NativeSort.cs b/Unity.Collections/NativeSort.cs
index d47c115..5342687 100644
--- a/Unity.Collections/NativeSort.cs
+++ b/Unity.Collections/NativeSort.cs
@@ -1256,11 +1256,11 @@ namespace Unity.Collections
         /// </summary>
         /// <param name="inputDeps">Handle of a job to depend upon.</param>
         /// <returns>The handle of this newly scheduled job.</returns>
-        public JobHandle Schedule(JobHandle inputDeps = default)
+        public JobHandle Schedule(JobHandle inputDeps = default, SegmentSort segmentSortJob = default, SegmentSortMerge segmentSortMergeJob = default)
         {
-            var segmentSortJob = new SegmentSort { DataRO = Data, Data = Data.m_ListData, Comp = Comp, SegmentWidth = 1024 };
+            segmentSortJob = new SegmentSort { DataRO = Data, Data = Data.m_ListData, Comp = Comp, SegmentWidth = 1024 };
             var segmentSortJobHandle = segmentSortJob.ScheduleByRef(Data, 1024, inputDeps);
-            var segmentSortMergeJob = new SegmentSortMerge { Data = Data, Comp = Comp, SegmentWidth = 1024 };
+            segmentSortMergeJob = new SegmentSortMerge { Data = Data, Comp = Comp, SegmentWidth = 1024 };
             var segmentSortMergeJobHandle = segmentSortMergeJob.Schedule(segmentSortJobHandle);

             return segmentSortMergeJobHandle;
#

no more manual registration needed