Address background-clip: border-area performance concern
Categories
(Core :: Web Painting, enhancement)
Tracking
()
| Tracking | Status | |
|---|---|---|
| firefox162 | --- | fixed |
People
(Reporter: aleix.pol, Assigned: aleix.pol)
References
(Blocks 1 open bug)
Details
Attachments
(1 external file)
In https://phabricator.services.mozilla.com/D332906 we implemented the rendering bits by creating full border masks. This makes rendering pages with border-area clipping very slow.
Copied from phabricator:
My main concern is the cost of the WR side, in two areas:
- CPU / batching. Each border clip gets its own picture task and command buffer, so nothing batches across elements. The border segment tasks are rebuilt every frame instead of going through the render task cache the way NormalBorderData::update does. With 600 small boxes under a scale animation I see ~980 draw calls per frame vs 23 for real dotted borders (Renderer 1.66 ms vs 0.27 ms).
- Fill cost. Any primitive with a border clip is forced onto the Indirect strategy over its whole rect, so every redraw shades the empty interior several times: clear, fill, mask multiply and composite. For a 600x400 CSS box with a 12px border at DPR 1.5, that's ~2.4M pixel writes for ~55k border pixels.
Earlier I thought the picture approach was an interesting way to do this, but I hadn't realised it prevents batching when there are multiple elements on a page.
What I think we'd want to try:
- Draw per border segment like normal borders do, reusing BorderRasterization. Solid segments are drawn directly; patterned segments use a segment-sized indirect task plus a mask from the segment texture. The interior is never drawn. This would be a new strategy in get_prim_render_strategy in place of the forced Indirect.
- Keep the current full-mask path as the fallback for non-scale-offset transforms and for non-quad clip consumers (prepare_picture_clips, add_clip_mask_render_task). That's mostly the code already in this patch.
- Request segment textures through the render task cache with the same keys as NormalBorderData, so they're reused across frames and shared with real borders. This is worth doing whichever strategy we end up with.
When possible, draw the border-area per segment, avoiding the interior
render and supporting batching across elements. It allows reusing the border
segment textures and rendering logic.
Reuses the border cache.
Updated•12 days ago
|
Updated•6 days ago
|
Comment 4•5 days ago
|
||
Backed out for causing build bustages
Backout link: https://hg.mozilla.org/integration/autoland/rev/7ffef3049bbc6c271849c84004c9bca617c97139
Failure log ->ERROR - error: unused import: crate::scene_building::SceneBuilder
I've addressed the issue and submitted it again.
Description
•