Repository navigation
Closed
Labels
bugSomething isn't working
Description
Describe the bug 📝
I'm using CivilNavigators component in a react application and I'm having some troubles disposing resources when components are unmounted.
Calling
components.dispose()will throw the attached error:
If load button is clicked again the left side of navigators stays blank and the only way to fix it is reloading the page.
To isolate the problem I created a small React application that wraps your CivilNavigators example and add a button to load/dispose CivilNavigators.
You can find the repo here or see it in action in StackBlitz
Reproduction ▶️
Steps to reproduce 🔢
- Open the stackbliz link or clone the repo and run
npm install && npm run dev - click the load button
- click the dispose button
- (optional) click again load button
System Info 💻
System:
OS: macOS 15.7.4
CPU: (10) arm64 Apple M2 Pro
Memory: 81.77 MB / 16.00 GB
Shell: 5.3.9 - /opt/homebrew/bin/bash
Binaries:
Node: 24.14.1 - /Users/ale/.nvm/versions/node/v24.14.1/bin/node
npm: 11.12.1 - /Users/ale/.nvm/versions/node/v24.14.1/bin/npm
Browsers:
Chrome: 149.0.7827.155
Firefox: 150.0.3
Safari: 18.6
npmPackages:
@thatopen/components: 3.4.6 => 3.4.6
@thatopen/components-front: 3.4.3 => 3.4.3
@thatopen/fragments: 3.4.5 => 3.4.5
@thatopen/ui: ^3.4.3 => 3.4.3
@thatopen/ui-obc: ^3.4.2 => 3.4.2Used Package Manager 📦
npm
Error Trace/Logs 📃
Click to expand!
navigators.ts:150 Group {isObject3D: true, uuid: '28cf42f8-680a-4523-859f-3afe984f750a', name: '', type: 'Group', parent: Scene, …}
chunk-VPA6MZ7K.js?v=ab71cf02:16310 Uncaught Error: No camera initialized!
at get camera (chunk-VPA6MZ7K.js?v=ab71cf02:16310:13)
at _ca.dispose (chunk-T4VKUU3Q.js?v=ab71cf02:30730:44)
at rr2.dispose (chunk-T4VKUU3Q.js?v=ab71cf02:40113:55)
at _Components2.dispose (chunk-VPA6MZ7K.js?v=ab71cf02:17537:19)
at NavigatorsExample.dispose (navigators.ts:34:22)
at App.tsx:17:24
at executeDispatch (react-dom_client.js?v=ab71cf02:13622:11)
at runWithFiberInDEV (react-dom_client.js?v=ab71cf02:997:72)
at processDispatchQueue (react-dom_client.js?v=ab71cf02:13658:37)
at react-dom_client.js?v=ab71cf02:14071:11
get camera @ chunk-VPA6MZ7K.js?v=ab71cf02:16310
dispose @ chunk-T4VKUU3Q.js?v=ab71cf02:30730
dispose @ chunk-T4VKUU3Q.js?v=ab71cf02:40113
dispose @ chunk-VPA6MZ7K.js?v=ab71cf02:17537
(anonymous) @ navigators.ts:34
$RefreshSig$ @ App.tsx:17
executeDispatch @ react-dom_client.js?v=ab71cf02:13622
runWithFiberInDEV @ react-dom_client.js?v=ab71cf02:997
processDispatchQueue @ react-dom_client.js?v=ab71cf02:13658
(anonymous) @ react-dom_client.js?v=ab71cf02:14071
batchedUpdates$1 @ react-dom_client.js?v=ab71cf02:2626
dispatchEventForPluginEventSystem @ react-dom_client.js?v=ab71cf02:13763
dispatchEvent @ react-dom_client.js?v=ab71cf02:16784
dispatchDiscreteEvent @ react-dom_client.js?v=ab71cf02:16765
<button>
exports.jsxDEV @ react_jsx-dev-runtime.js?v=ab71cf02:247
$RefreshSig$ @ App.tsx:23
react_stack_bottom_frame @ react-dom_client.js?v=ab71cf02:18509
renderWithHooksAgain @ react-dom_client.js?v=ab71cf02:5729
renderWithHooks @ react-dom_client.js?v=ab71cf02:5665
updateFunctionComponent @ react-dom_client.js?v=ab71cf02:7475
beginWork @ react-dom_client.js?v=ab71cf02:8525
runWithFiberInDEV @ react-dom_client.js?v=ab71cf02:997
performUnitOfWork @ react-dom_client.js?v=ab71cf02:12561
workLoopSync @ react-dom_client.js?v=ab71cf02:12424
renderRootSync @ react-dom_client.js?v=ab71cf02:12408
performWorkOnRoot @ react-dom_client.js?v=ab71cf02:11766
performWorkOnRootViaSchedulerTask @ react-dom_client.js?v=ab71cf02:13505
performWorkUntilDeadline @ react-dom_client.js?v=ab71cf02:36
<App>
exports.jsxDEV @ react_jsx-dev-runtime.js?v=ab71cf02:247
(anonymous) @ main.tsx:8
navigators.ts:125 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'three')
at model.getClippingPlanesEvent (navigators.ts:125:41)
at ViewManager.getPlanes (chunk-SV56ACRE.js?v=ab71cf02:80943:33)
at ViewManager.newView (chunk-SV56ACRE.js?v=ab71cf02:80924:32)
at ViewManager.newViewRequest (chunk-SV56ACRE.js?v=ab71cf02:80907:23)
at ViewManager.refreshView (chunk-SV56ACRE.js?v=ab71cf02:80874:26)
at _FragmentsModel2._refreshView (chunk-SV56ACRE.js?v=ab71cf02:84570:43)
at _FragmentsModels2.update (chunk-SV56ACRE.js?v=ab71cf02:99949:31)
at chunk-SV56ACRE.js?v=ab71cf02:99982:14
(anonymous) @ navigators.ts:125
getPlanes @ chunk-SV56ACRE.js?v=ab71cf02:80943
newView @ chunk-SV56ACRE.js?v=ab71cf02:80924
newViewRequest @ chunk-SV56ACRE.js?v=ab71cf02:80907
refreshView @ chunk-SV56ACRE.js?v=ab71cf02:80874
_refreshView @ chunk-SV56ACRE.js?v=ab71cf02:84570
update @ chunk-SV56ACRE.js?v=ab71cf02:99949
(anonymous) @ chunk-SV56ACRE.js?v=ab71cf02:99982
setTimeout
(anonymous) @ chunk-SV56ACRE.js?v=ab71cf02:99981
drainAll @ chunk-SV56ACRE.js?v=ab71cf02:85070
handleFinish @ chunk-SV56ACRE.js?v=ab71cf02:85040
MeshManager.requests.onFinish @ chunk-SV56ACRE.js?v=ab71cf02:84997
add @ chunk-SV56ACRE.js?v=ab71cf02:84665
handleRequest @ chunk-SV56ACRE.js?v=ab71cf02:84643
handleRequest @ chunk-SV56ACRE.js?v=ab71cf02:84539
manageRequest @ chunk-SV56ACRE.js?v=ab71cf02:99972
(anonymous) @ chunk-SV56ACRE.js?v=ab71cf02:99988
manageConnection @ chunk-SV56ACRE.js?v=ab71cf02:92642
manageInput @ chunk-SV56ACRE.js?v=ab71cf02:92651
(anonymous) @ chunk-SV56ACRE.js?v=ab71cf02:92601
postMessage
executeConnection @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:14171
await in executeConnection
(anonymous) @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:14153
fetch @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:14151
fetchMeshCompute @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:14147
(anonymous) @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:30079
setInterval
newUpdater @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:13925
MeshConnection @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:30093
_VirtualTilesController @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:32151
setupTiles @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:81742
VirtualFragmentsModel @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:81190
createModel @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:81808
execute @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:81783
ThreadController.thread.actions.<computed> @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:18374
handler @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:82089
manageConnection @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:14180
manageInput @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:14189
(anonymous) @ 788e948f-0e2d-479e-a4e1-2f5c33de869e:14139
postMessage
executeConnection @ chunk-SV56ACRE.js?v=ab71cf02:92633
await in executeConnection
(anonymous) @ chunk-SV56ACRE.js?v=ab71cf02:92615
fetch @ chunk-SV56ACRE.js?v=ab71cf02:92613
fetch @ chunk-SV56ACRE.js?v=ab71cf02:99618
setup @ chunk-SV56ACRE.js?v=ab71cf02:79993
_setup @ chunk-SV56ACRE.js?v=ab71cf02:84580
load @ chunk-SV56ACRE.js?v=ab71cf02:99860
(anonymous) @ navigators.ts:112
await in (anonymous)
$RefreshSig$ @ App.tsx:12
executeDispatch @ react-dom_client.js?v=ab71cf02:13622
runWithFiberInDEV @ react-dom_client.js?v=ab71cf02:997
processDispatchQueue @ react-dom_client.js?v=ab71cf02:13658
(anonymous) @ react-dom_client.js?v=ab71cf02:14071
batchedUpdates$1 @ react-dom_client.js?v=ab71cf02:2626
dispatchEventForPluginEventSystem @ react-dom_client.js?v=ab71cf02:13763
dispatchEvent @ react-dom_client.js?v=ab71cf02:16784
dispatchDiscreteEvent @ react-dom_client.js?v=ab71cf02:16765
<button>
exports.jsxDEV @ react_jsx-dev-runtime.js?v=ab71cf02:247
$RefreshSig$ @ App.tsx:23
react_stack_bottom_frame @ react-dom_client.js?v=ab71cf02:18509
renderWithHooksAgain @ react-dom_client.js?v=ab71cf02:5729
renderWithHooks @ react-dom_client.js?v=ab71cf02:5665
updateFunctionComponent @ react-dom_client.js?v=ab71cf02:7475
beginWork @ react-dom_client.js?v=ab71cf02:8525
runWithFiberInDEV @ react-dom_client.js?v=ab71cf02:997
performUnitOfWork @ react-dom_client.js?v=ab71cf02:12561
workLoopSync @ react-dom_client.js?v=ab71cf02:12424
renderRootSync @ react-dom_client.js?v=ab71cf02:12408
performWorkOnRoot @ react-dom_client.js?v=ab71cf02:11766
performWorkOnRootViaSchedulerTask @ react-dom_client.js?v=ab71cf02:13505
performWorkUntilDeadline @ react-dom_client.js?v=ab71cf02:36
<App>
exports.jsxDEV @ react_jsx-dev-runtime.js?v=ab71cf02:247
(anonymous) @ main.tsx:8Validations ✅
- Read the docs.
- Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a repository issue and not a framework-specific issue. For example, if it's a THREE.js related bug, it should likely be reported to mrdoob/threejs instead.
- Check that this is a concrete bug. For Q&A join our Community.
- The provided reproduction is a minimal reproducible example of the bug.
Metadata
Metadata
Assignees
Labels
bugSomething isn't working
Activity
agviegas commentedon Jul 14, 2026
Fixed in
4019a8bc(components) and ThatOpen/engine_fragment@c85a00a (fragments), shipping in the next release. Your StackBlitz made this easy, thanks.There were three bugs stacked on top of each other, each one hiding the next.
The throw you saw comes from dispose ordering.
Components.dispose()walks its components in insertion order, and disposing a world nulls its scene, camera and renderer, after which the world's getters throw on purpose. So any component still cleaning up against its world blew up halfway through, and everything after it was left undisposed. In your case it wasSimplePlane.disposereaching for the camera by way ofCivilCrossSectionNavigator. Worlds are now disposed after the components that depend on them, the same way fragments already was.SimplePlanealso guarded that access withworld.camera?.controls, which looks safe but isn't, since optional chaining doesn't save you from a getter that throws. It checks the world properly now.Once dispose stopped aborting early, two more surfaced.
SimpleWorld.disposewasn't idempotent, and disposing twice is completely normal in React: your components dispose on unmount, and thenbim-world-2dgets removed from the DOM and disposes its world again. AndAlignmentsManager.disposein fragments was treating alignment groups as meshes, reading an undefined geometry and throwing. Both fixed.That also explains the blank navigators you had to reload the page to fix: it wasn't a separate bug, the teardown was just aborting partway and leaving the app half destroyed, so the next mount started from a broken state. I rebuilt your scenario as a load / dispose / load cycle and both views come back correctly now.
fix(core): make disposing an app safe and repeatable (#756)
fix(alignments): dispose all alignment geometries and materials inste…