Open Bug 1693016 Opened 5 years ago Updated 2 years ago

SVG mask keyframes animation is throttled / choppy when masking element is outside of the viewport

Categories

(Core :: DOM: Animation, defect)

defect

Tracking

()

People

(Reporter: myf, Unassigned)

References

()

Details

Attachments

(2 files)

Attached testcase contains four SVG elements filled with rectangle in group that is masked by other rectangle (each SVG contains own mask). Masking rectangles are animated via CSS keyframes translating them back and forth.

Masks animations runs smoothly to the point when (presumably) effective top left corners of masking elements exceed actual viewport, then animation starts to be choppy - best observed on the last SVG in test page: it is smooth when page is scrolled to the top, but becomes choppy when page is scrolled so the last SVG is partially outside viewport.

We're incorrectly thinking that the <rect> is scrolled out of view here.

Status: UNCONFIRMED → NEW
Component: SVG → DOM: Animation
Ever confirmed: true

Not a fan of this since this would cause us to use more CPU if the thing
that observes is actually out of view... We already disable async
animations for these elements. Maybe we want to instead check if the
elements referencing us are out of view.

So there are sort of two issues here... First, the masked <rect> is 0x0 in the frame tree. It's inside a <mask>, but I'd still have expected it to have the right size. If it did, this particular case would be working (and it might be good enough of a solution).

The other issue is that we're actually accounting for the mask itself, not for the element that is using it... That seems like another issue, at least. Though in this case the origins are the same so it wouldn't matter.

Not sure what's the best solution here. I attached a patch that fixes the issue, but is extremely conservative and we probably don't want to take as-is.

masks and their contents will have frames that have NS_FRAME_IS_NONDISPLAY set. Perhaps we could use that? We don't size NONDISPLAY items in frame trees because they are only indirectly rendered.

If the mask is smaller than the element, you'd only display the mask bounds so the second paragraph sounds like we're doing the right thing.

Well, we're actually using the size of the <rect>, not the <mask>... But yeah, maybe just check that bit, go to the root of the NONDISPLAY subtree, and check for the contents that are observing it.

QA Whiteboard: [qa-regression-triage]

Hello!

I looked into the regression range for this issue and it seems broken from at least 2018-2019. I think this is not a regression. I'm removing the "regression" and "regressionwindow-wanted" keywords.

Severity: -- → S3
Duplicate of this bug: 1860510
Summary: SVG mask keyframes animation choppy when masking element exceeds viewport → SVG mask keyframes animation is throttled / choppy when masking element is outside of the viewport

The WIP patch in bug 1693016 would fix it, but as noted there is not ideal. Ideally, we want to check that at least some of the things that reference us are visible...

See Also: → 1882773
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: