Description

We recently had a few occurrences of crashes caused by a "Fatal world leaks detected" error when unloading a level (in a packaged game and in editor).

I tracked down what was keeping a references to a uobject preventing the world to be GCed and it led me to the sequencer, a TStrongObjectPtr was still holding a reference to an animation blueprint. The pointer was assigned by OutCachedValue.CachedAnimInstance.Reset(Component->AnimScriptInstance); in FPreAnimatedSkeletalAnimationTraits::CachePreAnimatedValue() but FPreAnimatedSkeletalAnimationTraits::RestorePreAnimatedValue was never called even though the sequence had stopped playing.

It turns out that this issue happen in some very specific conditions. I've put some details in the repro steps and project, but the main factors are the following:

  • a level sequence plays an animation on a skeletal mesh's animation blueprint
  • it also spawns an actor that plays a second sequence (through an actor sequence component in our case)

What happens is that when the main sequence stops:

  • FMovieSceneEntitySystemRunner::QueueFinalUpdate() and then FMovieSceneEntitySystemRunner::FlushOutstanding() is called
  • During the ERunnerFlushState::Import phase, in FSequenceInstance::Finish(), a call to Ledger.UnlinkEverything(Linker) adds a NeedsUnlink component to the sequence's entities.
  • Further in the same Finish() function, a call to SpawnRegister->CleanUp() does a DestroyObjectsByPredicate() and destroys spawned actors
  • When the spawned actors gets destroyed, in our case UActorSequenceComponent::EndPlay is called and the playing sequence is stopped
  • In SequencePlayer->TearDown(), UMovieSceneEntitySystemLinker::CleanGarbage() endup being called
  • In UMovieSceneEntitySystemLinker::CleanGarbage(), a EntityManager.FreeEntities() is done on all entities with a *NeedsUnlink *component, thus wiping the work that was done in the Import phase
  • Later in the Instantiation phase, UMovieSceneRestorePreAnimatedStateSystem::OnRun() won't find any entities with the *NeedsUnlink *component to cleanup so RestorePreAnimatedValue() won't be called
Steps to Reproduce

Steps to Reproduce

In the provided repro project, just open the Level, hit play in editor, and the crash should happen after 2 seconds.

<p> 
</p>

The main elements to trigger the issue are the following:

<p> 
</p>

  • [BP_SpawnedByLevelSequence] A blueprint with an actor sequence component set to auto run (but I'm pretty sure that starting and stopping a classic level sequence in the beginplay / endplay of the BP instead of using the component would do the same)
  • [BP_SkeletalMesh] A character BP with a skeletal mesh animated with an animation blueprint [ABP_SkeletalMesh]
  • [LevelSequence] A level sequence actor placed in the level is playing this sequence. The important bits of this sequence are:
  • It possesses BP_SkeletalMesh placed in the level and plays an animation in one of its slots
  • It spawns a BP_SpawnedByLevelSequence (that will also play its own sequence)
  • [Level] In the level blueprint the OpenLevel is called after 2 seconds to unload the world and trigger a GC
Callstack

> [Inline Frame] UnrealEditor-Core.dll!UE::Logging::Private::BasicFatalLog::__l2::<lambda>() Line 1103 C++
UnrealEditor-Core.dll!UE::Logging::Private::BasicFatalLog(const FLogCategoryBase & Category, const UE::Logging::Private::FStaticBasicLogRecord * Log, ...) Line 1103 C++
UnrealEditor-CoreUObject.dll!FReferenceChainSearch::FindAndPrintStaleReferencesToObjects(TArrayView<UObject * const,int> ObjectsToFindReferencesTo, EPrintStaleReferencesOptions Options) Line 2038 C++
UnrealEditor-CoreUObject.dll!FReferenceChainSearch::FindAndPrintStaleReferencesToObject(UObject * ObjectToFindReferencesTo, EPrintStaleReferencesOptions Options) Line 1895 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::CheckAndHandleStaleWorldObjectReferences(FWorldContext * InWorldContext) Line 5750 C++
UnrealEditor-Engine.dll!UEngine::LoadMap(FWorldContext & WorldContext, FURL URL, UPendingNetGame * Pending, FString & Error) Line 15693 C++
UnrealEditor-Engine.dll!UEngine::Browse(FWorldContext & WorldContext, FURL URL, FString & Error) Line 15154 C++
UnrealEditor-Engine.dll!UEngine::TickWorldTravel(FWorldContext & Context, float DeltaSeconds) Line 15352 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 2114 C++
UnrealEditor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 550 C++
UnrealEditor.exe!FEngineLoop::Tick() Line 5877 C++
[Inline Frame] UnrealEditor.exe!EngineTick() Line 69 C++
UnrealEditor.exe!GuardedMain(const wchar_t * CmdLine) Line 188 C++
UnrealEditor.exe!LaunchWindowsStartup(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow, const wchar_t * CmdLine) Line 266 C++
UnrealEditor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * pCmdLine, int nCmdShow) Line 317 C++
[Inline Frame] UnrealEditor.exe!invoke_main() Line 102 C++
UnrealEditor.exe!__scrt_common_main_seh() Line 288 C++
kernel32.dll!00007ff8734d259d() Unknown
ntdll.dll!00007ff87530af38() Unknown

Have Comments or More Details?

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

0
Login to Vote

Unresolved
ComponentUE - Anim - Sequencer
Affects Versions5.5
Target Fix5.7
CreatedMay 14, 2025
UpdatedMay 26, 2025
View Jira Issue