Description

When the gameplay framework component manager creates components as part of CreateComponentOnInstance, it passes in the requested class name as the literal name of the component instead of using the autogenerated name (which would be ClassName_1 etc). This gives it a consistent name, but it will also cause it to reuse a partially-destroyed component if it is destroyed and recreated before GC has time to delete the object. This confuses the replication system because it thinks it is literally the same component as before, so it never gets destroyed/recreated on the client and BeginPlay/EndPlay are out of sync on the client and server.

The exact behavior of this changed between 5.1 and 5.3 due to changes to component replication but both behaviors are not what the user expects. Ideally the server and client would get the same gameplay calls when a component is destroyed and recreated. Changing it to use the autogenerated names like default fixes this issue but may cause other problems.

Steps to Reproduce
  1. Download attached DestroyComponentBug project and unzip into DestroyComponentBug in your engine source tree
  2. Build/open DestroyComponentBug.uproject in the editor
  3. Open /Game/TestMap
  4. Start PIE with 1 client and 1 dedicated server
  5. Observe the output log (specifically, LogBlueprintUserMessages)

Expected:

BEGIN PLAY is printed for the new component on both the client and server, and then every 5 seconds thereafter the same component prints END PLAY on both client and server with a new component being created (and repeating the cycle) thereafter.

Actual:

5.1 behavior: BEGIN PLAY is printed for both the client and server, after 5 seconds a new BEGIN PLAY prints for both the client and server but only the server prints END PLAY. The client will randomly log BEGIN PLAY depending on the exact time that components are replicated

5.3 behavior: BEGIN PLAY is only printed once on the client and END PLAY is never printed on the client because it never destroys the component

Have Comments or More Details?

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

0
Login to Vote

Unresolved
ComponentUE - Gameplay
Affects Versions5.15.3
Target Fix5.5
Main Commit31905776
CreatedApr 5, 2023
UpdatedMar 2, 2024