Open Bug 1420699 Opened 7 years ago Updated 2 years ago

Firefox uses a lot of CPU on MacOS

Categories

(Core :: General, defect)

58 Branch
Unspecified
macOS
defect

Tracking

()

UNCONFIRMED
Performance Impact low

People

(Reporter: domoritz, Unassigned)

References

(Depends on 1 open bug)

Details

(Keywords: perf:resource-use, power)

Attachments

(3 files)

Attached image Screenshot of Activity Monitor. (deleted) —
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:58.0) Gecko/20100101 Firefox/58.0 Build ID: 20171120142222 Steps to reproduce: I installed the latest Firefox Beta and open some web pages and CPU usage is way too high. I really wanted to switch from Chrome to Quantum but the CPU usage is unacceptable for me. I've tried a new profile and safe mode (as per https://support.mozilla.org/en-US/kb/firefox-uses-too-many-cpu-resources-how-fix) but it didn't help. Are there any logs I can provide? OS: MacOS 10.13.2 Firefox: 58.0b5 Actual results: As soon as I open Firefox on MacOS, my CPU usage goes up and my fan starts spinning. Battery performance is poor as a result. Screenshot of Activity Monitor is attached. Expected results: I would expect CPU usage to be low as in Chrome or Safari.
Component: Untriaged → General
Keywords: power
OS: Unspecified → Mac OS X
Product: Firefox → Core
This could be related to https://bugzilla.mozilla.org/show_bug.cgi?id=1404042. I am using a scaled resolution. However, the CPU usage is not much better when I don't use a scaled resolution. I noticed that the processes "spindump" and "Window Server" often use a lot of CPU while Firefox is open.
Depends on: 1404042

Firefox use about 8 time more CPU than Safari on MacOS. Especially when scrolling page (without scaled resolution). Their was great improvement already with https://mozillagfx.wordpress.com/2019/10/22/dramatically-reduced-power-usage-in-firefox-70-on-macos-with-core-animation/ but the current situation is not good enough.

High CPU usage is not cool as it push people to buy new computer :/.

I can confirm that scrolling up and down this thread several times in Firefox and Safari CPU peaks at around 35% and 10% respectively. Resizing the each browser window the numbers are similar. Should this be moved into a separate ticket?

Has anyone checked that other processes don't make up the difference between "Firefox" and "Safari"? Both applications use lots of processes. And, as mentioned above, the cpu usage of the "Window Server" process (at least) can increase in proportion to the cpu usage of its "clients".

Someone should try measuring the "Firefox group of processes" against the "Safari group of processes", including a best guess at what share of "Window Server" cpu usage is due to each. And why not also throw in the "Chrome group of processes"?

Edit: I can see that at least some people are already measuring process groups (using the hierarchical process viewer in Activity Monitor). Still, though, one wants to make sure people are comparing apples to apples.

Attached image firefox.png (deleted) —

So this is firefox

Attached image Safari (deleted) —

And Safari. Using the same page (this bug page) and scrolling back and forth at normal speed.

On this naive test it's so it's not that bad. But still.

