Files PDF Quick Look loads every page text layer at once #1265

Closed
opened 2026-10-07 00:05:00 +00:00 by kayg · 4 comments
Owner

Steps

  1. Run bun e2e/files.mjs --pdf-a11y-only against the production SPA and local server.
  2. Open the 16-page CSP worker check.pdf in Quick Look.
  3. Count .pdf-page-group[data-text-loaded="true"] after the first text layer appears.

Expected

Only pages near the PDF viewport have text layers loaded, as checked by the existing regression assertion.

Actual

The viewer reported all 16 of 16 text layers loaded while the PDF viewport was at its first page. The existing assertion loadedTextPages > 0 && loadedTextPages < 16 failed. The run passed the Quick Look accessible-heading check before failing here.

Evidence

Screenshot: artifacts/bash-files/files/pdf-text-overfetch.png
Console: PDF text layers loaded: 16/16

Severity: minor (PDF preview eagerly loads text for every page in this 16-page fixture; larger documents may use more CPU and memory).

## Steps 1. Run `bun e2e/files.mjs --pdf-a11y-only` against the production SPA and local server. 2. Open the 16-page `CSP worker check.pdf` in Quick Look. 3. Count `.pdf-page-group[data-text-loaded="true"]` after the first text layer appears. ## Expected Only pages near the PDF viewport have text layers loaded, as checked by the existing regression assertion. ## Actual The viewer reported all 16 of 16 text layers loaded while the PDF viewport was at its first page. The existing assertion `loadedTextPages > 0 && loadedTextPages < 16` failed. The run passed the Quick Look accessible-heading check before failing here. ## Evidence Screenshot: `artifacts/bash-files/files/pdf-text-overfetch.png` Console: `PDF text layers loaded: 16/16` Severity: minor (PDF preview eagerly loads text for every page in this 16-page fixture; larger documents may use more CPU and memory).
Author
Owner

Confirmed after merging origin/dev (build 7e14f7181): bun e2e/files.mjs --pdf-a11y-only still reports PDF text layers loaded: 16/16 at the first viewer page and fails the existing near-page assertion. The Files Quick Look accessible-heading check passes first. Updated screenshot: artifacts/bash-files/files/pdf-text-overfetch-postmerge.png.

Confirmed after merging `origin/dev` (build `7e14f7181`): `bun e2e/files.mjs --pdf-a11y-only` still reports `PDF text layers loaded: 16/16` at the first viewer page and fails the existing near-page assertion. The Files Quick Look accessible-heading check passes first. Updated screenshot: `artifacts/bash-files/files/pdf-text-overfetch-postmerge.png`.
Author
Owner

Round 2 production reproduction on 2026-10-07:

  • Built apps/web with bun run build and used the worktree-built calternal-server with a fresh Home under target/tmp.
  • Ran bun e2e/files.mjs --pdf-a11y-only.
  • The 16-page accessible PDF rendered its first canvas, then failed the existing assertion at apps/web/e2e/files.mjs:1666: text layers load only within the near-page range.
  • The test first confirms at least one text layer loaded and expects fewer than 16; this failure therefore confirms all 16 text layers loaded on the first page.

Evidence: existing screenshot artifacts/bash-files/files/pdf-text-overfetch.png; the production run used the same real Files Quick Look path and real PDF.js renderer. Fix and regression test are in progress on job/bash-files.

Round 2 production reproduction on 2026-10-07: - Built `apps/web` with `bun run build` and used the worktree-built `calternal-server` with a fresh Home under `target/tmp`. - Ran `bun e2e/files.mjs --pdf-a11y-only`. - The 16-page accessible PDF rendered its first canvas, then failed the existing assertion at `apps/web/e2e/files.mjs:1666`: `text layers load only within the near-page range`. - The test first confirms at least one text layer loaded and expects fewer than 16; this failure therefore confirms all 16 text layers loaded on the first page. Evidence: existing screenshot `artifacts/bash-files/files/pdf-text-overfetch.png`; the production run used the same real Files Quick Look path and real PDF.js renderer. Fix and regression test are in progress on `job/bash-files`.
Author
Owner

Fixed on job/bash-files in commit 43692647c8d17c559a49d478a59134ddd72fbef5.

The production reproduction showed the PDF scroll viewport was 868 px tall, but its implicit grid rows advanced by only 53 px while each page box was 1,139 px tall. The boxes overlapped, so every page intersected the observer. The PDF now gives each page a max-content row and separates canvas pre-rendering from text, structure and link rendering. Text layers render only when their page is visible.

Verification: bun run build passed. bun e2e/files.mjs --pdf-a11y-only --screenshots /home/kayg/Developer/calternal-wt/bash-files/artifacts/bash-files/files passed with PASS PDF Quick Look text, link, lazy-loading and image-only accessibility and CSP REPORTS files: 0 across 2 pages. The test confirmed offscreen pages start without text, visible page text is accessible, scrolling to page 16 loads its text, and Enter opens its PDF link.

Screenshot evidence: artifacts/bash-files/files/pdf-quicklook-{390,820,1440}-{light,dark}.png (Mac-emulated, CSS-scale 1x).

Fixed on `job/bash-files` in commit `43692647c8d17c559a49d478a59134ddd72fbef5`. The production reproduction showed the PDF scroll viewport was 868 px tall, but its implicit grid rows advanced by only 53 px while each page box was 1,139 px tall. The boxes overlapped, so every page intersected the observer. The PDF now gives each page a max-content row and separates canvas pre-rendering from text, structure and link rendering. Text layers render only when their page is visible. Verification: `bun run build` passed. `bun e2e/files.mjs --pdf-a11y-only --screenshots /home/kayg/Developer/calternal-wt/bash-files/artifacts/bash-files/files` passed with `PASS PDF Quick Look text, link, lazy-loading and image-only accessibility` and `CSP REPORTS files: 0 across 2 pages`. The test confirmed offscreen pages start without text, visible page text is accessible, scrolling to page 16 loads its text, and Enter opens its PDF link. Screenshot evidence: `artifacts/bash-files/files/pdf-quicklook-{390,820,1440}-{light,dark}.png` (Mac-emulated, CSS-scale 1x).
Author
Owner

Deployed to calternal.cloud in merge round 34 (d395b6e25), 2026-10-08 05:03 IST. Backup: /srv/calternal/backup-pre-m34-20261008-0132. Production healthy after 36 s; served build matches.

Deployed to calternal.cloud in merge round 34 (d395b6e25), 2026-10-08 05:03 IST. Backup: /srv/calternal/backup-pre-m34-20261008-0132. Production healthy after 36 s; served build matches.
kayg closed this issue 2026-10-07 23:54:39 +00:00
Commenting is not possible because the repository is archived.
No labels
No milestone
No project
No assignees
1 participant
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kayg/calternal-v0#1265
No description provided.