Skip to content

Add experimental PDFViewer-PDFjs workload - #590

Open
canova wants to merge 4 commits into
WebKit:mainfrom
canova:pdfjs-workload
Open

canova wants to merge 4 commits into
WebKit:mainfrom
canova:pdfjs-workload

Conversation

@canova

@canova canova commented Sep 22, 2026

Copy link
Copy Markdown
Contributor

This PR adds a new experimental workload called PDFViewer-PDFjs which displays a PDF using PDF.js.

This PR builds on top of two PRs that fix some benchmark related issues: #588 and #589. Currently it includes their commits too, and I'll rebase it once they land.

Some information about the workload:

A document viewer on the pdf.js core API. It covers work like: canvas 2D drawing, rasterising glyphs from embedded fonts and JPEG decoding. The suite is remote with a single async step that renders 6 * complexity pages and their thumbnails.

Decisions worth knowing about:

  • It uses the core API rather than pdf.js' pdf_viewer.mjs, whose render queue and scroll handling schedule work with setTimeout that would land inside the measured step.
  • pdf.js continues each render chunk on requestAnimationFrame, which ties the step to the display's refresh rate. The step swaps rAF for a timer while it runs, and restores it after.
  • Nothing is rendered before the step, since pdf.js caches operator lists per page and an early render would leave the step a warm cache.
  • The fixture PDF is generated at build time with PDFKit, so its content is reviewable as code and byte-identical between builds.

Opening any remote workload outside the harness threw a TypeError on the
first stray message instead of logging it.

Note that I didn't rebuild the existing remote workloads. I checked the
others and it looks like they show a bit diff in the bundle, so I chose
to leave them for now. The next rebuild will take this up.
`StepRunner` only awaited the step body when its "type" argument was
"async". `AsyncBenchmarkStep` created an `AsyncStepRunner` without passing
that argument, so the step promise was never awaited and an async remote
step measured ~0ms with no error.

This commit makes the runner class decide instead: an `isAsync` getter
is false on `StepRunner` and true on `AsyncStepRunner`, and the type
argument is removed. Sync steps stay a plain call, since awaiting them
would add a microtask hop to the measured time.

The bug was never hit because nothing in the tree or in the open
workload PRs uses `AsyncBenchmarkStep`. But this is a requirement for
the pdf.js workload that I'm working on.
A document viewer on the pdf.js core API. It covers work like: canvas 2D
drawing, rasterising glyphs from embedded fonts and JPEG decoding. The
suite is `remote` with a single async step that renders `6
* complexity` pages and their thumbnails.

Decisions worth knowing about:

- It uses the core API rather than pdf.js' `pdf_viewer.mjs`, whose render
  queue and scroll handling schedule work with setTimeout that would land
  inside the measured step.
- pdf.js continues each render chunk on requestAnimationFrame, which ties
  the step to the display's refresh rate. The step swaps rAF for a timer
  while it runs, and restores it after.
- Nothing is rendered before the step, since pdf.js caches operator lists
  per page and an early render would leave the step a warm cache.
- The fixture PDF is generated at build time with PDFKit, so its content is
  reviewable as code and byte-identical between builds.
@netlify

netlify Bot commented Sep 22, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for webkit-speedometer-preview ready!

Name Link
🔨 Latest commit aeaeafa
🔍 Latest deploy log https://app.netlify.com/projects/webkit-speedometer-preview/deploys/6ab287f79db1fe00087559bf
😎 Deploy Preview https://deploy-preview-590--webkit-speedometer-preview.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.
🤖 Make changes Run an agent on this branch

To edit notification comments on pull requests, go to your Netlify project configuration.

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.

1 participant