Sequencer Crash (GC Leak) in Editor (similar to 44483919)

A GC leak, similar to the one fixed by 44483919 but for Level Sequences in Level Instances rather than ones with Widgets.

A Level Sequence Actor in a Level Instance points to a Level Sequence Asset that has an Event Track that creates the Director when scrubbed over. If Sequencer is open at the same time as the Level Instance is open for edit, a strong reference is created to the Director which uses the Level Sequence Actor in the Level Instance as its outer. When the Level Instance is closed, the level is kept alive by sequencer. Tearing down the level triggers GC which finds the leak and fatal errors.

Steps to Reproduce (sample project provided)

  • New blank project
  • New Basic World (/Game/BasicWorld)
  • New Empty World (/Game/EmptyWorld)
  • Add the Basic World as a level instance to the Empty World
  • Edit the Basic World level instance and add a Level Sequence Acotr
  • Create a level sequence asset for the player (/Game/LevelSequenceWithDirector)
  • Add an event track to the sequence
  • Add a key to the event track and double-click it to open the Director Blueprint
  • I added a PrintString node just to give it something substantial.
  • Compile and save and close the Director Blueprint editor
  • Save everything (because we’re about to crash)
  • Open Sequencer and scrub over the event to create the Director.
  • “Cancel” the level instance edit
  • Crash

[Attachment Removed]

Steps to Reproduce

  • New blank project
  • New Basic World (/Game/BasicWorld)
  • New Empty World (/Game/EmptyWorld)
  • Add the Basic World as a level instance to the Empty World
  • Edit the Basic World level instance and add a Level Sequence Acotr
  • Create a level sequence asset for the player (/Game/LevelSequenceWithDirector)
  • Add an event track to the sequence
  • Add a key to the event track and double-click it to open the Director Blueprint
  • I added a PrintString node just to give it something substantial.
  • Compile and save and close the Director Blueprint editor
  • Save everything (because we’re about to crash)
  • Open Sequencer and scrub over the event to create the Director.
  • “Cancel” the level instance edit
  • Crash
    [Attachment Removed]

I resolved this by performing similar clear down to FLevelEditorSequencerIntegration::OnMapChanged() but in FLevelEditorSequencerIntegration::OnLevelRemoved()

void FLevelEditorSequencerIntegration::OnLevelRemoved(ULevel* InLevel, UWorld* InWorld)
{
	IterateAllSequencers(
		[](FSequencer& In, const FLevelEditorSequencerIntegrationOptions& Options)
		{
			if (Options.bRequiresLevelEvents)
			{
				In.GetEvaluationState()->ClearObjectCaches(In);
 
// START EDIT
				// Mirror TearDownWorld cleanup from OnMapChanged()
				In.OnPlaybackContextChanged();
				In.RestorePreAnimatedState();
				In.NotifyMovieSceneDataChanged(EMovieSceneDataChangeType::Unknown);
// END EDIT
			}
		}
	);
}

[Attachment Removed]

Hey there,

Thanks for raising this and for your fix idea. I’ve logged an issue here that you can follow. https://issues.unrealengine.com/issue/UE-394309

Your change makes sense, and I would leave that locally for now. We may do something slightly different, but follow the issue to find out if that is the case.

Dustin

[Attachment Removed]