Closed Bug 1767570 Opened 2 years ago Closed 2 years ago

https://nx.dev animation is very slow (SVG filter and animation)

Categories

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

Firefox 102
defect

Tracking

()

RESOLVED FIXED
Performance Impact low

People

(Reporter: 709922234, Assigned: gw)

References

Details

(Keywords: perf, perf:animation)

Attachments

(2 files)

User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:102.0) Gecko/20100101 Firefox/102.0

Steps to reproduce:

visite: https://nx.dev/

Actual results:

animation is very slow

Expected results:

animation is smooth

Component: Untriaged → DOM: Animation
Product: Firefox → Core

reason is <header> svg background

https://share.firefox.dev/3kBOB9c
The SVG will only animate if the horizontal width of the tab is ~60% of the screen width. Else the animation stops.

Component: DOM: Animation → Graphics: WebRender
Status: UNCONFIRMED → NEW
Ever confirmed: true
Summary: https://nx.dev animation is very slow → https://nx.dev animation is very slow (SVG filter and animation)

A profile from my machine: https://share.firefox.dev/38UZRuU

Seems a bit busy due to animation but nothing obvious stands out.

Severity: -- → S3
Keywords: perf
Priority: -- → P3
Performance Impact: --- → P3
Keywords: perf:animation
Blocks: 1782834
Assignee: nobody → gwatson

Wow, we hit what seems to be a very inefficient way to render this content. Perhaps it's expected based on the current implementation, I'm not sure.

I've attached a minimized repro case - there is an HTML file which has a background-image set to a SVG URL. I've reduced the SVG to have a single path (the full case has multiple paths with a gradient and filter).

What appears to happen (I might also just be misinterpreting the call stacks) is:

  • We fail to generate WR commands in nsDisplayBackgroundImage, so we create a fallback image.
  • That image is rasterized in the content process (lots of time in SkCanvas::drawPath).
  • Gecko then decides that this (display item?) should be drawn as a blob.
  • The rasterized image from the content process gets serialized as a blob image (lots of time in memcpy under AddBlobImage).
  • On the scene building side, we replay the blob (most of the time is spent in the skia blitRect function).

The replay of that blob seems very expensive with the way we tile blobs, but that seems secondary since ideally we wouldn't be drawing the content this way at all?

Jeff / Nical / Andrew, is this expected given the current way we handle blobs?

Flags: needinfo?(nical.bugzilla)
Flags: needinfo?(jmuizelaar)
Flags: needinfo?(aosmond)
Attached file svg-perf.html
Attached image hero-bg-large.svg

Talking to Jeff, it seems this is unexpected and on his machine this fallback code path is not being hit (and the performance is as expected). It's not clear yet why it differs per machine.

It fails on my machine in https://searchfox.org/mozilla-central/source/image/VectorImage.cpp#785, which then results in the fallback path being hit.

See Also: → 1515787

So this is actually caused by CreateSamplingRestrictedDrawable which we don't use on macOS. We want to stop using it everywhere. Andrew and I or go to come up with a plan next week.

Flags: needinfo?(jmuizelaar)
Flags: needinfo?(nical.bugzilla)
Flags: needinfo?(aosmond)
Depends on: 1746662
Blocks: 1782590

This is much better after https://bugzilla.mozilla.org/show_bug.cgi?id=1746662 landed - there's a bit of time in texture upload, which is expected right now, but it easily runs at 60 fps at 4k for me now.

Status: NEW → RESOLVED
Closed: 2 years ago
Resolution: --- → FIXED
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: