Skip to content

studio: opening a texture no longer shows the previous one - #6697

Closed
dukefissura wants to merge 1 commit into
ItsNotRexed:mainfrom
dukefissura:studio-modal-stale-image
Closed

dukefissura wants to merge 1 commit into
ItsNotRexed:mainfrom
dukefissura:studio-modal-stale-image

Conversation

@dukefissura

Copy link
Copy Markdown
Contributor

Claimed in the coordination issue as: STUDIO-MODAL-STALE-IMAGE (in #6603)

Depends on: none. It conflicts only textually with my STUDIO-EU-STRINGS PR and with #6529 in tests/test_viewer_studio.cjs, where each adds a test; viewer/studio.html changes don't overlap.

What and why

openModal in viewer/studio.html set the new title and changed only the image's src. Chromium keeps showing the image it already has while a new src loads. Measured in Chromium 156: right after the swap, currentSrc is still the old URL and naturalWidth is still the old image's. So the texture modal showed the last texture under the next texture's name until the new preview arrived, which for a DDS means a conversion on the server.

The src attribute is now removed before the new one is set (measured in the same browser: naturalWidth is 0 until the new image loads), so the modal shows nothing rather than the wrong texture. The image's alt is the texture's name.

Tested

Linux, Node 22.23.5, plus Chromium 156 for the currentSrc / naturalWidth measurement. No GPU or driver involved, no game files.

  • node --test tests/test_viewer_studio.cjs: 4/4 on top of main 1cc6e3c.
  • The new opening a texture clears the previous one instead of showing it under the new name test uses a fake image that keeps showing its picture until a new one loads, as Chromium does. After openModal, the old texture must no longer be shown. It fails without the viewer/studio.html change (still showing /textures/a.png) 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.)

…new name

openModal set the new title and changed only the image's src. Chromium keeps showing the image it
has while a new src loads (currentSrc stays the old URL; measured in Chromium 156), so the modal
showed the last texture under the next texture's name until the new preview arrived, which for a DDS
is a conversion on the server. The src attribute is now removed before the new one is set, so the
modal is empty until the right picture loads, and the image's alt is the texture's name.

tests/test_viewer_studio.cjs: a fake image that keeps showing its picture until a new one loads, as
Chromium does; after openModal the old texture must no longer be shown. It fails before the change.

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

Copy link
Copy Markdown
Contributor

Independent AI-assisted check of 4ccbdd63 vs 1cc6e3c1 in T3 Preview on Windows (Chromium 152.0.7977.167), using exact Studio HTML and synthetic PNGs.

Within the same JavaScript turn as opening B, base still reported A as currentSrc at width 17 under title B. Head immediately reported an empty currentSrc, width 0, and B as title and alt. Base cleared by the next microtask on this browser, so I observed the immediate stale DOM state but did not measure a sustained visible stale frame.

With B held for 1.6 seconds and C opening during that delay, the modal stayed on C on both revisions after B finished decoding in a companion thumbnail. The final modal sampled C's blue pixel and width 43; head also kept C as alt. Closing during B and reopening on C gave the same result. Stock Studio tests passed 3/3 on base and 4/4 on head with Node 24.16.0.

@dukefissura

Copy link
Copy Markdown
Contributor Author

Closing: whattheflop's check was right. Measured frame by frame in Chromium 156, the base already shows no image on the first rendered frame after the swap (currentSrc is the new URL, naturalWidth 0). The old currentSrc exists only within the same JavaScript turn, so no stale texture is ever painted. My earlier measurement was synchronous only, and I overstated the bug. Thanks for checking. Releasing STUDIO-MODAL-STALE-IMAGE.

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.

2 participants