Repository navigation
Open PDFs a little faster: get the PDF reader ready early and keep one (v54) - #55
Merged
Merged
Conversation
…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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.jsgetswarmPdfjs()(called once at startup, when the browser is idle),pdfWorker()(one sharedPDFWorker, passed togetDocument) anddropPdfWorker()(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. InopenFile, pdf.js loads while the file is read, and the SHA-256 runs while the PDF opens.crypto.subtle.digestcopies 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-latestbecame 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