Description

We're on 4.25.4. We recently turned on mixed mode replication for GAS, which seems to work fine and reduce bandwidth as expected. However one of our unit tests started failing with this error message:

 FMinimapReplicationTagCountMap::RemoveTag called on Tag GameplayEffect.Weapon.Equip.Primary and count is now < 0

 Upon investigating, the case in question has a gameplay effect GE_Common_WeaponEquipPrimary being added via ApplyGameplayEffectToSelf which during UpdateTagMap_Internal activates an ability which adds another gameplay effect GE_Common_WeaponEquippedPrimary. The GE_Common_WeaponEquipPrimary effect is added and removed immediately, which leaves the GE_Common_WeaponEquippedPrimary effect on the character.

 I attached the callstack where the error "count is now < 0" appears. The problem is in the order in which updates to MinimalReplicationTags are applied via calls to AddTag/RemoveTag:

 AddTag(GameplayEffect.Weapon.Equipped.Primary)

RemoveTag(GameplayEffect.Weapon.Equip.Primary)

(outputs error about "FMinimapReplicationTagCountMap::RemoveTag called on Tag GameplayEffect.Weapon.Equip.Primary and count is now < 0", because the next AddTag hasn't happened yet

AddTag(GameplayEffect.Weapon.Equip.Primary)

 

The order above is attempting to remove a GE which has not been applied yet.

 I believe the problem is in FActiveGameplayEffectsContainer::AddActiveGameplayEffectGrantedTagsAndModifiers, where the UpdateTagMap calls happens before the minimal tags have the correct counts. Since UpdateTagMap dispatches arbitrary gameplay code, the minimal tag counts must be correct prior to this call so I've changed the order of operations:

// Update the MinimalReplicationTags counts prior to calling UpdateTagMap, since it can call other gameplay logic (such as 	
// adding secondary GEs) which requires the MinimalReplicationTags counts be correct.	

if (ShouldUseMinimalReplication())	
{
	Owner->AddMinimalReplicationGameplayTags(Effect.Spec.Def>InheritableOwnedTagsContainer.CombinedTags);
	Owner->AddMinimalReplicationGameplayTags(Effect.Spec.DynamicGrantedTags);	}	

// Update our owner with the tags this GameplayEffect grants them
Owner->UpdateTagMap(Effect.Spec.Def->InheritableOwnedTagsContainer.CombinedTags, 1);	
Owner->UpdateTagMap(Effect.Spec.DynamicGrantedTags, 1);

This updates the MinimalReplicationTags in the correct order:
AddTag(GameplayEffect.Weapon.Equip.Primary)
AddTag(GameplayEffect.Weapon.Equipped.Primary)
RemoveTag(GameplayEffect.Weapon.Equip.Primary)

Have Comments or More Details?

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

3
Login to Vote

Unresolved
ComponentUE - Gameplay
Affects Versions4.255.0
Target Fix5.2
CreatedApr 6, 2022
UpdatedAug 26, 2022