Type not assigned to the Dependency property?

I’m having some problems understanding a logged error relating to dependencies. I get the following error logged:

This is the scheduling of the job in question:

            Dependency = new GetActiveActorsJob
            {
                EntityTypeHandle = GetEntityTypeHandle(),
                IsActingHandle = GetComponentTypeHandle<IsActing>(true),
                ActiveActors = active_queue.AsParallelWriter()
            }.ScheduleParallel
            (
                _registeredActors,
                JobHandle.CombineDependencies(Dependency, _deactivateCurrentActorSystem.OutputDependency)
            );
           
            Dependency = new ActivateNextActorJob
            {
                TurnManager = GetSingletonEntity<TurnManager>(),
                Player = player,
                TurnOrderBuffer = GetBufferFromEntity<ActorOrderBufferItem>(),
                ActiveIndex = GetSingleton<ActiveActorIndex>().Value,
                CommandBuffer = _commandBufferSystem.CreateCommandBuffer(),
                ActiveActors = active_queue,
                ActiveActorTrackingRecords = active_actor_tracking_records
            }.Schedule(Dependency);
            _commandBufferSystem.AddJobHandleForProducer(Dependency);

The full stack track for the above error points to this line as where the problem “happens” in my code.

            Dependency = new BuildTargetAdjacentTilesMap
            {
                TranslationHandle = GetComponentTypeHandle<Translation>(true),
                EntityTypeHandle = GetEntityTypeHandle(),
                RegionContainer = this.GetRegion(),
                TileStorageBuffers = this.GetTileStorage(),
                AdjacentTilesMap = target_positions_map.AsParallelWriter()
            }.ScheduleParallel(_registeredActors, Dependency);

The most troubling part of this is that this issue didn’t always exist, and I’m not sure what changed to cause it to start happening. It appears that the systems are working as expected, but the error is logged nonetheless. Usually with dependency related errors it has been easy to track down exactly what’s going wrong so that I can fix it up, but I am not sure where to even begin with this one.

This error incorrectly shows when a previous job exits due to an exception. Annoyingly, the error message shows up before the job error message in the error list. Check to see if an error right afterwards pertains to a previous job. Another cause I have seen is forgetting to use AsDeferredJobArray() on a NativeList which causes implicit conversion instead.

7 Likes

No others errors are happening at all as far as I can tell, but I will give it another look over and take a look at the AsDeferredJobArray() bit, I’ve never encountered that so I could be doing something wrong.

Going to throw this in here for anyone has a similar issue and stumbles upon this thread. Be VERY careful with your Dependency properties.

My issue was that I had a single system that was assigning to the Dependency property, but not passing the property into the first job, so it was throwing away the automatic Dependency management done by unity.

E.g. I HAD this:

            Dependency = new RunBeginTurnJob
            {
                Writer = _commandBufferSystem.CreateCommandBuffer().AsParallelWriter(),
                EntityTypeHandle = GetEntityTypeHandle(),
                ActionPlanRequestEventHandle = GetComponentTypeHandle<ActionPlanRequestEvent>()
            }.ScheduleParallel(_beginTurnRequests);
            _commandBufferSystem.AddJobHandleForProducer(Dependency);

and the correction was to pass Dependency into the ScheduleParallel call.

            Dependency = new RunBeginTurnJob
            {
                Writer = _commandBufferSystem.CreateCommandBuffer().AsParallelWriter(),
                EntityTypeHandle = GetEntityTypeHandle(),
                ActionPlanRequestEventHandle = GetComponentTypeHandle<ActionPlanRequestEvent>()
            }.ScheduleParallel(_beginTurnRequests, Dependency);
            _commandBufferSystem.AddJobHandleForProducer(Dependency);

Man, how did you manage to solve that?
I have the same issue! Could you please check and help me

Through trial and error, I was able to work around this exception by removing a single ref dependency in a ForEach job. I really have no idea why that worked.

The dependency was not used in the job if that helps.