Mass Replicated Entities are not getting destroyed when we tried to upgrade to UE5.8

Summary

Hello!

We have a project that uses Mass and replicated entities. We are trying to upgrade it to UE5.8 but we are facing an issue when destroying replicated entities.

On the method UMassReplicationProcessor::Execute, the execution is being halt by the checkf present at the end of that method that checks AgentData.Handle is not valid (with message “This replicated agent should have been removed from this client and was not”). After debugging the code, we found that when an entity has b PendingDestruction == true its not added to the entity set processed to replicate. Therefore, method ProcessClientReplication is not being called and the entity is not invalidated by CalculateClientReplication. As a side note, it does not seem adequate to have a check there, as it halts the execution. Maybe an ensureMsg should be enough?

Also, for this setup, we had to set value to 0 of CVar mass.UseProcessingQueue because the UMassReplicationProcessor copies it’s EntityQuery to the FMassReplicationSharedFragment and then Replicator adds it’s custom requierements. Therefore when executing the query and checking it’s correctly registered on FQueuedProcessor::SetCurrentQuery it cannot find the query in the list of registered queries since it is comparing by pointer.

We are not sure if the problem is in the engine or on our end. Some help would be appreciated.

What Type of Bug are you experiencing?

Gameplay

Steps to Reproduce

Use UMassReplicationProcessor::Execute to replicate entities on UE5.7

Update engine to UE 5.8

Check the status of replicated entities

Expected Result

Mass Replicated Entities are destroyed after flagging them as pending_destruction=true when we upgrade to UE5.8

Observed Result

Mass Replicated Entities are not getting destroyed when we tried to upgrade to UE5.8

Affects Versions

5.8

Platform(s)

Windows