Child blueprints of a blueprint of a native actor class with sparse data can have an incorrectly null SparseClassDataStruct value, and thus fail to initialzie their SparseClassData. This affects editor-time, PIE, but not standalone games.
Example native actor class with sparse data:
USTRUCT(BlueprintType) struct FMySparseDataStruct { GENERATED_BODY() FMySparseDataStruct() {} UPROPERTY(EditDefaultsOnly) int32 SomeValue; }; UCLASS(SparseClassDataTypes = MySparseDataStruct) class SPARSEDATANULL54R_API AMySparseDataActor : public AActor { GENERATED_BODY() public: AMySparseDataActor(); virtual void BeginPlay() override; };
If you create a blueprint 'BP_MySparseDataActor' of the above, and a child blueprint 'BP_MySparseDataActor_Child' of that, the child blueprint will misbehave after editor restarts until either the parent or child blueprint have been recompiled.
This can be observed in multiple ways:
void AMySparseDataActor::BeginPlay() { Super::BeginPlay(); // These ensures will fail in an editor session for child blueprints unless the child BP itself or a parent BP has been manually compiled UClass* MyClass = GetClass(); ensure(MyClass->GetOrCreateSparseClassData() != nullptr); ensure(MyClass->GetSparseClassDataStruct() != nullptr); // This getter will crash under the same conditions const int32 SomeValue = GetSomeValue(); UE_LOG(LogTemp, Warning, TEXT("BeginPlay(%s) My Value = %d"), *GetPathName(), SomeValue); }
The problem does not affect Standalone builds. It also doesn't affect blueprints that directly inherit from the native class.
(Internal) repro project attached.
> [Inline Frame] UnrealEditor-SparseDataNull54R.dll!AMySparseDataActor::GetSomeValue() Line 23 C++
UnrealEditor-SparseDataNull54R.dll!AMySparseDataActor::BeginPlay() Line 21 C++
UnrealEditor-Engine.dll!AActor::DispatchBeginPlay(bool bFromLevelStreaming) Line 4193 C++
UnrealEditor-Engine.dll!AWorldSettings::NotifyBeginPlay() Line 305 C++
UnrealEditor-Engine.dll!AGameStateBase::HandleBeginPlay() Line 228 C++
UnrealEditor-Engine.dll!AGameModeBase::StartPlay() Line 206 C++
UnrealEditor-Engine.dll!UWorld::BeginPlay() Line 5330 C++
UnrealEditor-Engine.dll!UGameInstance::StartPlayInEditorGameInstance(ULocalPlayer * LocalPlayer, const FGameInstancePIEParameters & Params) Line 568 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::CreateInnerProcessPIEGameInstance(FRequestPlaySessionParams & InParams, const FGameInstancePIEParameters & InPIEParameters, int InPIEInstanceIndex) Line 3141 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::OnLoginPIEComplete_Deferred(int LocalUserNum, bool bWasSuccessful, FString ErrorString, FPieLoginStruct DataStruct) Line 1590 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::CreateNewPlayInEditorInstance(FRequestPlaySessionParams & InRequestParams, const bool bInDedicatedInstance, const EPlayNetMode InNetMode) Line 1853 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::StartPlayInEditorSession(FRequestPlaySessionParams & InRequestParams) Line 2872 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::StartQueuedPlaySessionRequestImpl() Line 1167 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::StartQueuedPlaySessionRequest() Line 1068 C++
UnrealEditor-UnrealEd.dll!UEditorEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 1902 C++
UnrealEditor-UnrealEd.dll!UUnrealEdEngine::Tick(float DeltaSeconds, bool bIdleMode) Line 550 C++
UnrealEditor.exe!FEngineLoop::Tick() Line 5910 C++
[Inline Frame] UnrealEditor.exe!EngineTick() Line 61 C++
UnrealEditor.exe!GuardedMain(const wchar_t * CmdLine) Line 180 C++
UnrealEditor.exe!LaunchWindowsStartup(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * __formal, int nCmdShow, const wchar_t * CmdLine) Line 247 C++
UnrealEditor.exe!WinMain(HINSTANCE__ * hInInstance, HINSTANCE__ * hPrevInstance, char * pCmdLine, int nCmdShow) Line 298 C++
[External Code]
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-215992 in the post.
1 |
Component | UE - Gameplay - Blueprint |
---|---|
Affects Versions | 5.4 |
Target Fix | 5.6 |
Created | May 29, 2024 |
---|---|
Updated | Oct 1, 2024 |