The cause of this issue is the PlayerClass variable not having UPROPERTY declaration. In the packaged project, UE5's Garbage Collector is cleaning up the class after changing levels as there isn't any hard ref to prevent it.
The issue can be solved like so:
UPROPERTY(BlueprintGetter = "GetPlayerClass", BlueprintSetter = "SetPlayerClass") TSubclassOf<APlayerPawn> PlayerClass;
Reproduced 3/3 times, issue does not occur in //UE5/Release-5.0 - CL 20979098 Binary. Confirmed Regression.
It's only in packaged & quick launched builds that this occurs; PIE works as normal.
1) Create an empty C++ project
2) Create classes
2.1) UMyGameInstance : public UGameInstance
2.2) UMyGameInstanceSubsystem : public UGameInstance Subsystem
2.3) APlayerPawn : public APawn
3) Add the variable "TSubclassOf<APlayerPawn> PlayerClass" to the GameInstance classes and add the getter and setter functions to it
4) create map 1 and map 2. Set map 1 as Game Default map.
5) create a blueprint from APlayerPawn
6) create a widget with a button, hang a logic one on the button
6.1) through the MyGameInstanceSubsystem setter, set the PlayerPawn blueprint class
6.2) open the map 2
7) in map 1, in the level blueprint on the begin play, create a widget and add it to the viewport
8) in the level blueprint of map 2 on the begin play, get the PlayerPawn class through the getter MyGameInstanceSubsystem
9) check the validity of the PlayerPawnClass variable
10) package project
11) open exe
Actual Result: After clicking button to open map 2, PlayerPawnClass variable is not valid. If the validity test is skipped and user tries to access PlayerPawnClass variable, a crash occurs.
Expected Result: PlayerPawnClass variable should still be valid
Fatal error! Unhandled Exception: EXCEPTION_ACCESS_VIOLATION reading address 0x000000000001bbba TestSubclass.exe!FName::ToString() [] TestSubclass.exe!UKismetSystemLibrary::execGetClassDisplayName() [] TestSubclass.exe!UObject::execCallMathFunction() [] TestSubclass.exe!UObject::execLet() [] TestSubclass.exe!ProcessLocalScriptFunction() [] TestSubclass.exe!ProcessScriptFunction<void (__cdecl*)(UObject * __ptr64,FFrame & __ptr64,void * __ptr64)>() [] TestSubclass.exe!ProcessLocalFunction() [] TestSubclass.exe!ProcessLocalScriptFunction() [] TestSubclass.exe!UObject::ProcessInternal() [] TestSubclass.exe!UFunction::Invoke() [] TestSubclass.exe!UObject::ProcessEvent() [] TestSubclass.exe!AActor::ProcessEvent() [] TestSubclass.exe!AActor::BeginPlay() [] TestSubclass.exe!AActor::DispatchBeginPlay() [] TestSubclass.exe!AWorldSettings::NotifyBeginPlay() [] TestSubclass.exe!AGameStateBase::HandleBeginPlay() [] TestSubclass.exe!UWorld::BeginPlay() [] TestSubclass.exe!UEngine::LoadMap() [] TestSubclass.exe!UEngine::Browse() [] TestSubclass.exe!UEngine::TickWorldTravel() [] TestSubclass.exe!UGameEngine::Tick() [] TestSubclass.exe!FEngineLoop::Tick() [] TestSubclass.exe!GuardedMain() [] TestSubclass.exe!GuardedMainWrapper() [] TestSubclass.exe!LaunchWindowsStartup() [] TestSubclass.exe!WinMain() [] TestSubclass.exe!__scrt_common_main_seh() [D:\a\_work\1\s\src\vctools\crt\vcstartup\src\startup\exe_common.inl:288] KERNEL32.DLL!UnknownFunction [] ntdll.dll!UnknownFunction []
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-171600 in the post.
3 |
Component | UE - Foundation - Core - Cooker |
---|---|
Affects Versions | 5.1 |
Target Fix | 5.1.1 |
Created | Dec 1, 2022 |
---|---|
Resolved | Dec 14, 2022 |
Updated | Dec 14, 2022 |