Skip to content

Dispose MixedStlModel fallback resources#898

Open
swhan0329 wants to merge 2 commits into
tscircuit:mainfrom
swhan0329:codex/dispose-mixed-stl-fallback-mesh
Open

Dispose MixedStlModel fallback resources#898
swhan0329 wants to merge 2 commits into
tscircuit:mainfrom
swhan0329:codex/dispose-mixed-stl-fallback-mesh

Conversation

@swhan0329
Copy link
Copy Markdown

@swhan0329 swhan0329 commented May 20, 2026

/claim #93

Summary

  • Track whether MixedStlModel is rendering its locally-owned red fallback mesh or a loaded cached model.
  • Dispose the fallback mesh geometry/material when it is replaced or unmounted.
  • Reuse already-registered STEP-to-GLB blob URLs before reading the localStorage GLB cache again, avoiding duplicate object URLs for repeated STEP mounts.
  • Keep loaded OBJ/WRL model instances untouched so shared/cached loader resources are not accidentally disposed.
  • Add focused helper tests for owned-resource disposal and STEP blob URL reuse.

Why

When a board has many duplicate or slow-loading models, MixedStlModel creates fallback meshes while the model loader is pending. The transform graph removes those placeholders when the real model arrives, but the placeholder geometry/material were not disposed. The follow-up also closes a small STEP cache reuse gap where a cached GLB could create another blob URL even though the global conversion registry already had one for the same STEP URL.

Verification

  • bun test tests/step-model-cache.test.ts tests/dispose-owned-object-resources.test.ts
  • bun run format:check
  • bunx tsc --noEmit
  • bun run build
  • bun run test:node-bundle
  • git diff --check

Full test note

bun test previously had 3 failures unrelated to this change in this checkout:

  • tests/preprocess-circuit-json.test.ts: expected faux-board z offsets are 0.1 higher than current output.
  • tests/outline-bounds.test.ts: expected soldermask color string does not match current rendered SVG color.

AI-assisted with Codex; I reviewed the diff and verification output before opening and updating this PR.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 20, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
3d-viewer Ready Ready Preview, Comment May 20, 2026 2:37am

Request Review

@swhan0329
Copy link
Copy Markdown
Author

Review-ready follow-up: all attached checks are green on this PR (format-check, test, type-check, Vercel, and Vercel Preview Comments), and the patch stays scoped to locally-owned fallback/STEP blob URL cleanup without touching shared OBJ/WRL cached model instances. Happy to adjust if maintainers want this split smaller.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant