Could this go to Melyssa Battison please, cc Mieszko Zielinski? It is in the instanced skinned mesh update in UMassVisualizationComponent.
When an entity stops being batched into an instanced skinned mesh component, the “Collect unwanted items & remove” sweep removes its instance, but never frees its ASTP track. Only ProcessRemovesForComponent calls DeallocateTrack, and outside the stationary ISM switcher and its destructor nothing in MassRepresentation calls RemoveInstance. So for a moving entity the sweep is the only way out of a component, and every despawn, LOD change or significance range change leaves a track behind.
The leaked track stays active, so it is still uploaded every frame, and it keeps its last sequence index. Once that sequence is released with DeallocateSequence, the ensure fires and the track is left pointing at a freed slot.
This is the non-external-ID path. The sweep is the same in //UE5/Main MassVisualizationComponent.cpp#74 (around line 951) and //UE6/Main #12 (around line 1069). We are on 5.8 with 57928894 and 58169258 cherry-picked from UE5/Main, which is where AllocateSequence and DeallocateSequence come from.
Locally I made the sweep free the track the same way ProcessRemovesForComponent does:
if (SharedIdMap.ContainsElementId(ElementId))
{
FPrimitiveInstanceId InstanceId = SharedIdMap.GetByElementId(ElementId).Value;
check(InstanceId.IsValid());
const FMassEntityHandle SweptEntity = SharedIdMap.GetByElementId(ElementId).Key;
const Experimental::FHashElementId TrackElementId = TrackMap.FindId(SweptEntity);
if (TrackElementId.IsValid())
{
if (UAnimSequenceTransformProviderDataInstance* ASTPDI = Cast<UAnimSequenceTransformProviderDataInstance>(InstancedSkinnedMeshComponent->GetTransformProvider()))
{
ASTPDI->DeallocateTrack(TrackMap.GetByElementId(TrackElementId).Value);
}
TrackMap.RemoveByElementId(TrackElementId);
const Experimental::FHashElementId AnimStateId = ResolvedAnimStates.FindId(SweptEntity);
if (AnimStateId.IsValid())
{
ResolvedAnimStates.RemoveByElementId(AnimStateId);
}
}
SharedIdMap.RemoveByElementId(ElementId);
RemovedInstancedSkinnedMeshInstanceIds.Add(InstanceId);
}
With that in, plus a fix to our own batching, we no longer hit the ensure in a cooked Development build, with sequences freed after a 1 second grace period.
Is that how you would want it fixed, or would you rather the sweep go through ProcessRemovesForComponent?
We will take whatever lands upstream and drop ours.
Also, a smaller ask. The update path reads InstanceAnimationData[IDIndex] in step with EntitiesRequiringUpdate, so a caller that calls AddBatchedAnimationData for only some of the entities it batches transforms for silently shifts every later entity onto its neighbour’s animation.
That one was our bug, but an ensure that the animation array is either empty or the same length as the transforms would have caught it straight away.
Here is the ensure callstack:
ensureMsgf(Pool.GetData(TrackIndex).GetSequenceIndex() != SlotIndex, TEXT("ASTP: sequence slot %d released while set on track %d layer %d"), ...)
UAnimSequenceTransformProviderDataInstance::DeallocateSequence::<lambda_1>()
UAnimSequenceTransformProviderDataInstance::DeallocateSequence()
<game code releasing a runtime-allocated sequence once no entity references it>
FMassProcessingPhase::OnParallelExecutionDone()
...
UWorld::Tick()
[Attachment Removed]