Description

Deadlock in Chaos during PIE; the main thread is in USkeletalMeshComponent::HandleExistingParallelEvaluationTask waiting for a task to complete, and a worker thread is running that task and is in USkeletalMeshComponent::PerformBlendPhysicsBones, but unfortunately the main thread has locked the scene for writing and the worker thread is trying to read it.

Licensee is hitting this intermittently but has a workaround: disabled async animation evaluation ("Allow Multi Threaded Animation Update").
But since that will hit their frame rate they request a fix instead.

Matt Peters: I believe `UPhysicalAnimationComponent::UpdatePhysicsEngineImp` needs to be modified to call `GetBoneSpaceTransforms` before entering the lock.

Slack thread in private support channel:
[Link Removed]

Game thread:

[External Code]	
 	UnrealEditor-Core.dll!FEventWin::Wait(unsigned int WaitTime, const bool bIgnoreThreadIdleStats) Line 1599	C++
 	[Inline Frame] UnrealEditor-Core.dll!FEvent::Wait() Line 76	C++
 	UnrealEditor-Core.dll!FScopedEvent::~FScopedEvent() Line 691	C++
 	UnrealEditor-Core.dll!FTaskGraphCompatibilityImplementation::WaitUntilTasksComplete(const TArray<TRefCountPtr<FGraphEvent>,TSizedInlineAllocator<4,32,TSizedDefaultAllocator<32>>> & Tasks, ENamedThreads::Type CurrentThreadIfKnown) Line 2220	C++
 	UnrealEditor-Engine.dll!FTaskGraphInterface::WaitUntilTaskCompletes(const TRefCountPtr<FGraphEvent> & Task, ENamedThreads::Type CurrentThreadIfKnown) Line 405	C++
>	UnrealEditor-Engine.dll!USkeletalMeshComponent::HandleExistingParallelEvaluationTask(bool bBlockOnTask, bool bPerformPostAnimEvaluation) Line 4091	C++
 	UnrealEditor-Engine.dll!USkeletalMeshComponent::GetBoneSpaceTransforms() Line 4657	C++
 	UnrealEditor-Engine.dll!UPhysicalAnimationComponent::UpdatePhysicsEngineImp::__l5::<lambda_1>::operator()() Line 376	C++
 	[Inline Frame] UnrealEditor-Engine.dll!UE::Core::Private::Function::TFunctionRefBase<UE::Core::Private::Function::FFunctionRefStoragePolicy,void __cdecl(void)>::operator()() Line 629	C++
 	UnrealEditor-Engine.dll!FPhysInterface_Chaos::ExecuteWrite(USkeletalMeshComponent * InMeshComponent, TFunctionRef<void __cdecl(void)> InCallable) Line 590	C++
CurrentFrame=974 bHasFloor=true ...}	Chaos::FPBDRigidsSolver * {UnrealEditor-Chaos.dll!Chaos::FPBDRigidsSolver}
 	UnrealEditor-Engine.dll!UPhysicalAnimationComponent::UpdatePhysicsEngineImp() Line 374	C++
 	UnrealEditor-Engine.dll!UPhysicalAnimationComponent::TickComponent(float DeltaTime, ELevelTick TickType, FActorComponentTickFunction * ThisTickFunction) Line 313	C++
 	[Inline Frame] UnrealEditor-Engine.dll!FActorComponentTickFunction::ExecuteTick::__l2::<lambda_1>::operator()(float) Line 1097	C++
 	UnrealEditor-Engine.dll!FActorComponentTickFunction::ExecuteTickHelper<`FActorComponentTickFunction::ExecuteTick'::`2'::<lambda_1>>(UActorComponent * Target, bool bTickInEditor, float DeltaTime, ELevelTick TickType, const FActorComponentTickFunction::ExecuteTick::__l2::<lambda_1> & ExecuteTickFunc) Line 4520	C++
 	UnrealEditor-Engine.dll!FActorComponentTickFunction::ExecuteTick(float DeltaTime, ELevelTick TickType, ENamedThreads::Type CurrentThread, const TRefCountPtr<FGraphEvent> & MyCompletionGraphEvent) Line 1095	C++
 	UnrealEditor-Engine.dll!FTickFunctionTask::DoTask(ENamedThreads::Type CurrentThread, const TRefCountPtr<FGraphEvent> & MyCompletionGraphEvent) Line 278	C++
 	UnrealEditor-Engine.dll!TGraphTask<FTickFunctionTask>::ExecuteTask(TArray<FBaseGraphTask *,TSizedDefaultAllocator<32>> & NewTasks, ENamedThreads::Type CurrentThread, bool bDeleteOnCompletion) Line 1267	C++
 	[Inline Frame] UnrealEditor-Core.dll!FBaseGraphTask::Execute(TArray<FBaseGraphTask *,TSizedDefaultAllocator<32>> & CurrentThread, ENamedThreads::Type) Line 868	C++
 	UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksNamedThread(int QueueIndex, bool bAllowStall) Line 758	C++
 	UnrealEditor-Core.dll!FNamedTaskThread::ProcessTasksUntilQuit(int QueueIndex) Line 649	C++
 	[Inline Frame] UnrealEditor-Core.dll!FTaskGraphCompatibilityImplementation::ProcessThreadUntilRequestReturn(ENamedThreads::Type CurrentThread) Line 2071	C++
 	UnrealEditor-Core.dll!FTaskGraphCompatibilityImplementation::WaitUntilTasksComplete(const TArray<TRefCountPtr<FGraphEvent>,TSizedInlineAllocator<4,32,TSizedDefaultAllocator<32>>> & Tasks, ENamedThreads::Type CurrentThreadIfKnown) Line 2126	C++
 	UnrealEditor-Engine.dll!FTickTaskSequencer::ReleaseTickGroup(ETickingGroup WorldTickGroup, bool bBlockTillComplete) Line 556	C++
 	UnrealEditor-Engine.dll!FTickTaskManager::RunTickGroup(ETickingGroup Group, bool bBlockTillComplete) Line 1583	C++
 	UnrealEditor-Engine.dll!UWorld::RunTickGroup(ETickingGroup Group, bool bBlockTillComplete) Line 772	C++
 	UnrealEditor-Engine.dll!UWorld::Tick(ELevelTick TickType, float DeltaSeconds) Line 1640	C++
 	UnrealEditor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 1927	C++
 	UnrealEditor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 529	C++
 	UnrealEditor.exe!FEngineLoop::Tick() Line 5851	C++
 	[Inline Frame] UnrealEditor.exe!EngineTick() Line 61	C++
 	UnrealEditor.exe!GuardedMain(const wchar_t * CmdLine) Line 188	C++
 	UnrealEditor.exe!GuardedMainWrapper(const wchar_t * CmdLine) Line 118	C++
 	UnrealEditor.exe!LaunchWindowsStartup(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow, const wchar_t * CmdLine) Line 258	C++
 	UnrealEditor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * pCmdLine, int nCmdShow) Line 298	C++
 	[External Code]	

Worker thread:

[External Code]	
 	[Inline Frame] UnrealEditor-Engine.dll!Windows::EnterCriticalSection(Windows::CRITICAL_SECTION *) Line 229	C++
 	[Inline Frame] UnrealEditor-Engine.dll!FWindowsCriticalSection::Lock() Line 44	C++
 	[Inline Frame] UnrealEditor-Engine.dll!Chaos::TMutexScopeLock<FWindowsCriticalSection>::{ctor}(FWindowsCriticalSection &) Line 494	C++
>	UnrealEditor-Engine.dll!Chaos::TRwFifoLock<FWindowsCriticalSection>::ReadLock() Line 548	C++
 	[Inline Frame] UnrealEditor-Engine.dll!FScopedSceneLock_Chaos::LockScene() Line 153	C++
 	UnrealEditor-Engine.dll!FScopedSceneLock_Chaos::FScopedSceneLock_Chaos(USkeletalMeshComponent * InSkelMeshComp, EPhysicsInterfaceScopedLockType InLockType) Line 80	C++
 	UnrealEditor-Engine.dll!FPhysInterface_Chaos::ExecuteRead(USkeletalMeshComponent * InMeshComponent, TFunctionRef<void __cdecl(void)> InCallable) Line 520	C++
 	UnrealEditor-Engine.dll!USkeletalMeshComponent::PerformBlendPhysicsBones(const TArray<unsigned short,TSizedDefaultAllocator<32>> & InRequiredBones, TArray<UE::math::TTransform<double>,TSizedDefaultAllocator<32>> & InOutComponentSpaceTransforms, TArray<UE::math::TTransform<double>,TSizedDefaultAllocator<32>> & InOutBoneSpaceTransforms) Line 184	C++
 	[Inline Frame] UnrealEditor-Engine.dll!USkeletalMeshComponent::ParallelBlendPhysics() Line 2479	C++
 	[Inline Frame] UnrealEditor-Engine.dll!FParallelBlendPhysicsTask::DoTask(ENamedThreads::Type) Line 68	C++
 	UnrealEditor-Engine.dll!TGraphTask<FParallelBlendPhysicsTask>::ExecuteTask(TArray<FBaseGraphTask *,TSizedDefaultAllocator<32>> & NewTasks, ENamedThreads::Type CurrentThread, bool bDeleteOnCompletion) Line 1267	C++
 	[Inline Frame] UnrealEditor-Core.dll!FBaseGraphTask::Execute(TArray<FBaseGraphTask *,TSizedDefaultAllocator<32>> &) Line 868	C++
 	[Inline Frame] UnrealEditor-Core.dll!FTaskGraphCompatibilityImplementation::QueueTask::__l5::<lambda>() Line 1973	C++
 	UnrealEditor-Core.dll!LowLevelTasks::FTask::Init::__l11::<lambda>(const bool bNotCanceled) Line 499	C++
 	[Inline Frame] UnrealEditor-Core.dll!Invoke(LowLevelTasks::FTask::Init::__l11::void <lambda>(void) &) Line 47	C++
 	[Inline Frame] UnrealEditor-Core.dll!LowLevelTasks::TTaskDelegate<LowLevelTasks::FTask * __cdecl(bool),48>::TTaskDelegateImpl<`LowLevelTasks::FTask::Init<`FTaskGraphCompatibilityImplementation::QueueTask'::`5'::void <lambda>(void)>'::`11'::void <lambda>(void),0>::Call(void *) Line 162	C++
 	UnrealEditor-Core.dll!LowLevelTasks::TTaskDelegate<LowLevelTasks::FTask * __cdecl(bool),48>::TTaskDelegateImpl<`LowLevelTasks::FTask::Init<`FTaskGraphCompatibilityImplementation::QueueTask'::`5'::void <lambda>(void)>'::`11'::void <lambda>(void),0>::CallAndMove(LowLevelTasks::TTaskDelegate<LowLevelTasks::FTask * __cdecl(bool),48> & Destination, void * InlineData, unsigned int DestInlineSize, bool <Params_0>) Line 171	C++
 	[Inline Frame] UnrealEditor-Core.dll!LowLevelTasks::TTaskDelegate<LowLevelTasks::FTask * __cdecl(bool),48>::CallAndMove(LowLevelTasks::TTaskDelegate<LowLevelTasks::FTask * __cdecl(bool),48> &) Line 308	C++
 	UnrealEditor-Core.dll!LowLevelTasks::FTask::ExecuteTask() Line 627	C++
 	UnrealEditor-Core.dll!LowLevelTasks::FScheduler::ExecuteTask(LowLevelTasks::FTask * & InOutTask) Line 150	C++
 	UnrealEditor-Core.dll!LowLevelTasks::FScheduler::TryExecuteTaskFrom<LowLevelTasks::TLocalQueueRegistry<1024>::TLocalQueue,&LowLevelTasks::TLocalQueueRegistry<1024>::TLocalQueue::DequeueGlobal,0>(LowLevelTasks::TLocalQueueRegistry<1024>::TLocalQueue * Queue, LowLevelTasks::TLocalQueueRegistry<1024>::FOutOfWork & OutOfWork, bool bPermitBackgroundWork, bool bDisableThrottleStealing) Line 350	C++
 	UnrealEditor-Core.dll!LowLevelTasks::FScheduler::WorkerMain(LowLevelTasks::FSleepEvent * WorkerEvent, LowLevelTasks::TLocalQueueRegistry<1024>::TLocalQueue * WorkerLocalQueue, unsigned int WaitCycles, bool bPermitBackgroundWork) Line 378	C++
 	[Inline Frame] UnrealEditor-Core.dll!LowLevelTasks::FScheduler::CreateWorker::__l2::<lambda>() Line 70	C++
 	[Inline Frame] UnrealEditor-Core.dll!Invoke(LowLevelTasks::FScheduler::CreateWorker::__l2::void <lambda>(void) &) Line 47	C++
 	UnrealEditor-Core.dll!UE::Core::Private::Function::TFunctionRefCaller<`LowLevelTasks::FScheduler::CreateWorker'::`2'::void <lambda>(void),void __cdecl(void)>::Call(void * Obj) Line 480	C++
 	[Inline Frame] UnrealEditor-Core.dll!UE::Core::Private::Function::TFunctionRefBase<UE::Core::Private::Function::TFunctionStorage<1>,void __cdecl(void)>::operator()() Line 629	C++
 	UnrealEditor-Core.dll!FThreadImpl::Run() Line 69	C++
 	UnrealEditor-Core.dll!FRunnableThreadWin::Run() Line 149	C++
 	UnrealEditor-Core.dll!FRunnableThreadWin::GuardedRun() Line 79	C++
 	[External Code]	
Steps to Reproduce

This seems to be very rare; one of our designers got it because her PC was spending a lot of time rebuilding assets while she was playing in PIE, and I managed to repro it only after I cleared my DDC.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-195356 in the post.

3
Login to Vote

Unresolved
ComponentUE - Simulation - Physics
Affects Versions5.3
Target Fix5.5
CreatedSep 13, 2023
UpdatedFeb 27, 2024