Hi there,
I’m currently working in a project where we get a consistent crash during level unloading.
For the purposes of this explanation there are 3 levels and 2 interactive actor blueprint objects.
Level A) Interactive Object level
Level B) Player Level
Level C) New Level
Object A) Puzzle piece
Object B) Target Puzzle
Player level contains a blueprint based off the UE4 VR Template. Upon begin play, level A and B are loaded.
During the gameplay, player uses the VR motion controllers to pickup an interactive object A from Level A - this means it will be parented to the motion controller hands in Level B. The user then uses their other hand to pick up interactive object B. When interactive object A overlaps with a box collision in interactive object B, A snaps to a location on interactive object B using the correct parenting and welding. The reference to the object is then removed from the hand that the object is removed from.
The user then places Object B back into the world, removing it’s reference from the corresponding hand.
After a certain amount of time (based on level sequencer) the next level will begin loading.
The new level (Level C) is loaded first, and then Level A is told to unload.
During level A’s unload, the editor crashes whilst trying to Unregister all components.
BodySetup.cpp line 2054 is the next statement to be executed. To me this indicates a problem with the previous line. I’m not entirely sure what is causing the issue, but here is the full call stack.
> UE4Editor-Engine.dll!UBodySetup::GetCollisionTraceFlag() Line 2054 C++
UE4Editor-Engine.dll!FBodyInstance::UpdatePhysicsShapeFilterData::__l2::<lambda>() Line 989 C++
UE4Editor-Engine.dll!FBodyInstance::ExecuteOnPhysicsReadWrite(TFunctionRef<void __cdecl(void)> Func) Line 3402 C++
UE4Editor-Engine.dll!FBodyInstance::UpdatePhysicsShapeFilterData(unsigned int ComponentID, bool bPhysicsStatic, const TEnumAsByte<enum ECollisionEnabled::Type> * CollisionEnabledOverride, FCollisionResponseContainer * ResponseOverride, bool * bNotifyOverride) Line 1063 C++
UE4Editor-Engine.dll!FBodyInstance::UpdatePhysicsFilterData() Line 1214 C++
UE4Editor-Engine.dll!FBodyInstance::UnWeld::__l2::<lambda>() Line 2394 C++
UE4Editor-Engine.dll!FBodyInstance::ExecuteOnPhysicsReadWrite(TFunctionRef<void __cdecl(void)> Func) Line 3402 C++
UE4Editor-Engine.dll!FBodyInstance::UnWeld(FBodyInstance * TheirBI) Line 2400 C++
UE4Editor-Engine.dll!UPrimitiveComponent::UnWeldFromParent() Line 847 C++
UE4Editor-Engine.dll!UPrimitiveComponent::UnWeldChildren() Line 899 C++
UE4Editor-Engine.dll!UPrimitiveComponent::OnDestroyPhysicsState() Line 699 C++
UE4Editor-Engine.dll!UStaticMeshComponent::OnDestroyPhysicsState() Line 644 C++
UE4Editor-Engine.dll!UActorComponent::DestroyPhysicsState() Line 1225 C++
UE4Editor-Engine.dll!UActorComponent::ExecuteUnregisterEvents() Line 1254 C++
UE4Editor-Engine.dll!UActorComponent::UnregisterComponent() Line 1050 C++
UE4Editor-Engine.dll!AActor::UnregisterAllComponents(bool bForReregister) Line 4011 C++
UE4Editor-Engine.dll!ULevel::IncrementalUnregisterComponents(int NumComponentsToUnregister) Line 988 C++
UE4Editor-Engine.dll!UWorld::RemoveFromWorld(ULevel * Level, bool bAllowIncrementalRemoval) Line 2270 C++
UE4Editor-Engine.dll!UWorld::UpdateLevelStreamingInner(ULevelStreaming * StreamingLevel) Line 2803 C++
UE4Editor-Engine.dll!UWorld::UpdateLevelStreaming() Line 2846 C++
UE4Editor-Engine.dll!UGameViewportClient::Draw(FViewport * InViewport, FCanvas * SceneCanvas) Line 1223 C++
UE4Editor-Engine.dll!FViewport::Draw(bool bShouldPresent) Line 1198 C++
UE4Editor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 1853 C++
UE4Editor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 402 C++
UE4Editor.exe!FEngineLoop::Tick() Line 3215 C++
UE4Editor.exe!GuardedMain(const wchar_t * CmdLine, HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, int nCmdShow) Line 166 C++
UE4Editor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow) Line 199 C++
UPDATE: We’ve managed to get around it by manually unparenting the offending objects prior to level unload. The bug should still be reported for fixing in the future.
UPDATE 2: Turns out it is still crashing, our test post change hadn’t been reproduced properly.