What is needed
Upon an Asynch Spawn Request, we would process the spawnable asset entity list into a list of batched entities to process together in the later, main threaded activation phases, in order to create a full throughline from multi-threaded handling, to main thread handling to provide a fully "Async" spawning experience through "Over Time" entity loading.
I believe that the data loading stage of spawning already runs threaded (async), however we would want to simply verify it and make sure that it's processing the source entity data in a way that we can piggy back on on completion.
Next, we can begin batch processing entity Initialization Init(). Either through callbacks from batched threaded data loading, or after a batching process that processes our list of loaded entities into groups, we then start Initializing these enitities over time. One batch per frame.
- One extra feature I would like to target is to have a deltaTime threshold where the batch this frame will break out and complete in a later frame if it's been taking too long to Init. This would be from situations where you're activating massive entities like Terrain or Nav Meshes or other big data entitities.
After Init(), if we introduce this feature after the Entity Activation Handling featureset, we can also target the Initialized entity Transform Component to build our entity hierarchy map and determine if this Entity, and therefor it's descendents will spawn inactive (meaning, remaining Initialized and no further.)
Then, upon full Init, we can do two possible things:
- Do a single massive entity activation of all valid Activate Enitites. This would be most compliant of current O3DE spawning patterns and thus, should yield a very regular outcome.
- Or, do Activation Batching as well. This might be worth creating as an option in the AsynchSpawnArgs companion class.
All throughout the stages of this process, we can utilize an AsynchSpawnNotificationsBus or add additional methods to the already present SpawningNotificationsBus to report the progress of the Spawn over this extended time.
Conclusion
Having already done a far more crude version of this feature here #1423862760701431868, I believe it's not too much farther to go the full way and build this range of features.
My second internal iteration from the original linked was going to pretty much match this process, however, as a duplicate of the already present spawn system in order to completely circumvent the Spawn Process and introduce these feature injections in my proprietary version. It, being separate from the entity system as it is, meant I had shortcomings, like being unable to process/map first runtime entities spawned, and ultimately involved recreating wheels that were already fully present and functional in the Entity system.
With the validation of the processes of spawning from Nick, I don't believe my proprietary implementation would be worth pursuing over a community expansion of the Entity Spawning system, as, with only a few additional steps, we could have a fully fledged and integrated feature that, along with entity activation handling, would lead to a HIGHLY impactful feature set that would significantly improve the viability of the engine for outside parties that expect these features to be present in game engines inherently.