Open Bug 2093297 Opened 17 days ago Updated 2 days ago

pdf.js's image scaling causes readback when it draws a large canvas to a small canvas

Categories

(Core :: Graphics: Canvas2D, defect, P3)

defect

Tracking

()

Tracking Status
firefox162 --- affected

People

(Reporter: mstange, Unassigned)

References

(Depends on 1 open bug, Blocks 1 open bug)

Details

pdf.js now defaults to using hardware accelerated canvases by default. But as part of drawing, it sometimes draws a large canvas to a small canvas. We have a minimum size for hardware accelerated canvas (128, gfx.canvas.accelerated.min-size), so often these draws go into a non-accelerated canvas, and we're forced to do a readback of the large canvas. For these small canvases we also turn off remoteness, so the readback blocks the content process main thread, rather than just blocking the canvas worker in the GPU process.

The experimental pdf.js workload in Speedometer hits this: https://webkit-speedometer-preview.netlify.app/?suites=PDFViewer-PDFjs
Profile: https://share.firefox.dev/3Vtxrkg

I could see three remedies:

  1. Remove the minimum size; check where the per-GPU-canvas overhead is coming from and reduce it
  2. Don't make software canvases render on the main thread, keep using remoteness
  3. Accelerate small canvases if the first draw to them after buffer reset is a drawImage from an accelerated canvas
Depends on: 2094308
Depends on: 2098754

Setting severity S3 / priority P3 by comparison with similar triaged Canvas2D readback and performance bugs (e.g. bug 2038926, S3): a main-thread stall in a specific workload, with the main mitigation (bug 2094308) already landed.

Blocks: gfx-triage
Severity: -- → S3
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.