Skip to content

Render overlay canvas in a worker - #591

Draft
aidenybai wants to merge 1 commit into
mainfrom
codex/offscreen-canvas-worker
Draft

Render overlay canvas in a worker#591
aidenybai wants to merge 1 commit into
mainfrom
codex/offscreen-canvas-worker

Conversation

@aidenybai

@aidenybai aidenybai commented Jul 20, 2026

Copy link
Copy Markdown
Owner

Summary

  • move overlay selection, drag, and grabbed-box painting into a dedicated worker using a transferred OffscreenCanvas
  • bundle the worker source at build time and instantiate it from an inline blob
  • share one renderer between the worker and the normal main-thread canvas fallback
  • preserve DPR, Display P3, zoom, and animation behavior, with coverage for both rendering paths

Why

The existing canvas layers still ran their animation and compositing loop on the main thread. This isolates that work where supported while retaining the current canvas behavior in browsers without transferable offscreen canvases.

Validation

  • nr build
  • nr typecheck
  • nr lint
  • nr format
  • E2E_ENVIRONMENT=vite-plus-development nr test -- e2e/overlay-canvas-worker.spec.ts e2e/zoom-canvas.spec.ts (164 unit tests and 3 focused browser tests)

Summary by cubic

Render the overlay canvas in a dedicated worker via a transferred OffscreenCanvas, with a main-thread fallback. Preserves DPR, Display P3, zoom, and animation behavior, and bundles the worker inline for reliable startup.

  • New Features

    • Added worker-backed overlay renderer with OffscreenCanvas transfer; shared renderer used for both worker and main-thread paths.
    • Bundled worker source at build time and instantiated from a blob URL.
    • Added backend detection and a data-react-grab-overlay-backend attribute for observability.
    • Improved label fade handling and animation scheduling across both paths.
    • Added e2e tests for worker and fallback paths, plus a pixel diff utility; updated zoom test to use screenshot diffs.
  • Dependencies

    • Added esbuild to bundle the inline worker.

Written for commit cbc9761. Summary will update on new commits.

Review in cubic

@vercel

vercel Bot commented Jul 20, 2026

Copy link
Copy Markdown
Contributor

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

Project Deployment Actions Updated (UTC)
react-grab-storybook Ready Ready Preview, Comment Jul 20, 2026 6:04am
react-grab-website Ready Ready Preview, Comment Jul 20, 2026 6:04am

@pkg-pr-new

pkg-pr-new Bot commented Jul 20, 2026

Copy link
Copy Markdown

Open in StackBlitz

npm i https://pkg.pr.new/@react-grab/cli@591
npm i https://pkg.pr.new/grab@591
npm i https://pkg.pr.new/react-grab@591

commit: cbc9761

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.

1 participant