AsyncPhysicsTick threading error on first play session after engine launch

Calling any physics function from AsyncPhysicsTickComponent() in my custom PawnMovementComponent seems to cause the condition check to fail on the first play session only after launching the editor.

I have checked that the physics body instance on which I am calling GetMass() is valid and that it is simulating physics. The callback to AsyncPhysicsTickComponent is indeed running on the game thread, and it’s not due to a race condition - I’ve ruled that out via delays. The error is always thrown following an editor restart.

To me, this looks like an engine issue with Chaos not properly recognizing the game thread context as such. It’s possible the correct context is cached for subsequent play sessions.

Does anyone know what’s going on?

Version: 5.5.3-39772772+++UE5+Release-5.5

LogOutputDevice: Error: === Handled ensure: ===
LogOutputDevice: Error: Ensure condition failed: IsInGameThreadContext()  [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Experimental\Chaos\Public\Framework\Threading.h] [Line: 287] 
LogOutputDevice: Error: Stack: 
LogOutputDevice: Error: [Callstack] 0x00007ff944e3899d UnrealEditor-PhysicsCore.dll!Chaos::TThreadedSingleParticlePhysicsProxyBase<1>::VerifyContext() [D:\build\++UE5\Sync\Engine\Source\Runtime\Experimental\Chaos\Public\PhysicsProxy\SingleParticlePhysicsProxy.h:1058]
LogOutputDevice: Error: [Callstack] 0x00007ff944e00001 UnrealEditor-PhysicsCore.dll!FChaosEngineInterface::GetMass_AssumesLocked() [D:\build\++UE5\Sync\Engine\Source\Runtime\PhysicsCore\Private\ChaosEngineInterface.cpp:447]
LogOutputDevice: Error: [Callstack] 0x00007ff94cb770c2 UnrealEditor-Engine.dll!UE::Core::Private::Function::TFunctionRefCaller<`FBodyInstance::OverlapTestForBodiesImpl<TSizedInlineAllocator<1,32,TSizedDefaultAllocator<32> > >'::`2'::<lambda_1>,void,Chaos::FSingleParticlePhysicsProxy * __ptr64 const & __ptr64>::Call() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Templates\Function.h:315]
LogOutputDevice: Error: [Callstack] 0x00007ff94cc5a8af UnrealEditor-Engine.dll!FPhysInterface_Chaos::ExecuteRead() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\PhysicsEngine\Experimental\PhysInterface_Chaos.cpp:512]
LogOutputDevice: Error: [Callstack] 0x00007ff94cb91535 UnrealEditor-Engine.dll!FBodyInstance::GetBodyMass() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\PhysicsEngine\BodyInstance.cpp:2826]
LogOutputDevice: Error: [Callstack] 0x00007ff94cdb6c29 UnrealEditor-Engine.dll!UPrimitiveComponent::GetMass() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\PrimitiveComponentPhysics.cpp:639]
LogOutputDevice: Error: [Callstack] 0x00000273cba130eb UnrealEditor-MRace.dll!UHoverMovementComponent::PhysicsTickWorker() [D:\Unreal Projects\MRace\Source\MRace\Private\Components\HoverMovementComponent.cpp:71]
LogOutputDevice: Error: [Callstack] 0x00007ff94cc79996 UnrealEditor-Engine.dll!FAsyncPhysicsTickCallback::OnPreSimulate_Internal() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\PhysicsEngine\Experimental\PhysScene_Chaos.cpp:208]
LogOutputDevice: Error: [Callstack] 0x00007ff94427b6b2 UnrealEditor-Chaos.dll!Chaos::FPhysicsSolverBase::ApplyCallbacks_Internal() [D:\build\++UE5\Sync\Engine\Source\Runtime\Experimental\Chaos\Public\Chaos\Framework\PhysicsSolverBase.h:603]
LogOutputDevice: Error: [Callstack] 0x00007ff9447c9ace UnrealEditor-Chaos.dll!Chaos::FPBDRigidsSolver::ApplyCallbacks_Internal() [D:\build\++UE5\Sync\Engine\Source\Runtime\Experimental\Chaos\Private\PBDRigidsSolver.cpp:794]
LogOutputDevice: Error: [Callstack] 0x00007ff944285a50 UnrealEditor-Chaos.dll!Chaos::FPhysicsSolverFrozenGTPreSimCallbacks::GTPreSimCallbacks() [D:\build\++UE5\Sync\Engine\Source\Runtime\Experimental\Chaos\Private\Chaos\Framework\PhysicsSolverBase.cpp:135]
LogOutputDevice: Error: [Callstack] 0x00007ff944283f07 UnrealEditor-Chaos.dll!TGraphTask<Chaos::FPhysicsSolverFrozenGTPreSimCallbacks>::ExecuteTask() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Async\TaskGraphInterfaces.h:634]
LogOutputDevice: Error: [Callstack] 0x00007ff9505c2722 UnrealEditor-Core.dll!UE::Tasks::Private::FTaskBase::TryExecuteTask() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Public\Tasks\TaskPrivate.h:504]
LogOutputDevice: Error: [Callstack] 0x00007ff9505b7d4a UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksNamedThread() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:779]
LogOutputDevice: Error: [Callstack] 0x00007ff9505b8089 UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksUntilIdle() [D:\build\++UE5\Sync\Engine\Source\Runtime\Core\Private\Async\TaskGraph.cpp:679]
LogOutputDevice: Error: [Callstack] 0x00007ff94d5b0370 UnrealEditor-Engine.dll!FFrameEndSync::Sync() [D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\UnrealEngine.cpp:13419]
LogOutputDevice: Error: [Callstack] 0x00007ff61d1b8b9a UnrealEditor.exe!FEngineLoop::Tick() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\LaunchEngineLoop.cpp:6095]
LogOutputDevice: Error: [Callstack] 0x00007ff61d1d57ac UnrealEditor.exe!GuardedMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Launch.cpp:188]
LogOutputDevice: Error: [Callstack] 0x00007ff61d1d589a UnrealEditor.exe!GuardedMainWrapper() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:123]
LogOutputDevice: Error: [Callstack] 0x00007ff61d1d9114 UnrealEditor.exe!LaunchWindowsStartup() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:277]
LogOutputDevice: Error: [Callstack] 0x00007ff61d1ebd04 UnrealEditor.exe!WinMain() [D:\build\++UE5\Sync\Engine\Source\Runtime\Launch\Private\Windows\LaunchWindows.cpp:317]
LogOutputDevice: Error: [Callstack] 0x00007ff61d1ef0ba UnrealEditor.exe!__scrt_common_main_seh() [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288]
LogOutputDevice: Error: [Callstack] 0x00007ffa2ddf7374 KERNEL32.DLL!UnknownFunction []
LogOutputDevice: Error: [Callstack] 0x00007ffa2f33cc91 ntdll.dll!UnknownFunction []