Skip to content

Use blob object URL for browser editor placeholder screenshot#318473

Merged
dmitrivMS merged 1 commit into
mainfrom
dev/dmitriv/perf-duplicate-image-data
May 27, 2026
Merged

Use blob object URL for browser editor placeholder screenshot#318473
dmitrivMS merged 1 commit into
mainfrom
dev/dmitriv/perf-duplicate-image-data

Conversation

@dmitrivMS
Copy link
Copy Markdown
Contributor

The integrated browser editor's placeholder screenshot was set via a base64 data URL on style.backgroundImage. For every visible browser tab this kept the JPEG bytes alive three times: as a VSBuffer, as a ~1.33x base64 JS string, and as the parsed CSS data URL value.

This change builds a Blob from the VSBuffer and uses URL.createObjectURL instead. The object URL is revoked when the screenshot is replaced or the editor is disposed.

Motivated by heap snapshots showing duplicate retention of screenshot image data.

Replaces base64 data URL with a Blob + URL.createObjectURL so the JPEG screenshot bytes are not simultaneously retained as a VSBuffer, a ~1.33x base64 JS string, and a parsed CSS data URL. The object URL is revoked when the screenshot is replaced or the editor is disposed.
Copilot AI review requested due to automatic review settings May 27, 2026 00:36
@dmitrivMS dmitrivMS self-assigned this May 27, 2026
@dmitrivMS dmitrivMS requested review from jruales and kycutler May 27, 2026 00:36
@dmitrivMS dmitrivMS enabled auto-merge (squash) May 27, 2026 00:37
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR reduces memory overhead in the integrated browser editor (desktop/electron) by switching the placeholder screenshot from a base64 data: URL (stored in JS/CSS strings) to a Blob-backed blob: object URL, and ensuring the URL is revoked when replaced or when the editor is torn down.

Changes:

  • Replace base64 encoding of screenshot buffers with Blob + URL.createObjectURL.
  • Track and revoke the active object URL on screenshot replacement, clearInput, and dispose.
Show a summary per file
File Description
src/vs/workbench/contrib/browserView/electron-browser/browserEditor.ts Use blob: object URLs for placeholder screenshot background images and revoke them to prevent memory retention.

Copilot's findings

  • Files reviewed: 1/1 changed files
  • Comments generated: 0

@dmitrivMS dmitrivMS merged commit 2ce2e46 into main May 27, 2026
26 checks passed
@dmitrivMS dmitrivMS deleted the dev/dmitriv/perf-duplicate-image-data branch May 27, 2026 00:58
@vs-code-engineering vs-code-engineering Bot added this to the 1.123.0 milestone May 27, 2026
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