Skip to content

Open PDFs a little faster: get the PDF reader ready early and keep one (v54) - #55

Merged
BPMData merged 2 commits into
mainfrom
claude/project-thread-3x2ucv
Nov 24, 2026
Merged

BPMData merged 2 commits into
mainfrom
claude/project-thread-3x2ucv

Conversation

@BPMData

@BPMData BPMData commented Nov 24, 2026 •

Copy link
Copy Markdown
Owner

Before: the PDF app only started loading its PDF reader (PDF.js plus its 1.4 MB worker) after you picked a file. Every PDF you opened, including Open again and each "add a page" in a notebook, started a brand-new reader. It also worked out the PDF's fingerprint (used to find its saved ink) before the PDF could start opening.

After: the reader loads in the background while the start screen is up, and one reader is kept and shared by every PDF the tab opens. The fingerprint is worked out at the same time as the PDF opens.

Nothing you see changes. The first PDF, Open again and adding notebook pages should just feel a bit quicker, most of all on slower board PCs and with big PDFs.

How: app/libs.js gets warmPdfjs() (called once at startup, when the browser is idle), pdfWorker() (one shared PDFWorker, passed to getDocument) and dropPdfWorker() (if a PDF fails to open, the next one gets a fresh reader, in case that one broke). PDF.js doesn't stop a worker it didn't make, so closing a PDF leaves the reader running for the next one. In openFile, pdf.js loads while the file is read, and the SHA-256 runs while the PDF opens. crypto.subtle.digest copies the bytes when it's called, so handing the bytes to the reader right after is safe.

The HTML overlay doesn't change: it has no PDF reader. Its only change is the version number (v54).

Also in this PR: the tests now run on Ubuntu 24.04. GitHub's ubuntu-latest became Ubuntu 26.04, where Playwright 1.56 can't install Chromium, so the test job failed before any test ran. This would hit every PR, not just this one.

I didn't measure the speedup: no browser could be installed where this was written. The full test suite passes on CI, including opening PDFs, notebooks and Open again.

🤖 Generated with Claude Code

…e (v54)

The PDF reader (PDF.js and its 1.4 MB worker) now loads while the start
screen is up, one reader is shared by every PDF the tab opens (Open again,
adding a notebook page), and the PDF's fingerprint is worked out while the
PDF opens instead of before.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… 26.04, which ubuntu-latest now is)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@BPMData
BPMData merged commit 13f88cc into main Nov 24, 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.

2 participants