Make Software Canvas2D remote, too (except for willReadFrequently)
Categories
(Core :: Graphics: Canvas2D, enhancement)
Tracking
()
People
(Reporter: mstange, Unassigned)
References
(Blocks 2 open bugs)
Details
Attachments
(4 external files)
On platforms where we use DrawTargetWebGL, we have a minimum size of 128x128 before a canvas is eligible for acceleration; anything smaller than that gets software. Today, accelerated canvases run in the GPU process, but software canvases run on the content process main thread.
When a site mixes large and small canvases and draws between them, sometimes there are readbacks: A draw to a small (software) canvas can require the contents of a large (accelerated) canvas. This readback currently blocks the main thread, and it needs to wait both for the CPU to finish executing the queued render commands, and for the GPU to finish the accelerated rendering. The wait for the CPU is often the bigger part. I fixed one case of readbacks in bug 2094308 but there are many other cases where this still happens.
If we can make software rendering happening in the GPU process too, then the main thread won't be blocked and is free to do more useful things while rendering continues. This helps our pdf.js performance tests in CI, see bug 2093297 and bug 2096586 comment 4.
| Reporter | ||
Updated•1 day ago
|
| Reporter | ||
Comment 1•1 day ago
|
||
No behavior change: every caller still asks for an immediate restore. A later
patch uses this to report a canvas as lost without restoring it.
| Reporter | ||
Comment 2•1 day ago
|
||
Some texture types have size limits that a plain buffer does not have, such as
the maximum D3D11 texture size. The content process already falls back to a
buffer in TextureClient::CreateForDrawing. Do the same in the GPU process.
So far, a canvas this large rarely reached the GPU process, because the content
process only makes a canvas remote within gfx.canvas.accelerated.max-size. That
changes once canvases that can't be accelerated stay in the GPU process.
| Reporter | ||
Comment 3•1 day ago
|
||
Behind gfx.canvas.remote.software, default false.
Today, a canvas that can't be accelerated draws on the content process main
thread. When content draws an accelerated canvas into such a canvas, the main
thread blocks on a readback until the GPU process has finished all queued
commands. If both canvases live in the GPU process, no readback is needed.
With the pref on, the content process makes every 2D canvas remote, except
willReadFrequently canvases. The GPU process never asks content to fall back.
If DrawTargetWebgl can't be used, the canvas continues on a software DrawTarget
in the GPU process. If that can't be allocated either, the canvas is reported
as lost: falling back to content would allocate the same kind of buffer, within
the same size limits. Resizing a lost canvas attempts to restore it.
The new gfxVar UseRemoteCanvas2D is separate from UseAcceleratedCanvas2D, so
that remote canvas stays available when acceleration is off.
| Reporter | ||
Comment 4•1 day ago
|
||
Description
•