desktop: Scrolling issues and high CPU usage when watching videos

Captchas

  • I have read the instructions.
  • I have searched existing issues and avoided creating duplicates.
  • I am not filing an enhancement request.

What happened?

WebRender (The graphics rendering system in Gecko) splits the scene into retained layers (WR actually calls them pictures) which are composited into the window. Scrolling a retained picture only requires moving it around and re-compositing which saves a considerable amount of CPU and GPU time and makes a big difference for power usage.

WR’s ability to split the scene into layers is limited by a number of things. For example element within a non-trivial clip or filter don’t get a cached layer. The way Zen’s UI is built currently prevents WebRender from generating multiple layers for scrollable content, I suspect because of the rounded-rectangle clip applied to the view.

This causes much choppier scrolling in Zen than in Firefox (and, I expect but did not actually measure, much worse power usage). It affects all platforms.

WebRender will probably get the ability to apply a rounded rectangle clip on retained layers some time this year. In the mean time Zen’s beautiful rounded corners come at a very high cost.

Checking how the layerization is working in WebRender is a bit tedious. You can enable the gfx.webrender.debug.picture-caching pref which will show a rather overwhelming overlay. You can compare with how this overlay looks in Firefox and maybe build an intuition from that or ask me if you need help with understanding it.

Reproducible?

  • I have checked that this issue cannot be reproduced on Mozilla Firefox.

Version

1.9b

What platform are you seeing the problem on?

Linux (Flatpak)

Relevant log output if applicable


About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 83
  • Comments: 61 (13 by maintainers)

Most upvoted comments

I just wanted to put some actual GPU power consumption numbers in this thread, as in my opinion this is a big issue with Zen and is likely the cause for lots of the posts I see in the Zen subreddit complaining about laggy scrolling and high power usage compared to other browsers.

Tested on a desktop with a 3080 GPU, I usually have MSI Afterburner up on my second display and Zen was constantly spiking my GPU into a higher power mode, I actually swapped back to Firefox it was that noticeably worse. I was also experiencing small stutters at the beginning of a scroll. Since disabling these rounded corners Zen has been behaving the same as Firefox for me regarding power usage and the scrolling stutters are mostly gone, I’m now happily using Zen as a daily driver with no problems.

On Firefox scrolling this github page up and down results in constant 35w GPU power usage, Zen uses 65w performing the same test.

Installed Disable Rounded Corners mod and switched zen.view.experimental-rounded-view to false, it was true for me on windows by default.

Now Zen also uses 35w scrolling this page.

Here’s a video of the test slightly higher power of 38w due to recording.

Below is a screenshot of the power usage for scrolling reddit with the mod enabled and then disabled, without rounded webview it’s a flat 30-35w, as soon as I disable the mod my GPU is constantly spiking to 100w or 65w. Image

I’ve also noticed that this can affect video playback too, on twitch at least, although the difference depends on the video and your hardware on how much worse it is.

Watching a 1080p 60fps twitch stream consumes about 36w with rounded corners, 30w without them, small saving but it adds up for laptop users.

When I have HDR enabled in windows and am watching a normal 1080p 60fps twitch stream, Zen frequently spikes up to 65w, disabling rounded corners, it’s just a flat 35w line, again same as Firefox. Picture below of this behaviour. Image

I don’t have a laptop myself to test battery life, but a user on reddit posted a test where he compared battery life of his morning routine on different browsers. Firefox had 92% battery left after this, Zen had 81% left. I pointed him in the direction of this fix and now after testing again with the mod installed, Zen consumed basically the same battery as Firefox with 91% left. Battery test

EDIT: Wanted to add another reddit thread here that showcases the poor performance this can cause on lower end hardware, his scrolling was very laggy and after testing this fix he seems happy so I’m assuming it’s now scrolling as well as Firefox would on his hardware.

Personally, I feel like leaving these rounded corners enabled by default and just waiting an unknown amount of time until the WebRender patch comes out that will allow the rounded corners to be done efficiently is a mistake, I hope you will consider disabling the rounded corners by default and adding them back when it can be done efficiently. Add a toggle to turn them back on for those that still want it and don’t care about power usage or performance problems.

