Instanced UObject is not preserved inside TInstancedStruct after blueprint recompilation

We are having an issue with `TInstancedStruct` for USTRUCT() which contains `UObject` reference to `EditInlineNew`, `Instanced` object. If such Instanced Structure is setup in Blueprint defaults, and has instanced `UObject` created for it, then upon blueprint recompilation, the instanced `UObject` is removed. This behavior is inconsistent with how “normal”, non-instanced USTRUCT()s behave. From what we have tested, this issue is present on Actor and Actor’s native default subobjects (components). If, however such `TInstancedStruct` setup is made on Actor Component which is then spawned inside Blueprint, then reference to `UObject` persists, but from our understanding such components are not Actor’s default subobjects.

Steps to reproduce with the following classes:

`UCLASS(EditInlineNew, DefaultToInstanced)
class UInstancedData : public UObject
{
GENERATED_BODY()
};

USTRUCT()
struct FStructData
{
GENERATED_BODY()

UPROPERTY(EditAnywhere, meta=(ShowInnerProperties))
UInstancedData* Data;
};

UCLASS()
class AInstancedStructTestActor : public AActor
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, meta=(ShowInnerProperties))
FStructData NormalStruct;

UPROPERTY(EditAnywhere, meta=(ShowInnerProperties))
TInstancedStruct InstancedStruct;
};1. Launch UE Editor and create new Blueprint which inherits from \AInstancedStructTestActor`
2. Open blueprint editor and locate `Normal Struct`, `Instanced Struct` properties
3. For `Normal Struct` set `Data` to “Instanced Data”
4. For `Instanced Struct` first select `Struct Data` struct type and then set it’s `Data` property to “Instanced Data”
5. Compile Blueprint
6. Notice that `Data` property inside `Instanced Struct` is cleared (None), but it’s preserved inside `Normal Struct`

Steps to Reproduce
Steps to reproduce with the following classes:

`UCLASS(EditInlineNew, DefaultToInstanced)
class UInstancedData : public UObject
{
GENERATED_BODY()
};

USTRUCT()
struct FStructData
{
GENERATED_BODY()

UPROPERTY(EditAnywhere, meta=(ShowInnerProperties))
UInstancedData* Data;
};

UCLASS()
class AInstancedStructTestActor : public AActor
{
GENERATED_BODY()
public:
UPROPERTY(EditAnywhere, meta=(ShowInnerProperties))
FStructData NormalStruct;

UPROPERTY(EditAnywhere, meta=(ShowInnerProperties))
TInstancedStruct InstancedStruct;
};1. Launch UE Editor and create new Blueprint which inherits from \AInstancedStructTestActor`
2. Open blueprint editor and locate `Normal Struct`, `Instanced Struct` properties
3. For `Normal Struct` set `Data` to “Instanced Data”
4. For `Instanced Struct` first select `Struct Data` struct type and then set it’s `Data` property to “Instanced Data”
5. Compile Blueprint
6. Notice that `Data` property inside `Instanced Struct` is cleared, but it’s preserved inside `Normal Struct`

Hello [mention removed]​,

Thanks for sharing the detailed reproduction steps. I was able to reproduce the issue locally in UE 5.6 and a recent build from Main.

I’ve submitted a report based on our findings. You’ll be able to track its status at the following link:

https://issues.unrealengine.com/issue/UE-300039

Please note that Epic determines whether the issue is made publicly visible, so the tracking link may not work immediately. It can take a few days before the report appears on the public tracker.

You may consider avoiding the use of TInstancedStruct as a native actor class property until the issue is addressed.

I’ll go ahead and close this case for now, but feel free to reply if you have any additional information to share.

Best,

Francisco