Perdrisat: What hardware are you testing on, running which version of macOS? I assume that, in each case (Firefox and Safari), only one tab (this bug's page) was open in the browser. Is that correct?

I just tested on a new Mac Pro (7.1, 48GB of RAM, 3.2 GHz 16-Core Intel Xeon W) running macOS 10.15.7. The CPU usage results for Firefox 85.0.2 (the current version) and Safari were basically identical. Each browser had only one tab open (this bug's page), at your comment 6. I made both pages identical in size, and ran Firefox and Safari one at a time (they weren't both running at the same time). I didn't have any other instances open of either browser. I didn't have any third party extensions running in either browser. I moved the mouse around as fast as I could manage, and scrolled the page up and down a bit (but not so far that some part of comment 6 wasn't visible).

Admittedly my machine is extremely powerful, and very atypical. But I now suspect this problem may be worse on less powerful machines, or perhaps on different versions of macOS. It's also possible one or more third party extensions may be involved.

Only once we have good STR can we begin to understand this problem.

Edit: We should also consider the possibility that the extent of this problem differs with the graphics hardware you're using. I have an AMD Radeon Pro 580X with 8MB of VRAM.

I just performed the same test on another machine: A mid-2015 15 inch Retina MacBook Pro (11,5 16GB of RAM) with two different kinds of graphics hardware (an "integrated" Intel Iris Pro and a "discrete" AMD Radeon R9 M370X), also running macOS 10.15.7.

Here Firefox's CPU usage was notably worse than Safari's, but only about 1.5 times worse. This machine is less powerful, and now more than five years old. It's also a Retina machine, so I wonder if that makes a difference. (My Mac Pro doesn't have a Retina display.)

I used gfxCardStatus to force usage of either the "integrated" or the "discrete" video hardware. As you'd expect, the "discrete" video hardware used more CPU. But as best I could tell, it made no difference to the performance gap between Firefox and Safari.

One thing I noticed is that Firefox uses about as much CPU in the foreground as in the background. But putting Safari in the background makes it use dramatically less CPU. This might make Firefox use considerably more battery power over time.

It's also a Retina machine, so I wonder if that makes a difference.

As best I can tell, the Retina display doesn't make much difference. I tested by connecting my non-Retina display to my MacBook Pro (as an external display) and testing either on the external display or the built-in display. Each browser performed about the same on both displays.

My Mac Pro has 16 cores, but my MacBook Pro only 4. I wonder if that could make a significant difference.

I retested on my new Mac Pro. Now I'm seeing the same results as on my old MacBook Pro -- Firefox's CPU usage is about 1.5 times worse than Safari's. I also tested on a new M1 Mac Mini with 16GB of RAM and 8 cores, and got the same result.

So my results are pretty much the same everywhere, regardless of age, RAM size, number of cores, and even type of CPU. Clearly something is going on here, but I'm still no closer to figuring out what it is :-(

More extreme differences are probably caused by some other factor -- an external one like an extension, or a non-external one like some special case of the test performed.

One thing I noticed is that Firefox uses about as much CPU in the foreground as in the background. But putting Safari in the background makes it use dramatically less CPU. This might make Firefox use considerably more battery power over time.

This is the only other real discovery I've managed to make to this point.

One more thing: I just tested on a VMware VM running macOS 10.15.7, which doesn't have any support for graphics hardware acceleration. Once again Firefox's CPU usage was about 1.5 times that of Safari. I think this shows that the problem, whatever it is, has nothing to do with graphics hardware acceleration.

(In reply to Steven Michaud [:smichaud] (Retired) from comment #7)

Perdrisat: What hardware are you testing on, running which version of macOS? I assume that, in each case (Firefox and Safari), only one tab (this bug's page) was open in the browser. Is that correct?

My machine:
MacBook Air (13-inch, Early 2015)
1.6 GHz Dual-Core Intel Core i5
8 GB 1600 MHz DDR3

I did not do the test very properly, both browser had 3-4 tabs opens during the test (certainly in idle). But both browsers was using very limited CPU without scrolling. I will redo those when I got the chance and without adons too (I doubt it's the problem, I just have ublock).

Running into the same bug on a Mac Mini 2018 after rebuilding Firefox installation.

With 4 reporters, this should be confirmed.

Similar bugs go back to Firefox 3.6, but I can't test older builds due to incompatibilities with some of the sites.

I already reduced the Content Process Limit to 4, but it still jumps to 80% or even 120% usage for Firefox and another 80% for webextensions as soon as I start Firefox.

I don't encounter this in Troubleshoot mode, but a lot of standard web design practices trigger my migraines, and could trigger seizures, so I can't use the web without user css and add-ons.

Checking about:performance, it does look like an extension issue. Both Default Scroll and Allow Right-Click can cause energy usage to spike, but not having them allows sites to screw with users. A native Firefox fix might avoid some of this trouble.

Hi, could you capture a performance profile as mentioned here and post it here? https://firefox-source-docs.mozilla.org/performance/reporting_a_performance_problem.html
It would help us a lot to identify the problem.

Performance Impact: --- → P3

Hi MarjaE, Adding a ni to you as well. It would be great if you could help with capturing a profile too.

Flags: needinfo?(erwinm)

(In reply to Nazım Can Altınova [:canova][:canaltinova on phabricator] from comment #18)

Hi, could you capture a performance profile as mentioned here and post it here? https://firefox-source-docs.mozilla.org/performance/reporting_a_performance_problem.html
It would help us a lot to identify the problem.
Hi there.

OP here. I'm not using macOS anymore. Tbh, I didn't think a resolution would take that long.

I don't think I could be of much help, sadly.

Sorry, can't do that.

Flags: needinfo?(erwinm)

Redirect a needinfo that is pending on an inactive user to the triage owner.
:overholt, since the bug has recent activity, could you have a look please?

For more information, please visit auto_nag documentation.

Flags: needinfo?(domoritz) → needinfo?(overholt)

Hey Florian, do you think we can still investigate something from the STRs in this bug?

Flags: needinfo?(florian)
Flags: needinfo?(overholt)

(In reply to Julien Wajsberg [:julienw] from comment #23)

Hey Florian, do you think we can still investigate something from the STRs in this bug?

Without a profile to look at, I doubt we can make this actionable. There was an interesting point in comment 9 about Firefox's CPU use being almost the same in the foreground or in the background. That might already be covered by eg. bug 1578123.

Flags: needinfo?(florian)

Yeah, I thought that you may want to look at this on your computer :-)

Severity: normal → S3
Duplicate of this bug: 1797832
No longer duplicate of this bug: 1797832
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: