Description

When a GameplayEffect (GE) grants an GameplayAbility (GA) via an AbilitiesGameplayEffectComponent on the GE, that ability will not be correctly removed if that GE is added and removed within an AbilityListScopeLock, for example during the activation of another ability. What currently happens:

  • The GE's granted GA is added to the AbilitySystemComponent's AbilityPendingAdds (due to being in an ability list scope lock)
  • If the GE is removed immediately, i.e. before exiting the ability list scope lock, the GA is still in AbilityPendingAdds by the end of executing the GE removal
    • ASC->AbilityPendingAdds is not checked by FActiveGameplayEffectsContainer::RemoveActiveGameplayEffectGrantedTagsAndModifiers() which is the place to handle such cleanup
  • The GA is then added when exiting the AbilityListScopeLock due to being in ASC->AbilityPendingAdds, even if the GE that granted it may no longer be active

This results in abilities that incorrectly remain on the ASC if the granting GE is added-removed quickly.

 

Steps to Reproduce
  • Create a GameplayAbility GA_Test
  • Create a GameplayEffect GE_Test
  • In GE_Test add an AbilitiesGameplayEffectComponent
    • In that component add an entry to GrantAbilityConfigs to add GA_Test
    • Set it's removal policy to anything other than DoNothing
  • Create another GameplayAbility GA_TestGranter
  • In GA_TestGranter's ActivateAbility implementation:
    • Resolve the owning AbilitySystemComponent
    • Call ASC->ApplyGameplayEffectToSelf and apply GE_Test, and remove it immediately by handle via ASC->RemoveActiveGameplayEffect(Handle)
  • In the character BP, add a debug key to GiveAbilityAndActivate GA_TestGranter
  • Press that debug key in PIE
  • Observe:
    • An error is logged: LogAbilitySystem: Error: OnGiveAbility Spec '(Default__GA_Test_C)' GameplayEffectHandle had invalid Owning Ability System Component
    • If you call AbilitySystemComponent->GetAllAbilities(Abils), you'll see that GA_Test is still in the ability list, even though it should have been removed when its granting GE was removed.
  • Expected:
    • No error message in log
    • GA_Test should no longer be in the ASC's abilities list, since its granting GE was removed.

Have Comments or More Details?

There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-201125 in the post.

13
Login to Vote

Unresolved
CreatedNov 23, 2023
UpdatedSep 30, 2024
View Jira Issue