Skip to content

Fix blurry high-zoom PDF rendering caused by detail canvas positioning - #4986

Merged
James-Yu merged 1 commit into
James-Yu:masterfrom
caixq1996:fix/pdf-detail-canvas-position
Sep 18, 2026
Merged

James-Yu merged 1 commit into
James-Yu:masterfrom
caixq1996:fix/pdf-detail-canvas-position

Conversation

@caixq1996

Copy link
Copy Markdown
Contributor

PDF text stays blurry at high zoom because the position: relative !important override in latexworkshop.css applies to PDF.js's detail canvas as well as its base canvas. Restrict the override to the first canvas so the high-resolution detail canvas can retain PDF.js's absolute positioning and cover the low-resolution base.

Reproduction and cause

  1. Open a vector PDF in the internal viewer.
  2. Increase the zoom until PDF.js creates a detail canvas (reproduced at 400% and 800%).
  3. Wait for rendering to finish. Text remains visibly pixelated.

PDF.js inserts the detail canvas immediately after the base canvas and positions it over the visible part of the page. The existing rule instead puts it in normal flow below the full-height base canvas, where the page's overflow clipping hides it.

In a Chromium reproduction at 400%, the base canvas was displayed at 3264 × 4224 CSS pixels. The detail canvas had finished rendering but its bounding rectangle started at y=4224 rather than y=0. With this selector change, the base remains position: relative, the detail canvas becomes position: absolute, and its top is correctly y=0. Text is sharp again without changing canvas limits or disabling detail rendering.

Validation

  • npm run compile — passed on upstream 52f8c9e with this change.
  • npm run lint — passed.
  • git diff --check — passed.
  • Reproduced the blur and verified the fix with PDF.js 6.2.108 in Chromium at 400% and 800%.
  • Reopened the PDF in VS Code's internal viewer on Windows with Remote SSH and visually verified sharp text at 400%.

The patch preserves the existing positioning of the base canvas and leaves PDF.js's rendering and memory limits unchanged.

Copilot AI lite review requested due to automatic review settings September 18, 2026 07:42

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.

🟢 Approval recommended

The change correctly preserves PDF.js detail-canvas positioning without affecting rendering limits.

Pull request overview

This PR fixes blurry high-zoom PDF rendering by limiting the relative-position override to PDF.js’s base canvas.

Changes:

  • Restricts the CSS override to canvas:first-child.
  • Preserves absolute positioning for detail canvases.
File summaries
File Description
viewer/latexworkshop.css Updates canvas positioning selector and documents its purpose.
Review details
  • Files reviewed: 1/1 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@James-Yu
James-Yu merged commit a259abf into James-Yu:master Sep 18, 2026
1 check 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.

3 participants