Consider not calling AllocateGeometry and ComputeInvalidationRegion for items <svg> elements
Categories
(Core :: Graphics: WebRender, defect, P2)
Tracking
()
Tracking | Status | |
---|---|---|
firefox63 | --- | affected |
People
(Reporter: mstange, Assigned: jrmuizel)
References
(Depends on 2 open bugs, Blocks 1 open bug)
Details
Attachments
(1 file)
59 bytes,
text/x-review-board-request
|
Details |
SVGs commonly have a large number of display items. Any work that we do per-item has a potentially big performance impact. Here's a profile of moving my mouse on https://www.article19.org/xpa-17-metric/ , focused on mozilla::layers::DIGroup::ComputeGeometryChange: https://perfht.ml/2vEfoLF As far as I know, SVG elements do not make use of DLBI. Anything that affects the appearance of something inside <svg> invalidates the frame. The only exceptions I can think of are: - async image decoding invalidation for <svg:image> (?) - <foreignObject> It would be nice if we could avoid allocating geometries for DLBI for SVG items. foreignObject should be easy to exclude from that optimization. Matt, can you think of other reasons why we might need to call AllocateGeometry and ComputeInvalidationRegion? Here's nsDisplaySVGGeometry::ComputeInvalidationRegion, it doesn't do anything interesting other than calling ShouldInvalidateToSyncDecodeImages: https://searchfox.org/mozilla-central/rev/8f06c1b9a080b84435a2906e420fe102e1ed780b/layout/svg/SVGGeometryFrame.cpp#137-152
Reporter | ||
Updated•6 years ago
|
Comment 1•6 years ago
|
||
Looks like nsDisplaySVGGeometry is using nsDisplayItemGenericImageGeometry, which also checks for border rect changes. If we're confident that SVG will invalidate the frame for border rect changes (which makes sense since we don't really reflow SVG), then we should be able to conditionally allocate the geometry if we actually have an image to paint. Can you think of anything else we need here Jonathan?
Updated•6 years ago
|
Comment 2•6 years ago
|
||
(In reply to Markus Stange [:mstange] from comment #0) > As far as I know, SVG elements do not make use of DLBI. It's been five years and my memories are hazy, but unless something's changed or we have a different understanding of what precisely "DLBI" means, I thought SVG has been relying on DLBI since bug 827915. (In reply to Matt Woodrow (:mattwoodrow) from comment #1) > Looks like nsDisplaySVGGeometry is using nsDisplayItemGenericImageGeometry, > which also checks for border rect changes. > > If we're confident that SVG will invalidate the frame for border rect > changes (which makes sense since we don't really reflow SVG), We don't reflow in the sense of box model reflow, but we have a reflow-lite that has to set mRect (see SVGGeometryFrame::ReflowSVG) and we depend on mRect having useful values for DLBI to work.
Assignee | ||
Updated•6 years ago
|
Comment hidden (mozreview-request) |
Reporter | ||
Comment 4•6 years ago
|
||
mozreview-review |
Comment on attachment 8972441 [details] Bug 1456281. Ensure that we don't need to call ComputeInvalidationRegion. https://reviewboard.mozilla.org/r/241042/#review246826 What about async image decoding?
Reporter | ||
Comment 5•6 years ago
|
||
mozreview-review |
Comment on attachment 8972441 [details] Bug 1456281. Ensure that we don't need to call ComputeInvalidationRegion. https://reviewboard.mozilla.org/r/241042/#review247740
Comment 6•6 years ago
|
||
Matt, Markus, I'm guessing we don't need to fix this for 61?
Reporter | ||
Comment 7•6 years ago
|
||
This optimization idea is mostly targeted at WebRender, so there's no rush to fix this.
Updated•6 years ago
|
Comment 8•5 years ago
|
||
Moving to p2 because no activity for at least 24 weeks.
See How Do You Triage for more information
Comment 9•2 years ago
|
||
Redirect a needinfo that is pending on an inactive user to the triage owner.
:gw, since the bug has high priority, could you have a look please?
For more information, please visit auto_nag documentation.
Reporter | ||
Comment 10•2 years ago
•
|
||
This was the patch: https://hg.mozilla.org/mozreview/gecko/rev/17cb6969152eecb590d8746a0156dceed571a3a9
I had completely forgotten about this idea. It seems worthwhile.
Assignee | ||
Comment 11•2 years ago
|
||
Assignee | ||
Comment 12•2 years ago
|
||
This fails layout/reftests/bugs/220165-1.svg
Reporter | ||
Comment 13•2 years ago
•
|
||
Ah, that file tests foreignObject, which we would need to special case (see comment 0). Too bad the patch didn't include the special case, now we actually have to do some thinking ourselves.
Assignee | ||
Comment 14•2 years ago
|
||
layout/reftests/svg/baseline-middle-01.svg also fills
Assignee | ||
Comment 15•2 years ago
|
||
After disabling the broken sync image decoding invalidation the assertion still fails on tests like layout/reftests/svg/text/mask-applied.svg because SVG reflow doesn't actually mark the frame as invalid because as of bug 802628 it just relies on DLBI
Assignee | ||
Comment 16•2 years ago
|
||
After making SVG reflow mark frames as invalid:
diff --git a/layout/svg/SVGContainerFrame.cpp b/layout/svg/SVGContainerFrame.cpp
index 38f4bf7a79470..ae1741d92a9ba 100644
--- a/layout/svg/SVGContainerFrame.cpp
+++ b/layout/svg/SVGContainerFrame.cpp
@@ -359,20 +359,21 @@ void SVGDisplayContainerFrame::ReflowSVG() {
// nsChangeHint_UpdateEffects):
SVGObserverUtils::UpdateEffects(this);
}
FinishAndStoreOverflow(overflowRects, mRect.Size());
// Remove state bits after FinishAndStoreOverflow so that it doesn't
// invalidate on first reflow:
RemoveStateBits(NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY |
NS_FRAME_HAS_DIRTY_CHILDREN);
+ InvalidateFrame();
}
void SVGDisplayContainerFrame::NotifySVGChanged(uint32_t aFlags) {
MOZ_ASSERT(aFlags & (TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED),
"Invalidation logic may need adjusting");
if (aFlags & TRANSFORM_CHANGED) {
// make sure our cached transform matrix gets (lazily) updated
mCanvasTM = nullptr;
}
We run into invalidations caused by transform changes with nsDisplayTransformGeometry in layout/reftests/svg/dynamic-text-06.svg. We could solve these by having a frame flag for container properties (transform, opacity, blendmode) changes.
Updated•2 years ago
|
Updated•1 month ago
|
Description
•