Skip to content

Render 2D image edits in a reusable tiled worker - #261

Merged
vycdev merged 7 commits into
developfrom
t3/modernize-219-tiled-image-worker
Dec 1, 2026
Merged

vycdev merged 7 commits into
developfrom
t3/modernize-219-tiled-image-worker

Conversation

@vycdev

@vycdev vycdev commented Nov 30, 2026 •

Copy link
Copy Markdown
Owner

Supersedes #219 by @JohnSt99, rebased onto current develop with their commit and authorship kept. Closes #165.

The 2D adjustment preview and Apply now render in one reusable background worker, in 128×128 tiles with a one-pixel clarity halo, so seams match full-frame output:

  • Old requests are cancelled when newer ones arrive.
  • Browsers without worker canvas support fall back to the same tiled rendering on the main thread.
  • A failed preview shows an alert with Retry preview, and a failed Apply shows an error instead of quietly using the unadjusted image.
  • The color-replacement step is the shared base for the threshold, filament-matcher and nozzle features.

On the contributor's 3,072 × 2,048 test image (median of four runs):

Before Worker
Time until the changed preview is visible 262 ms 375 ms
Longest frame gap while waiting 267 ms 33 ms

Changes made while rebasing and during review:

  • Merge with Merge a color into a touching or similar one, pick colors from the image, and dim the rest #254 in CanvasPreview. The Image colors dim and merge preview takes precedence. Otherwise the worker's adjusted preview is drawn, or the raw image.
  • Dedither smoke tests. They digest only the result, which is still pinned to the goldens. The input is now encoded in the worker.
  • While Apply renders:
    • The adjustment controls, touch-up input and the Image colors inspector are paused, and slider commits are ignored.
    • A touch-up still saving when Apply is clicked lands first, as its own Undo step, and Apply starts from it.
  • Views: switching to 3D no longer cancels Dedither's input or a pending Apply. The adjustment panel remounts with the values in effect.
  • Touch-ups: a committed touch-up keeps the adjusted image on screen while it re-renders.
  • Docs: the CHANGELOG entry is under Unreleased, and the translated guides describe background rendering and Retry.

Proof:

  • Four new @smoke tests in tiled-image-editing.spec.ts hold the worker's PNG results or the touch-up toBlob. They cover a pending Apply, a 3D switch during Dedither, a fill during and before Apply, and the panel after a 3D trip. Each failed with its fix reverted and passes with it.
  • lint and tsc -b pass.
  • npm test: 1406 passed. i18n and docs checks pass.
  • Local test:e2e:all passed on fresh servers (port 52067): 218 smoke tests and all 7 area suites.

Council review

Rounds: 4

Delegate Round 1 Round 2 Round 3 Round 4
Claude Opus 5.5 7/10 8/10 7/10 9/10
GPT-6.2 Sol 7/10 8/10 7/10 not run (no approval prompts)
Gemini Pro unavailable unavailable unavailable unavailable

Round 4 found no must-fixes. The remaining nice-to-haves are edge cases where Apply does nothing and can be retried, without losing work.

🤖 Generated with Claude Code

@vycdev
vycdev force-pushed the t3/modernize-219-tiled-image-worker branch from 4f4e98e to 03deacc Compare November 30, 2026 21:16
JohnSt99 and others added 6 commits November 30, 2026 23:30
The tiled image worker now captures and encodes dedither's input with
OffscreenCanvas, so the page's HTMLCanvasElement.toBlob hook sees only the
result. The result is still checked against the pinned goldens.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Apply takes the edit lock and disables the adjustment controls until its
  render lands, so a slider moved meanwhile is not baked over and reset.
- Unmounting the preview, such as switching to 3D, no longer cancels an
  export still in flight; the worker stays until it settles, so Dedither's
  input arrives. A new image still cancels it.
- A committed touch-up keeps the current adjusted image on screen while the
  worker re-renders, instead of falling back to the raw image.
- The changelog entry moves from v4.3.0 to Unreleased, and the translated
  image adjustment guides describe background rendering and Retry.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Holding the processing lock during Apply refused an Apply started while a
touch-up's snapshot was still loading, and rolled back that touch-up. Apply
now starts like before and instead disables the adjustment controls and
ignores slider commits until it lands.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
- Touch-up tools wait while Apply, or any other image edit that holds the
  lock, is running. A fill or stroke accepted meanwhile landed first and
  left Apply with a stale image, so Apply was dropped.
- The adjustment panel mounts with the adjustments in effect, so after a
  trip to 3D it shows them and Apply bakes them, instead of showing zero.
- The renderer updates its current-image ref during render, so an export
  started right after an image change is not cancelled as stale.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Disabling touch-ups for Apply also ran the processing rollback, which
dropped a fill or stroke whose save was still running. Apply now pauses
touch-up input without the rollback, waits for queued saves and the
render they cause, and only then takes the edit guard, so the touch-up
keeps its own Undo step and Apply starts from it. The Image colors
inspector, whose merge popover sits outside the disabled panel, is off
while Apply runs.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@vycdev
vycdev force-pushed the t3/modernize-219-tiled-image-worker branch from 03deacc to 32bd48c Compare November 30, 2026 21:32
@vycdev
vycdev merged commit d44d8d4 into develop Dec 1, 2026
14 checks passed
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