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).
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".
How does TextureRenderTarget2D get TArray<uint8> type data?
How do I set a material as a post-processing material?
Why does the REMOVE method of map container remove elements have memory leaks?
What is the cause of the packaging error falling back to 'GameUserSettings' in ue5?
UMG RichText not appear image when packaged
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-216453 in the post.
2 |
Component | UE - Gameplay |
---|---|
Affects Versions | 5.3.2, 5.4.1 |
Target Fix | 5.6 |
Fix Commit | 39122175 |
---|
Created | Jun 4, 2024 |
---|---|
Resolved | Jan 10, 2025 |
Updated | Jan 22, 2025 |