Description

If an actor component contains a TArray of instanced objects, some of those object instances can get incorrectly invalidated and marked for garbage collection in certain situations, possibly resulting in data loss for the user.

In particular, this behavior can be consistently reproduced in UE 5.3.2 and UE 5.4.1 when undoing an actor translation after some specific steps (see repro instructions).

Steps to Reproduce

1) Create a new blank C++ project
2) Add the following C++ classes:

UCLASS(EditInlineNew)
class UDataTest : public UObject
{
GENERATED_BODY()

UPROPERTY(EditAnywhere)
int32 MyData;
};

UCLASS(meta = (BlueprintSpawnableComponent))
class UComponentTest : public UActorComponent
{
GENERATED_BODY()

UPROPERTY(EditAnywhere, Instanced)
TArray<UDataTest*> Array;
};

3) Compile and open the project in the Editor
4) Create a blueprint actor
4.1) Add "UComponentTest" component
4.2) Populate "Array" with 3 "UDataTest" objects
4.3) Set the "MyData" property of these objects to 0,1,2
5) Create an instance of the actor in the world
5.1) Remove array entry at Index 1 (do NOT just clear the object instance, instead delete the array entry as a whole, the array will then have only 2 entries remaining)
5.2) On the array entry at index 0, modify the "MyData" property from 0 to -1
5.3) Reset array entry at index 0 to the default value (do NOT reset "MyData" or the object instance, instead reset the array entry as a whole using the rightmost reset arrow button)
6) Translate the actor on the viewport
7) Press ctrl-z to undo the translation

--> Note that the array entry at index 0 now contains an invalid object instance. If we use "gc.CollectGarbageEveryFrame 1", that object instance is immediately set to "None".

Have Comments or More Details?

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

1
Login to Vote

Unresolved
ComponentUE - Gameplay
Affects Versions5.3.25.4.1
Target Fix5.5
CreatedJun 4, 2024
UpdatedJun 4, 2024
View Jira Issue