Skip to content

Offload rendering to a worker #20053

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

ryzokuken
Copy link
Collaborator

This change works on top of #20016 to move CanvasGraphics operations to a new/different worker thread, thus offloading the heavy page renders and freeing up the main thread.

@ryzokuken ryzokuken self-assigned this Jul 2, 2025
ryzokuken and others added 3 commits July 2, 2025 10:45
This is a precursor to moving the call into a
worker thread to let us use `OffscreenCanvas`. The
current position wouldn't work since we make
transformations to the canvas object after the
getContext call, which isn't allowed for
OffscreenCanvas. Also it isn't allowed to clone or
`transferControlToOffscreen` the canvas after the
`getContext` call.
Move the work of drawing the PDF onto the cavas to a worker thread
using OffscreenCanvas. This should free up the main thread a bit by
moving all of the CanvasGraphics operations to this "renderer" worker.
import { OffscreenCanvasFactory } from "./canvas_factory.js";
import { PDFObjects } from "./display_utils.js";

class RendererMessageHandler {

Check notice

Code scanning / CodeQL

Unused variable, import, function or class Note

Unused class RendererMessageHandler.
@ryzokuken ryzokuken changed the title Offload rendering to worker Offload rendering to a worker Jul 2, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants