Closed Bug 1417870 Opened 7 years ago Closed 6 years ago

CPU pegged even after quitting Firefox on macOS

Categories

(Core :: Networking, defect)

57 Branch
defect
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 1424709

People

(Reporter: l2dy, Unassigned)

Details

Attachments

(2 files)

Attached file ffcpu.log
User Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:57.0) Gecko/20100101 Firefox/57.0
Build ID: 20171112125346

Steps to reproduce:

This bug has happened 5 times but I still can't figure out how to reproduce it. I was browsing GitHub and other websites and it happened.

I removed all Firefox, Mozilla files in ~/Library, logged out and logged back in so I have a fresh installation with only the following customization:

* Keybase Native Messaging API (installed by Keybase.app)
* uBlock Origin
* Light theme

But it still happened.


Actual results:

1. Noticed that CPU was pegged by crazy fan and heat.
2. `ps aux | grep firefox` found 4 firefox processes pegging CPU.
3. After quitting Firefox with Cmd+Q, 3 firefox processes were still pegging CPU.
4. SIGTERM doesn't kill the remaining processes, SIGKILL killed them.


Expected results:

Firefox doesn't suddenly peg CPU when browsing and quits cleanly.
Please troubleshoot with Safe Mode with all the extensions disabled: https://support.mozilla.org/kb/troubleshoot-firefox-issues-using-safe-mode
I can't reproduce the bug under Safe Mode today. However, it only happened one or two times a day so I don't have much confidence that Safe Mode can prevent it from happening.
Zero, if the issue is only reproducible sporadically and we cannot reproduce the problem, this usually means it's nearly impossible to get an idea what is wrong and what we should be fixing.

So, since according to comment 2, safe mode apparently prevents the bug from manifesting, do you think you can further assist into debugging this issue by temporarily disabling your extensions for several browsing sessions? Or just use in parallel a new profile without any extension?

And also, for the normal mode and using the comment 0 profile, could you watch for anything "interesting" in browser console when the CPU peg happens?
Flags: needinfo?(l2dy)
I understand that the issue is impossible to fix without more information. If not that it happened five times, I wouldn't have submitted this bug report at all.

I've been unable to reproduce this issue in the last few days. My assumption is that it only happens if I bring my MacBook outdoors with Firefox open. Too many factors, e.g. network, power supply, and macOS sleep, could affect my attempt to reproduce the issue. I'll try my best to reproduce it and provide more information.