If the patch comes out in a few weeks or you can find a fix sooner it’s fine to leave them enabled, but if it could potentially be months before this is fixed, leaving Zen in a worse state performance/power wise than Firefox for that long just to have some tiny rounded corners on the webview doesn’t make much sense to me. I see complaints about Zen’s battery life, unsmooth scrolling and general performance all the time in the subreddit and this issue is likely a big reason for a lot of these problems. Most users will never find this fix on their own and will just associate Zen with being a bit laggy/poor battery performance when it doesn’t need to be like this.

Keep up the great work, love the browser.

Looks like clip overflowing the content area got fixed on nightly!

I noticed that you also need to disable the background gradient for the optimization to activate.

So the full instruction for optimizing smooth scrolling looks like this:

  1. Set zen.theme.gradient to false Disable grain in theme color settings
  2. Set zen.view.experimental-rounded-view to false
  3. Enable Disable Rounded Corners mod
  4. Restart Zen

UPD: As mentioned, disabling the gradient completely is not necessary, just disabling the grain is enough

Ah, apologies for the hasty conclusion. Filters like mix-blend modes are also a way to fall off of the compositing optimizations, but it could be other things as well. I’ll try to come up with a way to diagnose it when I have some time to spare and get back to you (feel free to poke me if I don’t).

So for whatever reason, most of the issues are fixed when I go to this screen in dev tools and click “Start Recording”

Image

Not sure if this helps but it makes it much smoother

Please avoid “Im having issues as well” comments, we know there is an issue, that’s why this is still open. Unless it’s something important that’ll help us directly, please avoid commenting as people are subscribed to this issue. Thanks

@mauro-balades Why was this issue renamed? The word video hasn’t been mentioned even once here, and the whole discussion has been about scrolling performance - which is laggy on any page, even those with just plain text.

dosubot, this is still relevant

There seems to be some bugs reported already: https://bugzilla.mozilla.org/show_bug.cgi?id=1958313 https://bugzilla.mozilla.org/show_bug.cgi?id=1933527

Ill subscribe to them and merge the patches as soon as they get a proved. In the meantime, ill just join all general high CPU usage issues into this one

@nical I’ve just tested it on zen twilight with firefox version 141, issue seems to be resolved?

I saw the fix landed on nightly a month ago but im not entirely sure if it will be available on 141.

Image

Why is every issue about huge and excesive ram usage been marked as duplicated of this one?

All we can do is wait 😔

Would it made sense to allow a config to disable the rounded corners in the meantime in order to prevent this perf penalty?

Turns out there already is a zen-mod that does just that. I don’t think fixing this performance issue was the authors intention, but it does work!

Installing this zen mod drastically decreases the energy usage on my macbook!

update zen.view.experimental-rounded-view has to be false aswell. It was already false by default for me, but seemingly not for everyone (see https://github.com/zen-browser/desktop/issues/6302#issuecomment-2729220509)

I have also identified the media player animation as a cause for high(er) GPU usage.

Image (the little notes which usually are animated in the controls)

As someone who regularly plays music in the background, I was wondering why my laptop was often sluggish when doing so.

I worked around this issue by adding the following to my userChrome.css file

#zen-media-controls-toolbar {
  & #zen-media-focus-button::after {
    display: none !important;
  }
]

The fixes described here have not really worked for me. On the latest Twilight version (1.14t) my GPU usage has dropped by 30-40% though. See the related bugzilla issue: https://bugzilla.mozilla.org/show_bug.cgi?id=1933527

I wonder why zen.theme.gradient is making this issue, since all it does really is just apply a background to the browser… Maybe it’s because of the grainy texture which uses mix-blend-mode?

@mauro-balades I think you’re on to something there. I just re-enabled the gradient, but removed the grain from all workspace themes > normal CPU&GPU usage during scrolling.

