Any custom track with track instance inside UMG animation can lead to memory leak.
This leak is caused by TrackInstances variable inside UMovieSceneTrackInstanceInstantiator not being correctly freed during tear down of sequence instance.
It doesn’t reproduce for Camera Cuts Track Instance, but as far as I understand it can happen with level sequences too if actor ends play while sequence is playing and it is in evaluation state(there is additional condition because for actors Stop is called before tear down and it correctly finishes sequence if it is not evaluated rn).
We’ve solved it with overriding OnCleanTaggedGarbage in UMovieSceneTrackInstanceInstantiator and clearing TrackInstances for which TrackInstanceInput’s have NeedsUnlink
Steps to Reproduce
- Create a Custom Track with Custom Track Instance to use in umg animations
- Create widget with animation containing this custom track
- Spawn widget + launch animation
- Despawn widget before animation finished
Or you can launch attached project where everything is setuped
- Play LVL_Strategy
- Click “1” to spawn widget and play animation
- Click “2” to despawn widget before animation ended(There is text block that changes opacity)
Result:
Binded object is referenced indefinitely in UMovieSceneTrackInstanceInstantiator via AddReferencedObjects.
Hi! Thanks for the report and the detailed description. I tried reproducing the bug but maybe I missed something… I ran your sample project (thanks for that!), ran PIE in LVL_Strategy, pressed 1, saw the text block, pressed 2 soon after, and then put a breakpoint inside `UMovieSceneTrackInstanceInstantiator::AddReferencedObjects`. Both TrackInstances and BoundObjectToInstances were empty and no object was added to the collector… am I missing something?
Hello!
It is already referenced when you press 2. I’ve added ensure in custom track that checks whether input is connected with valid sequence or not (you can click 1 one more time and it will trigger because System will start running again and try to process invalid inputs that are being held), with the help of it you can look into the state of UMovieSceneTrackInstanceInstantiator.
Or you can just use your breakpoint but it requires clicking 1 again, and there will be 2 inputs first referencing widget with destroyed slate and second referencing newly created.
Sorry for missing this second part of reproduction in initial message
I can’t debug engine for this attached project properly because it’s created with UE from EGS Launcher.
But I can revert our fix and share screenshots of state inside our project to show what I mean.
UPD: Added screenshot
UPD: Actual leak isn’t reproducing in attached project only ensure sorry for misleading. Trying to get actual reproduction steps[Image Removed]
It can be reproduced in this project.
If I understood correctly it’s actually referencing not indefinitely but while there is any track instance animation playing.
Once ALL animations with track instances finish widgets being freed correctly(but sometimes widgets leak like in attached logs, couldn’t find accurate steps for this).
Ah, great, thanks! I got it and I understand what’s going on. We’ll try to put the fix in for 5.7, or at least 5.7.1. Thanks again for the sample project and detailed repro steps, it helps a lot.
Added updated project and more steps