Failed check in fast gameplay tag replication with tag defined in GFP

We have some smoke tests that run on editor startup which test the replication of various structs to verify that they fit within a given size threshold, and that we can properly serialize and deserialize some test data within those structs. The Automation Test Framework runs these tests before GFPs have been loaded. During these tests, the first call to `FGameplayTag::NetSerialize()` triggers a call to `UGameplayTagsManager::ConstructNetIndex()` to build an index of all of the currently registered gameplay tags. `ConstructNetIndex()` is not called again after this point, so any gameplay tags that are registered by loaded GFPs do not get a valid NetIndex assigned. Attempting to replicate one of these tags triggers the check statement in `FGameplayTagNode::GetNetIndex()`.

The problem seems to be in `UGameplayTagsManager::HandleGameplayTagTreeChanged()`. This is called from `UGameplayTagsManager::AddTagIniSearchPath()` when a GFP’s tags are registered, but `bDoneAddingNativeTags` is still false, so the logic that would invalidate the constructed network index is skipped. When `UGameplayTagsManager::DoneAddingNativeTags()` is called, it considers all of the gameplay tag search paths from the GFPs as properly searched and added, so it doesn’t reconstruct the tree at that time.

We’ve worked around this by adding a call to `InvalidateNetworkIndex()` at the top of `UGameplayTagsManager::HandleGameplayTagTreeChanged()`.

void UGameplayTagsManager::HandleGameplayTagTreeChanged(bool bRecreateTree)
{
    if (ShouldUseFastReplication())
    {
       InvalidateNetworkIndex();
    }

    // Don't do anything during a reconstruct or before initial native tags are done loading
    if (!bIsConstructingGameplayTagTree && bDoneAddingNativeTags)
    {

[Attachment Removed]

Steps to Reproduce

  1. Enable Fast Replication in GameplayTags project settings.
  2. Create a GFP which defines a gameplay tag.
  3. Define an automation test with the SmokeFilter flag, which calls NetSerialize on a Gameplay Tag defined in DefaultGameplayTags.ini.
  4. Run a PIE session in which an actor replicates the gameplay tag defined in the GFP.
  5. Observe the failed `check(NetIndex != INVALID_TAGNETINDEX)`
    [Attachment Removed]

Hi,

Thank you for the report!

I can confirm this issue is still present in the latest version of the engine, and I’ve opened a new issue for this, UE-410401, which should be visible in the public tracker in a day or so.

In the meanwhile, your fix here definitely looks reasonable, and I didn’t run into any issues in my own local testing with the change. I’ve included that information on the internal tracker for the bug as well.

Thanks,

Alex

[Attachment Removed]