I’ve tested this and it really works. Updated my instructions accordingly. (https://github.com/zen-browser/desktop/issues/6302#issuecomment-2764052368).

Indeed this has to be fixed in either (or a mix of) Zen and Gecko.

Probably that’s the cause of [at least some of] https://github.com/zen-browser/desktop/issues/5734, https://github.com/zen-browser/desktop/issues/5588, https://github.com/zen-browser/desktop/issues/5840, https://github.com/zen-browser/desktop/issues/2206?

I am pretty sure this has at least a very large impact on all of these issues.

Why was this issue renamed?

Because it’s all related to the rounded corners and it’s starting to get a bit hard to manage duplicates. Please, unless it’s something that’s useful related to this issue, don’t comment as many people are subscribed

@Propheticus thanks for the mod, I’ll look it up. About topic relevance: you are absolutely right, I added nothing to the topic of performance optimization, but still. If you ask me, the amount of people that will read this thread, follow the instructions and be happy with a tedious conjuction of sharp and round corners is miniscule compared to the amount of folks that will install the browser, look at the overall performance, and uninstall/abandon it altogether instead of going for solutions on reddit and github.

@nickj2014 raised concerns that the Webrender fix may take a long time to implement, and unless the devs are sure that it will not, IMO there should be a fast browser-side fix deployed as a default. I find borderless zen the most elegant of temporary (and mayhaps permanent) solutions.

@mauro-balades i’ll shut up from now on, dixi 😃

Enabling the grain texture is definitely another cause, just tested it on Windows with default acrylic theme and the rounded corner fix enabled. High GPU usage 65w continuous with 100w spikes and the picture-caching overlay goes crazy when smooth scrolling.

No grain

Image

Grain enabled

Image

WebRender will probably get the ability to apply a rounded rectangle clip on retained layers some time this year.

All we can do is wait 😔

If someone finds a patch before it actually gets released to stable, please let me know so we can have it as soon as possible

Seems to be fixed on twilight, ill close this issue as resolved and it will land once firefox gets released (3 days from now).

Please ping me here to reopen if picture caching is still broken even after the update (or currently on twilight)

I’m seeing significantly less GPU usage on twilight vs stable (when scrolling with rounded corners enabled/default settings). The recording seemed to add 15-20% to GPU usage, but there appears to be a ~30% difference between stable and twilight. This was particularly a problem when using my iGPU on battery power, I had input lag and scrolling stutters, etc. Fixed for me on latest twilight (video compressed to hell for github). The only issue I still see is a choppy animation when the window control bar comes down in compact mode.

https://github.com/user-attachments/assets/bfaa76bd-fbf3-452d-a6bb-220eb96ea2fb

  • ~Set zen.theme.gradient to false~ Disable grain in theme color settings

  • Set zen.view.experimental-rounded-view to false

  • Enable Disable Rounded Corners mod

  • Restart Zen

Unfortunately it didn’t work for me, as soon as I dock it to one side of the screen it becomes blurred. Gnome, Wayland

@Psychosoc1al zen.view.experimental-rounded-view was already false by default for me

Although, I did disable rounded corners and spacings… but the issue doesn’t seem to go away?

I just want to mention that on my system I get a slightly different behavior then what is described here. I have a very high end system so neither component should result in any hiccups. When I scroll in Zen the first scroll is laggy and then goes smooth after a second. It’s like the browser turns on an energy saving mode after not scrolling for a second. I hope this info can somehow help in resolving the issue.

If we roll with full “no distraction from surfing the web, pure zen” and set --zen-element-separation to 0px (as well as rounded-corners disabled and no grain), the caching is still present, while the UI looks consistent. @mauro-balades and others, what do you think about setting “borderless” view as a default till someone fixes the caсhing bug?

IMHO performance and decent font rendering are worth way more than a signature border, which btw rarely matches nice with the outer Windows gray border. Also it seems that the folks on Reddit like the mod: https://www.reddit.com/r/zen_browser/comments/1jsxsc1/borderless_zen_browser_is_incredible/

Image

Removing rounded corners helped me to make scrolling smoother indeed. But I found another issue probably linked to the core problem: When I open a “glance” preview, the GPU usage while scrolling goes to 90+% on my laptop, while scrolling the same page in a separate tab results in ~40% usage.

Was this fixed in 1.11b?

Nope 😃

Also, @nik9play do we really need the Disable Rounded Corners mod ? Seems like only setting zen.view.experimental-rounded-view to false does the job

Also encountering this issue zen.view.experimental-rounded-view false didn’t help

Installing this zen mod drastically decreases the energy usage on my macbook!

Actually yes, but only a bit for me. The drastic improvement on my machine is to turn off zen.view.experimental-rounded-view combined with this mod. Now gfx.webrender.debug.picture-caching and GPU usage looks similar to what I see in Firefox.

UPD: I noticed that clip-path from a custom userChrome theme (Natsumi in my case, it’s really cool BTW) also ruins caching 😦 So note this in your experiments

All we can do is wait 😔

Would it made sense to allow a config to disable the rounded corners in the meantime in order to prevent this perf penalty?