Skip to content

studio: a failed texture preview no longer re-fires its onerror forever - #6529

Merged
shayderrr merged 1 commit into
ItsNotRexed:mainfrom
dukefissura:studio-tex-onerror-loop
Nov 23, 2026
Merged

shayderrr merged 1 commit into
ItsNotRexed:mainfrom
dukefissura:studio-tex-onerror-loop

Conversation

@dukefissura

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: STUDIO-TEX-ONERROR-LOOP (posted in #6414)

Depends on: none. It conflicts only textually with #5780 in tests/test_viewer_studio.cjs, where both add a test at the same place. It applies cleanly with #5017 and #5083.

What and why

The texture cards in viewer/studio.html (the first 80 and the "show all" ones) handled a preview that failed to load with onerror="this.src=''; this.alt='DDS / Pre-converted'". Chromium fires error again for every src='' it is given, so this handler re-ran itself without end. Measured in Chromium 156: about 424,000 error events in 3 s for a single image, which is one pinned CPU core per broken preview. A preview fails, for example, when the gallery answers 404 for a DDS format dds_png can't convert.

The handler now clears itself first (this.onerror=null; ...), as the three <script> tags at the top of the same file already do. Measured in the same browser, it then runs once and the card still shows the DDS / Pre-converted text.

Tested

Linux, Node 22.23.5, plus Chromium 156 for the before/after event counts. No GPU or driver involved, no game files.

  • node --test tests/test_viewer_studio.cjs: 4/4 on top of main 1cc6e3c.
  • The new a texture preview that fails to load fires its error handler once, not in a loop test renders both card paths through the existing renderTextureGrid helper and runs each onerror on a fake image that fires the handler again on every src write, as Chromium does. It fails without the viewer/studio.html change and passes with it.
  • tests/test_viewer_streaming.cjs: the only failure is the Shift/Ctrl test that already fails on main (fixed by test(viewer): pass AbortController and timers into camera-speed vm context #5692).
  • git diff --check is clean.

AI-assisted: yes (Claude)

Checklist

  • No game data, keys or decryption (CONTRIBUTING.md), including in logs or reports quoted here.
  • A new translator rule is in the contract table of docs/design.md, with how it was confirmed. (Not applicable: no translator change.)

…r handler forever

The texture cards in viewer/studio.html (the first 80 and the "show all" ones) handled a failed preview
with onerror="this.src=''; ...". Chromium fires error again for every src='' it is given, so the
handler re-ran itself without end: about 424,000 error events in 3 s for one card in Chromium 156,
one pinned CPU core per broken preview (for example a 404 for a DDS format dds_png can't convert).
The handler now clears itself first (this.onerror=null), as the script tags in the same file already
do; measured in the same browser it then runs once.

tests/test_viewer_studio.cjs: a fake image that fires the handler again on every src write, as that
browser does, runs each card path's handler; it fails before the change and passes after.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Fi5BEBqGPiXnY67f9mzu13
@Juryii

Juryii commented Nov 23, 2026

Copy link
Copy Markdown

Independent source/Node check of 364563c681e9f1815f21d86c8ab995f392ad2faf on Windows, Node v20.19.3: node --test tests/test_viewer_studio.cjs — 4 passed; git diff --check clean; checkout unchanged.

Negative control: copied the exact new test file into an external scratch fixture with the actual parent viewer/studio.html. Three tests pass and precisely the new error-handler test fails (the handler ran 1000 times). No repository files changed.

Also exercised both source handlers with an asynchronous event-queue simulation, rather than the suite's synchronous setter re-entry. Resetting src queues another error event; dispatch consults the image's current onerror property. On head, each card path invokes the handler once, leaves onerror === null, retains the fallback alt text, and drains the second event without another handler call. Parent handlers keep re-queuing themselves (stopped at 32 calls, with an event still pending). This checks the first-80 and show-all paths separately.

No blocking finding from the source and JavaScript checks. No independent native-browser verification here: the available browser environment could not reach the local fixture, so I cannot corroborate the Chromium timing/event-rate measurement. The event-queue check above is explicitly a simulation, not a browser run. No GPU, game files or external services used for these tests.

AI-assisted review with Codex; tests and negative control executed locally.

@shayderrr shayderrr left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Summary

viewer/studio.html sets this.onerror=null before clearing src in both texture-card <img> handlers (first 80 and "show all"), so Chromium's repeat error on src='' cannot re-enter the handler. tests/test_viewer_studio.cjs adds a fake image whose src setter refires onerror and asserts both inline handlers run exactly once and leave the fallback alt text.

Why merge

Fixes a real infinite error loop observed at ~424,000 firings in 3 s on Chromium 156. Test reproduces the browser behaviour without a browser.

Verdict: Approve

@shayderrr

Copy link
Copy Markdown
Collaborator

Summary

viewer/studio.html sets this.onerror=null before clearing src in both texture-card <img> handlers (first 80 and "show all"), so Chromium's repeat error on src='' cannot re-enter the handler. tests/test_viewer_studio.cjs adds a fake image whose src setter refires onerror and asserts both inline handlers run exactly once and leave the fallback alt text.

Why merge

Fixes a real infinite error loop observed at ~424,000 firings in 3 s on Chromium 156. Test reproduces the browser behaviour without a browser.

Verdict: Approve

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.

3 participants