Skip to content

fix: prevent crash when duplicating elements#239

Merged
open-pascal merged 1 commit intopascalorg:mainfrom
nnhhoang:fix/duplicate-crash
Apr 15, 2026
Merged

fix: prevent crash when duplicating elements#239
open-pascal merged 1 commit intopascalorg:mainfrom
nnhhoang:fix/duplicate-crash

Conversation

@nnhhoang
Copy link
Copy Markdown
Contributor

@nnhhoang nnhhoang commented Apr 15, 2026

Summary

  • Guard _buildCache in merged-outline-node against stale/disposed Object3D refs that cause TypeError: Cannot read properties of undefined (reading 'id') during WebGPU render pass
  • Reset children array when duplicating roofs to prevent inconsistent parent-child relationships (matching existing stair duplication behavior)
  • Use obj?.parent check in EditorOutlinerSync to ensure objects removed from the scene graph don't reach the outline pass
  • Resume temporal state on parse failure to prevent permanent undo/redo freeze

Closes #232

Root cause

The crash occurs due to a race condition between the post-processing render pipeline and the outliner sync. When duplication modifies the scene, renderer components may unmount/remount, leaving stale Object3D references in the outliner arrays. The MergedOutlineNode._buildCache() then calls .traverse() on these stale refs, and the WebGPU pipeline crashes accessing .id on disposed internals.

Test plan

  • Duplicate an item (select → click copy icon) — no crash
  • Duplicate a door/window on a wall — no crash
  • Duplicate a roof — children are independent from original
  • Cancel a failed duplicate — undo/redo still works
  • Existing selection outlines and hover highlights still work

- Guard _buildCache in merged-outline-node against stale/disposed
  Object3D refs that cause TypeError on .id access during render
- Reset children array when duplicating roofs to prevent inconsistent
  parent-child relationships (matching existing stair behavior)
- Use obj?.parent check in EditorOutlinerSync to ensure objects are
  still in the scene graph before adding to outliner arrays
- Resume temporal state on parse failure to prevent undo/redo freeze

Closes pascalorg#232
@open-pascal open-pascal merged commit 3d10058 into pascalorg:main Apr 15, 2026
@open-pascal open-pascal mentioned this pull request Apr 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] Crash/Error when duplicating elements(I reported bug #223 before, but it hasn't been fixed.)

2 participants