Crash when using OnPlayMontageNotifyBegin. Engine BUG?

Hey guys, I need to use the OnPlayMontageNotifyBegin delegate that the AnimInstance provides. Unluckily, it is crashing/stalling when using it in conjunction FOnMontageEnded. I’ve used it without the FOnMontageEnded delegate and apparently it works. Here is the code I am currently using:

if (UAnimInstance* AnimInstance = GetMesh()->GetAnimInstance())
        FOnMontageEnded EndDelegate;
        EndDelegate.BindUObject(this, &ABaseCharacter::OnMontageEnded);
        AnimInstance->Montage_SetEndDelegate(EndDelegate, Montage);

		AnimInstance->OnPlayMontageNotifyBegin.AddDynamic(this, &ABaseCharacter::OnAnimNotifyBegin);	

The line that throws the exception is on the ScriptDelegates.h, line 554. Apparently the InDelegate that the AddInternal function takes is not the same as the one in the InvocationList array. But I compared both objects (memory address and values) and they’re all exactly the same. It crashes anyways. I would like to mention that all functions are declared and defined fitting the delegate structure and also using UFUNCTION().

Besides of that I’ve been doing some tests with no luck.

1.- Using OnPlayMontageNotifyBegin without FOnMontageEnded :white_check_mark: (But I need both to work lmao)
2.- Declaring FOnMontageEnded EndDelegate as class member instead of local variable :x:
3.- Swap NotifyDelegate and MontageEnded bind orders :x:
4.- Using AnimInstance->Montage_SetEndDelegate with and without Montage parameter :x:

One last thing to mention, Unreal uses all delegates successfully in its BP node PlayMontage, you can find the function on PlayMontageCallbackProxy.cpp, line 29. I’m doing exactly the same, but no luck. The issue can be replicated across these versions as far as I’ve tested, 4.25.4 and 4.26.2.

Hope we can solve this issue guys, it’s been many days of headaches…

I found the solution. It seems that using AddUniqueDynamic instead of AddDynamic made it work.
I made sure I was only binding the delegate once, so not sure if the engine did something underneath. Anyway here is the code that works just in case someone encounters this issue:

AnimInstance->OnPlayMontageNotifyBegin.AddUniqueDynamic(this, &ABaseCharacter::OnAnimNotifyBegin);