Skip to content

viewer/studio: dispose superseded loads, handle material arrays, escape texture preview/format - #6441

Open
sanchaton wants to merge 1 commit into
ItsNotRexed:mainfrom
sanchaton:fix/studio-dispose-and-escape
Open

sanchaton wants to merge 1 commit into
ItsNotRexed:mainfrom
sanchaton:fix/studio-dispose-and-escape

Conversation

@sanchaton

Copy link
Copy Markdown

Claimed in #6414 (claim comment).

Summary

  • viewer/studio.html (loadModel): dispose gltf.scene via disposeModel when a load resolves after a newer request (loadId !== modelLoadId), preventing leaked geometry/materials/textures.
  • viewer/studio.html (applyMeshShading, disposeModel): handle multi-material meshes (Array.isArray(material)) when toggling wireframe and when disposing model materials/textures, and guard disposeModel(!root) / typeof mat.dispose === 'function'.
  • viewer/studio.html (renderTexturesGrid): escape t.preview and t.format with escapeHtml(...) in both the initial 80-item batch and the "show more" batch, matching t.name.
  • tests/test_viewer_studio.cjs: add 3 regression tests covering superseded-load disposal, multi-material wireframe/disposal, and escaping t.preview / t.format in both batches.

Verification

  • node --test tests/test_viewer_studio.cjs (Node v24.21.0, Windows): 6/6 passed.
  • python -I tests/test_text_write_line_endings.py (Python 3.14.7, Windows): 3/3 passed.
  • git diff --check: clean (exit 0).
  • Synthetic inputs only; no game data, no GPU required.

AI-assisted (Antigravity).

@RELMYMathieu RELMYMathieu left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed the diff, looks good to me. Ran node --test tests/test_viewer_studio.cjs on the PR head (Node v24.22.1, Windows 11) and 6/6 pass. With the pre-fix studio.html the 3 new tests fail, so they cover the fix.

To note, there is some overlap with other open PRs:

  • #5780 also disposes superseded model loads (and aborts the request) and edits the same if (loadId !== modelLoadId) lines in loadModel, so whichever lands second needs a rebase.
  • #6529 edits the same two texture-card <img ...> lines (this.onerror=null), so a text conflict, but no real logic clash.

@gorodnoff

Copy link
Copy Markdown

Independently reviewed and tested 5d7dc5c, including a local integration onto main f3a7b0f. No new blocking finding in the stale-load cleanup, material-array handling, or texture-field escaping.

The integration has one end-of-file conflict in tests/test_viewer_studio.cjs. Keeping both sides' complete test blocks resolves it: retain main's newer paging and DDS-inspector tests, then append this PR's three tests. viewer/studio.html applies without a conflict. The resulting diff still has only the original 80 insertions / 14 deletions across two files.

Tested on Windows, Node.js v24.22.3 and Python 3.12.14:

  • Exact PR head: Studio 6/6 pass.
  • Integrated onto f3a7b0f: Studio 12/12 pass, including all nine tests on main.
  • Negative control, using main's unchanged Studio HTML with the combined tests: 9 pass / 3 fail, specifically stale-load disposal, material arrays, and hostile texture preview/format fields.
  • Additional synthetic checks: null entries in material arrays; wireframe and clay -> normals -> original restoration; disposal preserves shared clay/normal materials; hostile/Unicode preview values in both initial and appended texture cards preserve the selected URL.
  • Python compileall and make_game.py --help pass. The no-game-data scan of the changed files and git diff --check pass.

The full viewer suite is 68/69 after integration. The only failure is the existing Shift/Ctrl camera test's missing AbortController, also reproduced on unchanged main (streaming 56/57), tracked by #5692. The repository-wide newline check also fails on the unchanged tools/leonida_tui.py:753 and tools/wave_diff.py:373 writers; these are not changed by this PR.

This is synthetic CPU-only verification; no browser/GPU/driver or retail game files were used. AI-assisted review. This PR overlaps #5780 on stale-load handling and #6529 around texture image rendering, so please reconcile those when rebasing.

Attached integration patch preserves sanchaton's original change, with the test block placed after main's newer tests.
pr-6441-on-main.patch

@Courdetenis

Copy link
Copy Markdown

Independently tested head 5d7dc5c2f752de2242ba76cb7ca2c8a9c205c1a1 on Windows with Node v26.12.1 (AI-assisted, Codex).

  • node --test tests/test_viewer_studio.cjs: 6/6 pass.
  • Synthetic stale-load check (start A, start B, complete A): geometry, material and texture are all disposed; current main leaves all three undisposed.
  • python -I scripts/check_no_game_data.py viewer/studio.html tests/test_viewer_studio.cjs and diff whitespace check pass.

This checks the exact PR head, not integration with current main (which has more studio tests). No real assets, browser/WebGL or GPU test; GPU/driver: not used.

@sanchaton
sanchaton force-pushed the fix/studio-dispose-and-escape branch from 5d7dc5c to 8e082df Compare November 23, 2026 18:06
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.

4 participants