I noticed PIE was unnecessarily rerunning all Blueprint construction scripts when loading in levels, adding a second or more to our PIE start-up time and causing hitches during PIE level streaming.
UWorld::AddToWorld and UWorld::InitializeActorsForPlay query bWasDuplicatedForPIE to avoid rerunning the construction scripts. However, it seems bWasDuplicatedForPIE is not set on the levels dynamically created by the World Partition system.
I added an additional condition of GetPackage()->HasAnyPackageFlags(PKG_PlayInEditor) and this fixed the issue.
Is this a safe and correct fix? Is there a better solution, perhaps with bWasDuplicatedForPIE being set on generated World Partition levels?
Hello,
I apologize for the delay. We rerun the construction scripts in PIE to guarantee they are up-to-date (see this [Content removed] If you want to change this locally, you could also try setting NewLevel->bHasRerunConstructionScripts in FWorldPartitionLevelHelper::CreateEmptyLevelForRuntimeCell after the level has been created (also check for PIE). However, besides the PIE experience potentially differing from what you should actually expect if some actors are not updated to reflect their changes, I’m unsure if you might run into any other issues from this.
Thanks,
Ryan
For the most part, the levels and actors are not duplicated for PIE when using World Partition with streaming enabled. During PIE, World Partition generates the runtime levels as they are requested. This consists of creating a new level and then loading the actors that should be associated with it from disk unless those actors are unsaved dirty actors in which it will duplicate them instead (see code under the Duplicate unsaved actors section of UWorldPartitionLevelStreamingDynamic::IssueLoadRequests). There is no caching that I’m aware of between PIE sessions and I would expect all the runtime levels generated for the PIE session to be cleaned up when the PIE world gets destroyed.
-Ryan
Hi Ryan,
Thanks for the feedback and the referenced post.
In the cases I’m testing, the entire world is loaded in the editor before running PIE. It seems like it shouldn’t be necessary to rerun the construction scripts - they are guaranteed to run when the level is loaded and if the Blueprints are changed.
However, we have come across two cases where components of instances of Blueprints were in a stale/invalid state in PIE with this change. While there was no clear indication of the root cause, resaving the affected actor instances resolved the issue.
I’d like to better understand why that happened, what got repaired by resaving the actor instances and whether it’s something fixable. My only hypothesis is that the PIE level instances made by the World Partition system are cached between sessions and are only rebuilt if any actor instances within a partition are modified - is that correct? If so, that would explain the side-effects of my change. If it’s caching between sessions, that’s pretty nice and presumably has better savings than skipping the construction scripts.
Best regards,
Ben