Fix DRACOLoader Web Worker leak during GLTF loading #795
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.
Fix DRACOLoader Web Worker memory leak during GLTF loading
Summary
This PR fixes a critical memory leak caused by undisposed
DRACOLoaderinstances created during GLTF loading.Each GLTF load was spawning Web Workers that were never terminated, leading to unbounded worker and memory growth during normal Phoenix usage.
Problem
Multiple GLTF loading paths in
ImportManagercreated newDRACOLoaderinstances per load without callingdispose().In three.js,
DRACOLoader:These resources are not garbage-collected and must be explicitly released via
DRACOLoader.dispose().As a result:
This issue is independent of PR #791, which addressed GPU
BufferGeometrydisposal, not loader lifecycle or Web Workers.What This PR Fixes
DRACOLoaderChanges Made
Core Fix
File:
packages/phoenix-event-display/src/managers/three-manager/import-manager.tsDRACOLoaderlifecycleDRACOLoadercreation with a controlled instancecleanup()method to explicitly dispose DRACO resourcesparsePhnxSceneloadGLTFGeometryInternalparseGLTFGeometryFromArrayBufferIntegration
File:
packages/phoenix-event-display/src/managers/three-manager/index.tsImportManager.cleanup()intoThreeManager.cleanup()to ensure proper disposal during teardownImpact
This is especially important for physics analysis workflows where Phoenix is kept open for extended periods.
Test Coverage
New tests added:
packages/phoenix-event-display/src/tests/managers/three-manager/import-manager.test.tsTests verify:
dispose()is called during cleanupTests run in
jsdomand mockDRACOLoaderto validate lifecycle behavior without spawning real workers.Verification (Manual)
chrome://inspect/#workers)Notes