fix: reuse cached scene definition on LSD reload instead of full re-discovery - #9505
Draft
dalkia wants to merge 1 commit into
Draft
fix: reuse cached scene definition on LSD reload instead of full re-discovery#9505dalkia wants to merge 1 commit into
dalkia wants to merge 1 commit into
Conversation
…iscovery LSD reloads re-ran the whole static-pointer discovery pipeline (entities/active POST, deferred-loading queue, definition deserialization) on every reload, costing ~1.8s, even though the definition cannot change for edits-in-place: the local dev server derives content hashes from file paths, not content. Keep the scene definition entity alive on unload for LSD exactly like regular scenes (UnloadSceneSystem already does this as an in-ECS definition cache), and drop the StaticScenePointers promise reset in ECSReloadScene. On reload, ResolveStaticPointersSystem recreates the facade promise from the kept entity. Known limitation: newly added/removed files change the definition content list and are only picked up on realm re-entry, not on reload. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request Description
What does this PR change?
Cuts ~1.8s off every Local Scene Development (LSD) scene reload by reusing the scene definition already cached in ECS instead of re-running the full static-pointer discovery pipeline.
Problem. On every LSD reload (
/reload-scenechat command or CLI websocket trigger), the client destroyed the scene definition entity and nulledStaticScenePointers.Promise, forcing a complete re-discovery:entities/activePOST → deferred-loading queue wait → definition deserialization → scene entity re-creation. Measured on Genesis Plaza 2025 via LSD, this discovery round-trip costs ~1.8s of an ~4.9s reload (~6.1s with local asset bundles, where the pipeline additionally re-fetches the AB manifest twice — see follow-ups).Why the re-fetch buys nothing. The LSD dev server derives content hashes from file paths, not content (entity id = b64 of the project path; every content entry hash = b64 of the file path). Editing code or models changes nothing in the definition — the same JSON is returned byte-for-byte. The client re-fetches the JS bundle and re-loads assets on reload anyway.
Fix. Two deletions, reusing the mechanism regular scenes already have:
UnloadSceneSystem: stop excluding LSD from the "keep definition entity = cache in ECS itself" path (thelocalSceneDevelopmentctor param is now unused and removed).ECSReloadScene: stop nullingStaticScenePointers.Promiseon LSD reload.On reload,
ResolveStaticPointersSystemrecreates the facade promise from the kept entity (it queries for definition entities with noISceneFacade/promise). Realm teardown still destroys the kept entities viaRealmController.CLEAR_QUERY, same as regular scenes.Reload timing (Genesis Plaza 2025, measured before / expected after):
Known limitation. Adding or removing files changes the definition's content list and is no longer picked up by a reload — re-entering the realm (or restarting the preview) is required. Edits to existing files (code, models, scene.json metadata — the overwhelmingly common case) are unaffected: scene.json is re-fetched during facade creation, and JS/assets are re-fetched by path. A follow-up can restore added-file support with an inline
entities/activerefresh (~0.3s) that patches the kept definition.Follow-ups identified while profiling (not in this PR):
--local-asset-bundles, the definition flow fetches the same AB manifest twice (AssetBundleManifestFallbackHelper+SceneAssetBundleDigestsLoader) at ~2.5s each — the manifest system usesNoCache, so the "deduped via the promise cache" assumption doesn't hold.GatherGltfAssetsSystemconcludes immediately on reload (no readiness report queued →assets 0/N), soSceneLoadingConcludedfires before any GLTF is loaded, defeating the collider-protection wait inECSReloadSceneand unfreezing the character early.Test Instructions
Steps (LSD reload):
Expected result:
entities/activePOST between reloads in the CLI server logs).Automation (if applicable):
metaforge explorer test XXXX🤖 Generated with Claude Code