-
Notifications
You must be signed in to change notification settings - Fork 1.4k
feat!: gestalt-di migration #5299
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 4 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
9537e27
temp: gestalt-di migration changes
BenjaminAmos acb4846
fix: fix missing input events in main menu
BenjaminAmos 3c195ee
Fix 2nd client crashing on trying to join a server via localhost
Cervator ce52b17
Fixes bad generated code that breaks the build
Cervator b353187
refactor: remove some uses of CoreRegistry
BenjaminAmos 9a8d7a8
fix: fix failing tests
BenjaminAmos 9db6a25
style: fix some checkstyle issues
BenjaminAmos 22589d0
style: fix some more checkstyle issues
BenjaminAmos File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| ## Engine Start-Up | ||
|
|
||
| ```mermaid | ||
| graph TD; | ||
| PreInitialise[Pre-Initialise] | ||
| subgraph InitialiseManagers[Initialise Managers] | ||
| ModuleManager --> ModuleTypeRegistry --> ReflectFactory --> CopyStrategyLibrary --> TypeHandlerLibrary | ||
| TypeHandlerLibrary --> ModuleAwareAssetTypeHandler --> AssetManager | ||
| end | ||
| subgraph Initialise | ||
| ConfigurationSubsystem --> TimeSubsystem --> OtherSubsystems[Other Subsystems...] --> MonitoringSubsystem | ||
| MonitoringSubsystem --> PhysicsSubsystem --> CommandSubsystem --> NetworkSubsystem | ||
| NetworkSubsystem --> WorldGenerationSubsystem --> GameSubsystem --> I18nSubsystem --> TelemetrySubsystem | ||
| end | ||
| InitialiseAssets[Initialise Assets] | ||
| PostInitialise[Post-Initialise] | ||
|
|
||
| PreInitialise --> ModuleManager | ||
| AssetManager --> ConfigurationSubsystem | ||
| TelemetrySubsystem --> InitialiseAssets --> PostInitialise | ||
| ``` | ||
|
|
||
| ### Why three phases? | ||
| _These are just my guesses based on the provided documentation._ | ||
| #### Pre-initialise | ||
| This phase allows for doing most of the initialisation for a subsystem that does not rely on other subsystems. | ||
| Any subsystem state that needs to be accessed from other subsystems should be initialised here. | ||
|
|
||
| #### Initialise | ||
| This is the first point at which subsystems have access to the module context. Most subsystems will properly initialise | ||
| themselves here. It also allows subsystems to interact in a limited fashion, although this shouldn't be often needed. | ||
|
|
||
| #### Post-initialise | ||
| This is the last point at which a subsystem should initialise itself. After this stage, the subsystem should be | ||
| considered fully initialised. If a subsystem must depend immediately on other initialised subsystems, interact | ||
| with them here. This occurs after engine assets have been loaded. | ||
|
|
||
| #### Why is this not ideal? | ||
| - Most subsystems actually have an implicit undocumented dependency on `TimeSubsystem` and `ConfigurationSubsystem`. | ||
| These subsystems are hard-coded to always run first during engine start-up and as-such break the principle of | ||
| subsystem independence (subsystems should be allowed to initialise in any order within the same stage). | ||
| - These implicit dependencies prevent us from initialising subsystems in parallel, which is limiting potential | ||
| start-up performance. | ||
| - Currently, all subsystems are actually initialised in the sequence you see above for each stage. | ||
| This has the potential to harbour further implicit dependencies that we are yet unaware of. | ||
| - (It's also a blocker for migrating to use Gestalt-DI, which requires dependencies to declared up-front.) | ||
|
|
||
| #### Potential Improvements | ||
| - Change `TimeSubsystem` and `ConfigurationSubsystem` to be classified as managers. This would allow them to initialise | ||
| in sequence after `ModuleManager` but before subsystems' `initialise()`. | ||
|
|
||
| ## Revised Start-Up Sequence (provisional) | ||
| ```mermaid | ||
| graph TD; | ||
| PreInitialise[Pre-Initialise] | ||
| subgraph InitialiseManagers[Initialise Managers] | ||
| ModuleManager --> ModuleTypeRegistry --> ReflectFactory --> CopyStrategyLibrary --> TypeHandlerLibrary | ||
| TypeHandlerLibrary --> ModuleAwareAssetTypeHandler --> AssetManager | ||
| end | ||
| subgraph Initialise | ||
| ConfigurationSubsystem | ||
| TimeSubsystem | ||
| OtherSubsystems[Other Subsystems...] | ||
| MonitoringSubsystem | ||
| PhysicsSubsystem | ||
| CommandSubsystem | ||
| NetworkSubsystem | ||
| WorldGenerationSubsystem | ||
| GameSubsystem | ||
| I18nSubsystem | ||
| TelemetrySubsystem | ||
| end | ||
| InitialiseAssets[Initialise Assets] | ||
| PostInitialise[Post-Initialise] | ||
|
|
||
| PreInitialise --> ModuleManager | ||
| AssetManager --> Initialise | ||
| Initialise --> InitialiseAssets --> PostInitialise | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| ### Engine States | ||
|
|
||
| ```mermaid | ||
| graph TD; | ||
| subgraph MainMenu | ||
| subgraph MainMenuHandleInput[HandleInput] | ||
| MainMenuInputSystemHandleInput[InputSystem] | ||
| end | ||
|
|
||
| subgraph MainMenuUpdate[Update] | ||
| MainMenuNUIManagerUpdate[NUIManager] --> MainMenuEventSystemUpdate[EventSystem] | ||
| MainMenuEventSystemUpdate --> MainMenuStorageServiceWorkerUpdate[StorageServiceWorker] | ||
| end | ||
|
|
||
| subgraph MainMenuRender[Render] | ||
| MainMenuNUIManagerRender[NUIManager] | ||
| end | ||
| end | ||
|
|
||
| subgraph Loading | ||
| subgraph LoadingUpdate[Update] | ||
| LoadingLoadingScreenUpdate[LoadingScreen::updateStatus] --> LoadingNUIManagerUpdate[NUIManager] | ||
| LoadingNUIManagerUpdate--> LoadingStepUpdate[Step Update] | ||
| subgraph LoadingStepUpdate | ||
| direction TB | ||
| RegisterMods --> InitRenderingHeadlessCheck{!headless} | ||
| InitRenderingHeadlessCheck -->|true| InitialiseRendering --> InitialiseEntitySystem | ||
| InitRenderingHeadlessCheck -->|false| InitialiseEntitySystem | ||
| InitialiseEntitySystem --> RegisterBlocks --> InitGraphicsHeadlessCheck{!headless} | ||
| InitGraphicsHeadlessCheck -->|true| InitialiseGraphics --> LoadPrefabs | ||
| InitGraphicsHeadlessCheck -->|false| LoadPrefabs | ||
| LoadPrefabs --> ProcessBlockPrefabs | ||
| ProcessBlockPrefabs --> InitialiseComponentSystemManager --> InitInputHeadlessCheck{!headless} | ||
| InitInputHeadlessCheck -->|true| RegisterInputSystem --> RegisterSystems | ||
| InitInputHeadlessCheck -->|false| RegisterSystems | ||
| RegisterSystems --> InitialiseCommandSystem --> LoadExtraBlockData --> InitialiseWorld | ||
| InitialiseWorld --> RegisterBlockFamilies --> EnsureSaveGameConsistency | ||
| EnsureSaveGameConsistency --> InitialisePhysics --> InitialiseSystems --> PreBeginSystems | ||
| PreBeginSystems --> LoadEntities --> InitialiseBlockTypeEntities --> CreateWorldEntity | ||
| CreateWorldEntity --> InitialiseWorldGenerator --> InitialiseRecordAndReplay | ||
| InitialiseRecordAndReplay --> NetModeIsServerCheck{netMode.isServer} | ||
| NetModeIsServerCheck -->|true| StartServer --> PostBeginSystems | ||
| NetModeIsServerCheck -->|false| PostBeginSystems | ||
| PostBeginSystems --> NetModeHasLocalClientCheck{netMode.hasLocalClient} | ||
| NetModeHasLocalClientCheck -->|true| SetupLocalPlayer --> AwaitCharacterSpawn --> PrepareWorld | ||
| NetModeHasLocalClientCheck -->|false| PrepareWorld | ||
| PrepareWorld | ||
| end | ||
| end | ||
|
|
||
| subgraph LoadingRender[Render] | ||
| LoadingNUIManagerRender[NUIManager] | ||
| end | ||
| end | ||
|
|
||
| subgraph InGame | ||
| subgraph InGameHandleInput[HandleInput] | ||
| InGameHandleInputInputSystem[InputSystem] | ||
| end | ||
|
|
||
| subgraph InGameUpdate[Update] | ||
| InGameEventSystemUpdate[EventSystem] --> InGameComponentSystemsUpdate[UpdateSubscriberSystems] | ||
| InGameComponentSystemsUpdate --> InGameWorldRendererUpdate[WorldRenderer] | ||
| InGameWorldRendererUpdate --> InGameStorageManagerUpdate[StorageManager] | ||
| InGameStorageManagerUpdate --> InGameNUIManagerUpdate[NUIManager] | ||
| InGameNUIManagerUpdate --> InStorageServiceWorkerUpdate[StorageServiceWorker] | ||
| end | ||
|
|
||
| subgraph InGameRender[Render] | ||
| InGameDisplayDevicePrepareToRender[DisplayDevice::prepareToRender] --> InGameNUIManagerRender[NUIManager] | ||
| InGameNUIManagerRender--> InGameWorldRendererrRender[WorldRenderer] | ||
| end | ||
| end | ||
|
|
||
| MainMenu -->|Start Game| Loading | ||
| Loading -->|Failed| MainMenu | ||
| Loading -->|Succeeded| InGame | ||
| InGame -->|Exit To Main Menu| MainMenu | ||
| ``` |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't swap
contexthalfway throughreset().Line 55 publishes the first
ContextImpltoCoreRegistry, then Line 89 replacesthis.contextwith a different service-backed instance. Anything setup hooks put into the first context is lost, and any remainingCoreRegistrycallers keep resolving from the stale one. That makes startup behavior depend on which access path a caller uses.Also applies to: 73-93
🤖 Prompt for AI Agents