Major bug with intersect ray and worker group threads

Godot Version

4.4

Question

Situation: Worker thread pool → grouptask → raycasting → checking collisions between units to see if there is a wall between them. The group task is called from the physics process and the physics state is stored in a variable.

The walls are tiles in a tilemap with phy layers. The raycast is correct 99% of the time and can tell if there is a wall between two units. however 1% of the time it will seem to forget a wall is there and allow the unit to attack.

(see large red debug line showing the raycast)

When I just run the same code in a loop over all the units in the physics thread, everything works fine.

I spent all day poking and prodding and looking around the internet, so now i come humbled to the alter of @smix8 and hope they will bless me with some knowledge.

thank you.

To whoever finds this later. Something is wrong with group tasks and the physics state combined with tilemaps. Everything works fine when I switch to just using WorkerThreadPool.AddTask instead of grouptask.

The plot thickens more.

All intersect rays work when using

        long ID = WorkerThreadPool.AddGroupTask(Callable.From<int>(UnitTargetAquisitionAtIndex), AllCombatObjects.Count,1,true,"Test");

however if you increase the threads above 1 they dont respect collision at all!

        long ID = WorkerThreadPool.AddGroupTask(Callable.From<int>(UnitTargetAquisitionAtIndex), AllCombatObjects.Count,8,true,"Test");

There is a major bug in here…