Skip to content

Fix image preview copy performance by using a worker for encoding - #341783

Merged
Logan Ramos (lramos15) merged 2 commits into
mainfrom
lramos15/agents/fix-terminal-encoding-issue-88636145
Oct 15, 2026
Merged

Logan Ramos (lramos15) merged 2 commits into
mainfrom
lramos15/agents/fix-terminal-encoding-issue-88636145

Conversation

@lramos15

Copy link
Copy Markdown
Member

Fix #341527

Copilot AI balanced review requested due to automatic review settings October 15, 2026 14:28
@lramos15
Logan Ramos (lramos15) enabled auto-merge (squash) October 15, 2026 14:28

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

Synchronous bitmap-transfer failures bypass cleanup and leak resources.

1 open finding
What changed in this PR

Addresses delayed image-preview copying in #341527 by moving PNG encoding to a worker.

Changes:

  • Adds worker-based encoding with a main-thread fallback.
  • Allows blob workers in the preview’s content security policy.
File Description
extensions/​media-preview/​src/​imagePreview/​index.ts Permits blob workers.
extensions/​media-preview/​media/​imagePreview.js Adds worker encoding and fallback handling.

🧠 Review effort: Balanced


💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

If postMessage throws synchronously (for example a DataCloneError for a bitmap that isn't origin-clean), neither worker handler runs, so the worker, its blob URL and the bitmap were never released. Repeated failed copies could accumulate them. Handle worker creation, handler setup and the transfer under one try so every synchronous failure cleans up before falling back to toBlob().

Refs #341527

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
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.

Image preview Copy is intermittently delayed by 1–7 seconds

3 participants