I know there have been issues in the past with how AttachParent and AttachChildren replication are handled (they’re non-atomic), but it’s causing huge headaches for us because we have optimized our net update frequencies in such a way that has resulted in the parent’s replication always occurring before the child’s replication.
Therefore we get stuck in a state where, upon detaching (and I presume attaching) the child, the AttachParent is stale and the AttachChildren reflects the new list for the clients. There are lots of replication flows that rely on these being in sync and throw hitch-causing ensures. The easiest repro case I can show you is in the most UE4.14.2 vanilla, when a replicated actor attempts to SyncReplicatedPhysicsSimulation in PostNetReceive while it still has a stale AttachParent.
The ensure seems to be benign since it occurs in DetachComponent, which actually promptly puts it in a safe state, but I don’t think that was the intended use of that function given the existence of the ensure. I’ve temporarily changed the ensure to a log in our version of UE4 to get rid of the hitch, but I’d love to know if there is any intention of making the replication of attachment atomic or at least have it gracefully handle replication occurring in this order.
I’ve attached a very simple project that you should be able to use to reproduce the issue simply by playing in dedicated server and then waiting around 10 seconds for the delay and subsequent latent replication to occur.
There’s just the one BeginPlay event in AttachParent, and then the most notable properties are the Net Update Frequencies in both AttachParent and AttachChild.
we have hit this check a few times, and it seems to be on the clients where attaching/detaching has been replicated. I can’t confirm yet, but I suspect this might be the problem.
For clarification, I mean the check mentioned in Unreal Engine Issues and Bug Tracker (UE-40244), which links back to here.
It’s the same as the one if the associated issue :
UE4Editor-Engine.dll!USceneComponent::DetachFromComponent(const FDetachmentTransformRules & DetachmentRules) Line 2009 C++
UE4Editor-Engine.dll!AActor::OnRep_AttachmentReplication() Line 1536 C++
UE4Editor-CoreUObject.dll!UFunction::Invoke(UObject * Obj, FFrame & Stack, void * const Z_Param__Result) Line 4551 C++
UE4Editor-CoreUObject.dll!UObject::ProcessEvent(UFunction * Function, void * Parms) Line 1345 C++
UE4Editor-Engine.dll!AActor::ProcessEvent(UFunction * Function, void * Parameters) Line 687 C++
UE4Editor-Engine.dll!FRepLayout::CallRepNotifies(FRepState * RepState, UObject * Object) Line 2404 C++
UE4Editor-Engine.dll!FObjectReplicator::CallRepNotifies(bool bSkipIfChannelHasQueuedBunches) Line 1487 C++
UE4Editor-Engine.dll!FObjectReplicator::PostReceivedBunch() Line 1043 C++
UE4Editor-Engine.dll!UActorChannel::ProcessBunch(FInBunch & Bunch) Line 2313 C++
UE4Editor-Engine.dll!UActorChannel::ReceivedBunch(FInBunch & Bunch) Line 2148 C++
UE4Editor-Engine.dll!UChannel::ReceivedSequencedBunch(FInBunch & Bunch) Line 296 C++
UE4Editor-Engine.dll!UChannel::ReceivedNextBunch(FInBunch & Bunch, bool & bOutSkipAck) Line 667 C++
UE4Editor-Engine.dll!UChannel::ReceivedRawBunch(FInBunch & Bunch, bool & bOutSkipAck) Line 388 C++
UE4Editor-Engine.dll!UNetConnection::ReceivedPacket(FBitReader & Reader) Line 1540 C++
UE4Editor-Engine.dll!UNetConnection::ReceivedRawPacket(void * InData, int Count) Line 933 C++
This issue has not been resolved at this time. We don’t have a timeframe for when this may be addressed. Please keep in mind that with source code access, a programmer on your project can implement your own solution, and you are welcome to share that result with Epic for possible integration.