I'll use a new profile for testing. On which tab should I check the console, or is there a global console somewhere?
I'm using an external monitor at home and this could be a factor too.
(In reply to Zero King from comment #4)
> I'll use a new profile for testing. On which tab should I check the console,
> or is there a global console somewhere?

You can access the browser console from: hamburger menu/web developer / browser console (shortcut: Cmd+Shift+J for Mac)

I don't think an external monitor would cause CPU to hog, I am inclining more towards Keybase Native Messaging API. I'll install it as well and play around see if I can catch anything similar. Is this the correct path you installed it from -  https://keybase.io/docs/extension / https://addons.mozilla.org/en-US/firefox/addon/keybase-for-firefox/?
(In reply to Adrian Florinescu [:AdrianSV] from comment #6)
> (In reply to Zero King from comment #4)
> > I'll use a new profile for testing. On which tab should I check the console,
> > or is there a global console somewhere?
> 
> You can access the browser console from: hamburger menu/web developer /
> browser console (shortcut: Cmd+Shift+J for Mac)

Thanks.

> I don't think an external monitor would cause CPU to hog, I am inclining
> more towards Keybase Native Messaging API. I'll install it as well and play
> around see if I can catch anything similar. Is this the correct path you
> installed it from -  https://keybase.io/docs/extension /
> https://addons.mozilla.org/en-US/firefox/addon/keybase-for-firefox/?

I didn't install the extension, I only installed Keybase from https://keybase.io/docs/the_app/install_macos.
(In reply to Adrian Florinescu [:AdrianSV] from comment #3)
> Zero, if the issue is only reproducible sporadically and we cannot reproduce
> the problem, this usually means it's nearly impossible to get an idea what
> is wrong and what we should be fixing.
> 
> So, since according to comment 2, safe mode apparently prevents the bug from
> manifesting, do you think you can further assist into debugging this issue
> by temporarily disabling your extensions for several browsing sessions? Or
> just use in parallel a new profile without any extension?
> 
> And also, for the normal mode and using the comment 0 profile, could you
> watch for anything "interesting" in browser console when the CPU peg happens?

Reproduced just now, nothing interesting in browser console.
(In reply to Zero King from comment #8)
> Reproduced just now, nothing interesting in browser console.

This was under normal mode, outdoors.
Reproduced again, attaching screenshot of the browser console.
(In reply to Zero King from comment #10)

This bug has happened 3 times today, last two under normal mode, indoors.

I've started to use a new profile now. What else can I do to help?
(In reply to Zero King from comment #11)
> (In reply to Zero King from comment #10)
> 
> This bug has happened 3 times today, last two under normal mode, indoors.
> 
> I've started to use a new profile now. What else can I do to help?
To clarify,did you reproduce the bug with the new profile, or with your existing profile and just now switched to new profile?
(In reply to Adrian Florinescu [:AdrianSV] from comment #12)
> (In reply to Zero King from comment #11)
> > (In reply to Zero King from comment #10)
> > 
> > This bug has happened 3 times today, last two under normal mode, indoors.
> > 
> > I've started to use a new profile now. What else can I do to help?
> To clarify,did you reproduce the bug with the new profile, or with your
> existing profile and just now switched to new profile?

With the existing profile and just now switched.
Ok, please use the new profile and try to reproduce the issue. If the issue isn't reproducible using the clean profile, that means the root-problem is somewhere in the customization -> ublock maybe? We'll move forward once we know if the add-ons are/are not culpable.
I've been unable to reproduce the issue under both profiles since last time I commented.
(In reply to Zero King from comment #15)
> I've been unable to reproduce the issue under both profiles since last time
> I commented.
I'll mark this issue as WFM for the time being. Please reopen when you reproduce or/and figure out any other details related to this issue.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → WORKSFORME
Reproduced twice (Wed Dec 13 07:40:00 UTC 2017 and Wed Dec 13 15:45:00 UTC 2017) with Firefox 57.0.1 (existing profile), only one firefox process is pegging CPU after quitting Firefox though.

The issue stopped happening for 21 days using the existing profile, so I can't be certain if it's reproducible using a clean profile unless I attempt to reproduce it for a very long period under both profiles, which I cannot afford.
Flags: needinfo?(l2dy)
(In reply to Zero King from comment #17)
> Reproduced twice (Wed Dec 13 07:40:00 UTC 2017 and Wed Dec 13 15:45:00 UTC
> 2017) with Firefox 57.0.1 (existing profile), only one firefox process is
> pegging CPU after quitting Firefox though.

Content process limit (in Preferences - Performance) is set to 2 when I reproduced the issue today, which explains the reduced number of processes.
Wed Dec 13 16:09:00 UTC 2017

Reproduced again just now... This is getting annoying.

After quitting Firefox.app:

$ ps aux
USER               PID  %CPU %MEM      VSZ    RSS   TT  STAT STARTED      TIME COMMAND
l2dy              7310  70.3  0.0  7988704    652   ??  R     3:52PM  10:19.27 /Applications/Firefox.app/Contents/MacOS/firefox
[...]

Only `killall -9 firefox` can terminate it.
Zero, did you notice any correlations between the times when you managed to reproduce that state? (e.g. any common page?) For example in comment 19, it appears that something is stuck and using alot of your CPU. And just to make sure I understand, if you let it be, the process stays stuck with the high CPU consumption, right? The only way is to kill it manually?
(In reply to Adrian Florinescu [:AdrianSV] from comment #20)
> Zero, did you notice any correlations between the times when you managed to
> reproduce that state? (e.g. any common page?)

No common page. As far as I can remember, it only happens if I brought my computer outdoors on the same day.

> For example in comment 19, it
> appears that something is stuck and using alot of your CPU. And just to make
> sure I understand, if you let it be, the process stays stuck with the high
> CPU consumption, right? The only way is to kill it manually?

Yes and yes.
(In reply to Zero King from comment #21)
> No common page. As far as I can remember, it only happens if I brought my
> computer outdoors on the same day.

If you can only reproduce the bug when you get your computer outdoors that might mean that we're looking at something that is related to networking (I would assume that you change network?) or something related to sleep/standby mode or maybe some power mode setting?. Something around that area maybe?
(In reply to Adrian Florinescu [:AdrianSV] from comment #22)
> (In reply to Zero King from comment #21)
> > No common page. As far as I can remember, it only happens if I brought my
> > computer outdoors on the same day.
> 
> If you can only reproduce the bug when you get your computer outdoors that
> might mean that we're looking at something that is related to networking (I
> would assume that you change network?) or something related to sleep/standby
> mode or maybe some power mode setting?. Something around that area maybe?

I have two network locations (in macOS system preferences) and would switch between them when I get my computer outdoors. I'm using Thunderbolt Ethernet with a VLAN interface (WiFi disabled or not connected) at home and a public WiFi network outdoors.

I'm using the default macOS "Energy Saver" configuration except "prevent computer from sleeping" when power adapter is connected. The computer is running on battery when I bring it outdoors.
I suspect it's caused by network location switch, because I just reproduced the issue after switching the network location after rebooting my computer and have power adapter connected since the reboot.

$ ps aux | grep firefox
l2dy               490  63.8  0.0  7913280    668   ??  R     3:01AM   4:07.79 /Applications/Firefox.app/Contents/MacOS/firefox
l2dy               482  63.6  0.0  7913312    668   ??  S     3:01AM   4:09.22 /Applications/Firefox.app/Contents/MacOS/firefox
l2dy               479  63.3  0.0  6127396    764   ??  R     3:01AM   4:11.62 /Applications/Firefox.app/Contents/MacOS/firefox
Status: RESOLVED → UNCONFIRMED
Resolution: WORKSFORME → ---
I can reliably reproduce the issue now, every failed (elaborated below) switch of network location on macOS creates one more firefox process that pegs CPU.

I'm using a standard (unprivileged) user and have set require administrator authorization to turn Wi-Fi on or off. The two locations I use have Wi-Fi turned on and off, respectively. Usually I can switch the network location in the Apple menu, and Wi-Fi will be switch on and off accordingly, however, sometimes the switch will be no-op (failed above) and I have to go into Network Preferences, unlock it with administrator credentials and switch the location.
(In reply to Zero King from comment #25)
> I'm using a standard (unprivileged) user and have set require administrator
> authorization to turn Wi-Fi on or off. The two locations I use have Wi-Fi
> turned on and off, respectively. Usually I can switch the network location
> in the Apple menu, and Wi-Fi will be switch on and off accordingly, however,
> sometimes the switch will be no-op (failed above) and I have to go into
> Network Preferences, unlock it with administrator credentials and switch the
> location.

I'm not certain of what caused the location switch from the Apple menu to fail though.
Comments 24 to 26 do certainly seem a step forward. 
Can you confirm if the STR below are accurate to reproduce the issue? 

[Steps:]
1. Create a standard user
2. Save two network locations: one Wi-fi and one wlan. (wi-fi turns on/off )
3. While Firefox is turned on switch between the two network locations using the Apple menu.

[Actual Result:]
When the the location switch from Apple menu fails and requires elevated rights, the Firefox process becomes pegged.


I couldn't reproduce the above steps on 10.13.1, but I figure that should be it. I would guess that a prerequisite is to be able to make the location switch fail with standard user and make it require elevated rights to switch. Do you by chance have a secondary OSX different from 10.13, for example 10.12 to check if the issue is OSX version dependent?
Also, could you redo the location settings, then see if you can reproduce the bug?

Stephen, do you have any thoughts on what could happen here or what info Zero might provide, given the fact that reproducing the issue proves a bit hard at the moment?
Flags: needinfo?(spohl.mozilla.bugs)
Flags: needinfo?(l2dy)
Component: Untriaged → Networking
Product: Firefox → Core
(In reply to Adrian Florinescu [:AdrianSV] from comment #27)
> Comments 24 to 26 do certainly seem a step forward. 
> Can you confirm if the STR below are accurate to reproduce the issue? 
> 
> [Steps:]
> 1. Create a standard user
> 2. Save two network locations: one Wi-fi and one wlan. (wi-fi turns on/off )

I'm not using any Wi-Fi network at home (when I reproduced it yesterday) under both network locations though, just Wi-Fi on/off in the two locations.

Also set require administrator authorization to turn Wi-Fi on or off (see the attached screenshot).

> 3. While Firefox is turned on switch between the two network locations using
> the Apple menu.
> 
> [Actual Result:]
> When the the location switch from Apple menu fails and requires elevated
> rights, the Firefox process becomes pegged.

Not only that, but also each consecutive failed switch increments the number of CPU-pegging firefox processes by 1.

So my previous assumption that the content process limit affects the number of leftover firefox processes is probably wrong.

> I couldn't reproduce the above steps on 10.13.1, but I figure that should be
> it. I would guess that a prerequisite is to be able to make the location
> switch fail with standard user and make it require elevated rights to
> switch.

Most of the time, location switch from the Apple menu (top left corner) works even with administrator authorization required for switching Wi-Fi on/off.

> Do you by chance have a secondary OSX different from 10.13, for
> example 10.12 to check if the issue is OSX version dependent?
> Also, could you redo the location settings, then see if you can reproduce
> the bug?

No, I don't have another OS X. I reproduced the CPU-pegging bug 3 time with failed location switches yesterday, so I said "reliably". And if it happened once I can reproduce the switch failure many times immediately after that, but after I killed firefox, start Firefox and restart into safe mode, I can't reproduce the switch failure.

Sadly, I'm having trouble reproducing the location switch failure today. It could take sometime until I can reproduce it again.
Flags: needinfo?(l2dy)
(In reply to Zero King from comment #25)
> I can reliably reproduce the issue now, every failed (elaborated below)
> switch of network location on macOS creates one more firefox process that
> pegs CPU.
> 
> I'm using a standard (unprivileged) user and have set require administrator
> authorization to turn Wi-Fi on or off. The two locations I use have Wi-Fi
> turned on and off, respectively. Usually I can switch the network location
> in the Apple menu, and Wi-Fi will be switch on and off accordingly, however,
> sometimes the switch will be no-op (failed above) and I have to go into
> Network Preferences, unlock it with administrator credentials and switch the
> location.

Hi reporter,
Since you can reproduce this easily, could you try to:
- provide the log by following instructions on [1]
- Replace the current log modules with: timestamp,rotate:200,nsHostResolver:5,nsNotifyAddr:5,nsIOService:5

[1] https://developer.mozilla.org/en-US/docs/Mozilla/Debugging/HTTP_logging
Flags: needinfo?(l2dy)
I believe this is a duplicate of bug 1424709 which I'm currently looking into.
Flags: needinfo?(spohl.mozilla.bugs)
Thanks Stephen.
Marking as duplicate as per comment 33.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago6 years ago
Resolution: --- → DUPLICATE
Flags: needinfo?(l2dy)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: