Hi, I’ve been trying to fix this myself for days and it’s beginning to drive me insane…
I will try to stick to the essential information and not write an essay here right from the start. If you need more info, I’m glad to provide it.
My setup is this: a landscape with about 100 vs 100 characters killing each other. My testing arsenal contains bows, magic and melee weapons at the moment. No problems with the ranged stuff, but melee weapons tend to break the game completely. My melee implementation is based on “manual” sweeping from the weapons Tick function to determine if the weapon hits something in a given frame.
After lots of testing I can say that the bug happens only when characters are going (or have already gone?) ragdoll. Without dead characters turning into ragdolls there is no bug.
So it usually happens a while after the two groups have clashed and there are already corpses on the ground. Then suddenly the game/editor freezes and after half a minute or so I get this error:
LogCore:Error: ConvertQueryImpactHit() received NaN/Inf for position: -nan(ind) -nan(ind) -nan(ind)
After that the game continues, but the whole physics/collision part is broken somehow. Projectiles (arrows and magic) suddenly don’t hit the ground anymore but fall through it. Melee sweeps start hitting their carrier instantly on performing an attack even though that carrier is supposed to be ignored during the sweeps. On top of that the console gets spammed with more error messages looking like this:
LogCollision:Error: GeomSweepSingle resulted in a NaN/INF in PHit!
The frame rate also drops significantly after the initial error, probably because of the console spam that follows it. After the first 50 (+/-) times the message above got spammed, there is this section about a broken bounding box:
LogOutputDevice:Warning: === Handled error: === Ensure condition failed: !Primitive->Bounds.BoxExtent.ContainsNaN() && !Primitive->Bounds.Origin.ContainsNaN() && !FMath::IsNaN(Primitive->Bounds.SphereRadius) && FMath::IsFinite(Primitive->Bounds.SphereRadius) [File:D:\Build\++UE4+Release-4.12+Compile\Sync\Engine\Source\Runtime\Renderer\Private\RendererScene.cpp] [Line: 800] Nans found on Bounds for Primitive CharacterMesh0: Origin X=-nan(ind) Y=-nan(ind) Z=-nan(ind), BoxExtent X=nan Y=nan Z=nan, SphereRadius -nan(ind) Stack: UE4Editor-Core.dll!FWindowsPlatformStackWalk::StackWalkAndDump() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\core\private\windows\windowsplatformstackwalk.cpp:183] UE4Editor-Core.dll!FDebug::EnsureFailed() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\core\private\misc\outputdevice.cpp:327] UE4Editor-Core.dll!FDebug::OptionallyLogFormattedEnsureMessageReturningFalse() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\core\private\misc\outputdevice.cpp:451] UE4Editor-Renderer.dll!FScene::UpdatePrimitiveTransform() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\renderer\private\rendererscene.cpp:799] UE4Editor-Engine.dll!UPrimitiveComponent::SendRenderTransform_Concurrent() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\components\primitivecomponent.cpp:383] UE4Editor-Engine.dll!UActorComponent::DoDeferredRenderUpdates_Concurrent() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\components\actorcomponent.cpp:1251] UE4Editor-Engine.dll!<lambda_1c27e0d8d47d1db9d2f7e512dcaa630c>::operator()() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\leveltick.cpp:857] UE4Editor-Engine.dll!ParallelForWithPreWork() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\core\public\async\parallelfor.h:214] UE4Editor-Engine.dll!UWorld::SendAllEndOfFrameUpdates() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\leveltick.cpp:871] UE4Editor-Renderer.dll!FRendererModule::BeginRenderingViewFamily() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\renderer\private\scenerendering.cpp:1998] UE4Editor-Engine.dll!UGameViewportClient::Draw() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\gameviewportclient.cpp:1096] UE4Editor-Engine.dll!FViewport::Draw() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\engine\private\unrealclient.cpp:1149] UE4Editor-UnrealEd.dll!UEditorEngine::Tick() [d:\build\++ue4+release-4.12+compile\sync\engine\source\editor\unrealed\private\editorengine.cpp:1531] UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick() [d:\build\++ue4+release-4.12+compile\sync\engine\source\editor\unrealed\private\unrealedengine.cpp:368] UE4Editor.exe!FEngineLoop::Tick() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\launch\private\launchengineloop.cpp:2775] UE4Editor.exe!GuardedMain() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\launch\private\launch.cpp:148] UE4Editor.exe!GuardedMainWrapper() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:126] UE4Editor.exe!WinMain() [d:\build\++ue4+release-4.12+compile\sync\engine\source\runtime\launch\private\windows\launchwindows.cpp:200] UE4Editor.exe!__scrt_common_main_seh() [f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:264] kernel32.dll ntdll.dll ntdll.dll LogStats: SubmitErrorReport - 0.000 s LogStats: SendNewReport - 7.685 s LogStats: FDebug::EnsureFailed - 25.510 s
And after that,
LogCollision:Error: GeomSweepSingle resulted in a NaN/INF in PHit!
keeps spamming on indefinitely.
After using the debugger, I think what happens is that a ragdoll’s head-bone gets an invalid location for some reason, which then causes the character-mesh’s bounds to become invalid as well. Maybe the broken physics behavior afterwards are caused by some shape(s) becoming infinitely big or something?.. I don’t know, if other bone-transforms can become NaN (whatever that actually means) as well. So far I’ve only seen it happening to the head.
And something really weird: I can’t be 100% sure this is not some coincidence, but it looks very much like the bug stops happening when I use this line:
UE_LOG(MyLog, Warning, TEXT("sweep hit (%i): %s, %s, %s, %s, %s, %s, %s, %f, %s"), j, *Carrier->GetName(), *GetName(), *allHits[j].Actor->GetName(), *allHits[j].Component->GetName(), *allHits[j].BoneName.ToString(), *allHits[j].ImpactPoint.ToString(), *allHits[j].Location.ToString(), allHits[j].Time, (allHits[j].Time == 0.f) ? TEXT(" - INITIAL") : TEXT(""))
after every melee-sweep to display info about it. I thought I might find some hint what’s causing the problem, but instead that line seems to fix it or at least reduces the chance for it to happen drastically. So, since that line doesn’t actually “do” anything other than read some values and log them to the console, I can only imagine that the delay it causes somehow prevents the bug. The sweeping code takes 0 to 1 ms without the UE_LOGs, and something from 5 to 15 with the UE_LOGs.
Does this make any sense to anyone? Please help fix this properly! I can’t just spam the console or create any artificial delays inside my code and hope that the problem is solved without having an idea what’s going on…