Open Bug 1798206 Opened 2 years ago Updated 18 days ago

"Ambient Mode" on youtube uses a lot of GPU/CPU (particularly high impact with sw-wr)

Categories

(Core :: Graphics: WebRender, enhancement)

enhancement

Tracking

()

Performance Impact medium

People

(Reporter: mayankleoboy1, Unassigned)

References

(Blocks 1 open bug)

Details

(Keywords: perf:resource-use, top50)

Attachments

(1 file)

Enable sw-wr.
Enable dark mode on youtube.
Go to youtube (e.g. https://www.youtube.com/watch?v=x7Tbj2ee7t4&t=195s)
Choose a low res stream to ensure this particular issue can be isolated

In the video settings (gear in the youtube player) choose the "Ambient Mode"

ER: no impact on gpu/cpu use
AR: High impact on GPU/CPU. In particular, the GPU use gets quite high.

"Ambient mode" disabled: https://share.firefox.dev/3sHdHYi
"Ambient mode" enabled: https://share.firefox.dev/3SPnuX4

This also has an impact on Chrome but noticable less than sw-wr Nightly. This bug may end up being a webcompat bug.

Attached image ambient mode.png

For comparison, here is a profile with hw-wr : https://share.firefox.dev/3fi6nzl (the first half is with ambient mode enabled, rest half with ambient mode disabled).

Some additional info on the new Ambient Mode :
https://blog.youtube/news-and-events/an-updated-look-and-feel-for-youtube/
https://uxplanet.org/ui-ux-design-youtubes-new-ambient-mode-7759d0d10b1b
Specifically from the second link: "Essentially, it’s just a copy of the video, using a blur filter, with the opacity taken down to about 60%."

Performance Impact: --- → ?

The Performance Impact Calculator has determined this bug's performance impact to be medium. If you'd like to request re-triage, you can reset the Performance Impact flag to "?" or needinfo the triage sheriff.

Platforms: Windows
×3
Configuration: Specific but common
×0.5
Websites affected: Major
×5
[x] Causes severe resource usage
+2

Performance Impact: ? → medium

It looks like in SW-WR it's hitting almost every single fast-path it can, so there isn't really much to optimize at that level. It just seems like the amount of picture cache targets being rendered to and then combined is just a lot to ask of a software rasterizer for this. Glenn, do you see anything that could be simplified higher up in WR to make this less awful?

Flags: needinfo?(gwatson)

Worth highlighting that with sw-wr+Ambient mode, the GPU use (as measured by the Windows task manager) is much higher:

sw-wr: 50% in nightly process (with periodic/constant additional 20% GPU use in DWM)
hw-wr: 20%

I took a quick look at this, I think it's unfortunately expected that this mode is going to be significantly worse for both performance and battery life, at least in it's current implementation.

If I understand the effect correctly, the video gets used as an input source to a blur effect followed by opacity.

Without ambient mode, we hit optimal video fast paths where there is almost no GPU work done by WR, as we post the video directly as an interleaved external surface to the compositor, and the WR content tiles don't get redrawn every frame.

However, with this change, we need to:

  • Use the input video as a source to a blur filter
  • Run the blur filter on the GPU
  • Composite all the video and under/over tiles ourselves in WR and present this to the compositor.

What we probably want to do in this case is:

  • Detect that it's not worth having an external compositor surface
  • Collapse the picture cache slices in to one slice which is all rendered by WR in to tiles (including the video)
  • Present that single slice to the compositor

This would probably make the CPU/GPU use much better, but:

  • I'm not sure what heuristic we'd use to determine that we don't want an external compositor surface here.
  • It's still going to be worse performance than the optimal video path, as we won't be hitting the path of supplying video directly to compositor.
Flags: needinfo?(gwatson)

Oh, I was wrong about the above - it is a canvas element that has the blurred content. Not sure if the input source for the canvas is from the video itself or some other data stream. Either way, it's going to involve lots more GPU time than the regular video fast paths.

I wonder if we could (assuming we don't already) detect that the external video surface occludes most of the blurred canvas and skip drawing that. Seems complex / fragile, but might be possible.

This issue has a huge performance impact for me, it makes youtube basically unwatchable when it's on. Unfortunately, because it's tied to the system-level "dark mode" setting in Windows, there's no way to permanently disable it in the YouTube settings. I have to periodically turn it off it each video, and every time if the video is in a private window.

Only work-around for now is disabling dark-mode at the Windows level. This will change YouTube's default mode to light-mode which doesn't have ambient mode on by default.

Maybe consider an "about:config" setting to disable this? or perhaps there's a user CSS or JS solution that could block it?

Eli, is the huge performance impact you're seeing because you're getting sw-wr? If that's happening, perhaps we can identify why and see if we can get your machine to run hardware webrender? Would you be able to post your about:support content so we can see the hardware and what renderer backend is running (this wouldn't be a general fix for the bug, but it might help work around your particular issue).

Flags: needinfo?(eli)

References:

https://old.reddit.com/r/firefox/comments/13aisdz/excessive_gpu_usage_in_firefox_3040_vs_67_in/
https://old.reddit.com/r/firefox/comments/13ago3g/very_high_cpu_usage/

Both with the same problem, Ambient Mode.

I think we need to fix this bug quick because users are suffering.

Duplicate of this bug: 1831745

Redirect a needinfo that is pending on an inactive user to the triage owner.
:gw, since the bug has recent activity, could you please find another way to get the information or close the bug as INCOMPLETE if it is not actionable?

For more information, please visit BugBot documentation.

Flags: needinfo?(eli) → needinfo?(gwatson)
Flags: needinfo?(gwatson)

Came here to post this as a ticket and found it already exists. Still present in latest release channel FF 64bit, OSX. Fishy one, since it doesn't happen in Chrome..

I bet you've got telemetry that says YouTube is one of the most used websites by all FF users, so I'd expect this bug to be much higher priority.

(In reply to Rich Jones from comment #15)

Came here to post this as a ticket and found it already exists. Still present in latest release channel FF 64bit, OSX. Fishy one, since it doesn't happen in Chrome..

I bet you've got telemetry that says YouTube is one of the most used websites by all FF users, so I'd expect this bug to be much higher priority.

+1

You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: