The order of world and game instance initialization is different between a true standalone game (cooked game or an editor build with -game) and a Play In Editor game. Specifically, in Play in Editor it calls Init() on the GameInstance after it initializes the world in PostCreatePIEWorld.
This means that in true standalone games, UGameInstanceSubsystem classes like CommonUserSubsystem in Lyra always initialize before UWorldSubsystem classes like UUIExtensionSystem that are created in the startup map (it may create subsystems attached to an empty level, but those are deleted before gameplay starts). However in PIE startup it will create the world subsystems for the true startup map before it initializes the game instance. This is inconsistent behavior because for every other type of gameplay map load the game instance subsystem will already exist.
This issue is related to prior bugs like [Link Removed] which were fixed by moving the world initialization in PIE later during the startup process. However, the place it was moved to resolve that issue was slightly too early to resolve this issue. To be consistent between PIE and normal standalone startup, the simplest fix is to modify UGameInstance::InitializeForPlayInEditor and move the call to PostCreatePIEWorld after the Init() call. This is more consistent but may have side effects in games that depend on the old behavior.
Expected behavior:
It should call CommonUserSubsystem::Initialize before UUIExtensionSubsystem::Initialize the same as it does for -Game
Broken behavior:
It first calls UUIExtensionSubsystem::Initialize on L_LyraFrontEnd, and then it calls UCommonUserSubsystem::Initialize. This order is different than the non-PIE order described above. It never initializes an empty map and the subsystems on the real map initialize too early in PIE
There's no existing public thread on this issue, so head over to Questions & Answers just mention UE-186247 in the post.
2 |
Component | UE - Gameplay |
---|---|
Affects Versions | 5.2, 5.3 |
Target Fix | 5.3 |
Fix Commit | 25613936 |
---|
Created | May 18, 2023 |
---|---|
Resolved | Sep 6, 2023 |
Updated | Dec 20, 2023 |