Ensure condition failed: bPlayingBackwards ? (CurrentPosition <= PreviousPosition) : (CurrentPosition >= PreviousPosition)

**Ensure condition failed: bPlayingBackwards ? (CurrentPosition <= PreviousPosition) : (CurrentPosition >= PreviousPosition) [File:D:\build\++UE5\Sync\Engine\Source\Runtime\Engine\Private\Animation\AnimSequence.cpp] [Line: 1424]**

Can someone help me? I have a Default state machine with two Sequence states. Each state plays an animation using a SequencePlayer. I control the state transitions and blending through code, but occasionally I get an error. It’s not a consistent issue, but it happens quite frequently. Does this issue relate to how I control the animation playback through code? How can I fix it?

void UBaseAnimInstance::TransitionState()
{
	auto stateMachineIndex=GetStateMachineIndex("Default");
	const FAnimNode_StateMachine* constStateMachine=GetStateMachineInstance(stateMachineIndex);
	FAnimNode_StateMachine* stateMachine = const_cast<FAnimNode_StateMachine*>(constStateMachine);
	auto curStateIndex=stateMachine->GetStateIndex(m_isPlaySequence1?"Sequence2":"Sequence1");
	auto targetStateIndex=stateMachine->GetStateIndex(m_isPlaySequence1?"Sequence1":"Sequence2");
	FAnimationUpdateSharedContext SharedContext;
	FAnimationUpdateContext ContextTemp(GetProxyOnGameThreadStatic<FAnimInstanceProxy>(this), GetDeltaSeconds(), &SharedContext);
	FAnimationTransitionBetweenStates TransitionInfoTemp;
	TransitionInfoTemp.PreviousState = curStateIndex;
	TransitionInfoTemp.NextState = targetStateIndex;
	TransitionInfoTemp.CrossfadeDuration = m_blendOutTime;
	TransitionInfoTemp.BlendMode = EAlphaBlendOption::CubicInOut;
	TransitionInfoTemp.CustomCurve = nullptr;
	TransitionInfoTemp.BlendProfile = nullptr;
	TransitionInfoTemp.LogicType = ETransitionLogicType::TLT_StandardBlend;
	const FAnimationTransitionBetweenStates& TransitionInfo = TransitionInfoTemp;
	const FAnimationUpdateContext& Context = ContextTemp;
	stateMachine->TransitionToState(Context,TransitionInfo);
}