Closed Bug 1374995 Opened 7 years ago Closed 7 years ago

Firefox WebContent taking too much CPU 100%

Categories

(Firefox :: Untriaged, defect)

54 Branch
defect
Not set
normal

Tracking

()

RESOLVED WORKSFORME

People

(Reporter: firefox, Unassigned)

Details

(Keywords: perf)

User Agent: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:54.0) Gecko/20100101 Firefox/54.0
Build ID: 20170612122018

Steps to reproduce:

Go to a page that indefinitely loads (e.g. page with print_r of complex object)


Actual results:

Firefox hangs, closing the tab with hanging page does not relieve/free the resources


Expected results:

Resources should have been immediately relieved/freed after closing the tab
Keywords: perf
Hi Dave,

Can you please provide an example of a page where do you encounter this issue, in order to test it? Or maybe a test case? 
I have tried to create a local page to test this, but I'm not sure if I am doing it right.
Flags: needinfo?(firefox)
Test case:

Try this link (a while loop sending content to a browser indefinitely):
https://eia.cyklokoalicia.sk/debug/project/150

Open two tabs with the same URL. Let it run for few seconds. Check WebContent process (under Linux over 100% of CPU), close one tab, then close the second tab. Firefox should switch to an existing tab. It does, but spinner spins indefintely when trying to access any of the existing tabs (i.e. not part of the test case). 

Firefox needs to be killed to relieve resources and make it usable again.
Flags: needinfo?(firefox)
@Daniel, Thanks for the provided URL!

I have managed to reproduce this issue on Ubuntu 14.04 x64 using latest Firefox (54.0) release. It seem that the issue is partially reproducible on Windows. After I have followed the provided steps from comment 2, Firefox hangs, but after I have closed both pages, I was able to navigate through the opened tabs without any issues.

I have also tested this on latest Nightly build (56.0a1 Build ID: 20170625030210) and the issue is harder to reproduce. In order to reproduce it you have to open the provided page in multiple tabs and navigate through them a couple of times.

I have used the Gecko Profiler add-on to measure the performance, but I am not sure how to read them:
- On Ubuntu: http://bit.ly/2sSFLIC
- On Windows: http://bit.ly/2sSn4ov

Mike, when you have time can you please take a look at the provided profiles? Are the provided profiles useful?
Flags: needinfo?(mconley)
The Windows profile is less useful because it's only pseudostacks - I'm guessing it was captured on a non-Nightly build of Firefox. Regardless, it looks like it's spending a lot of time reflowing.

The Ubuntu profile is more illuminating. It looks like we're spending a lot of time inside an interruptible layout flush.

Is this reproducible in Firefox 55? I ask, because I tried to address the interruptible reflow problem in bug 1360946.
Flags: needinfo?(mconley) → needinfo?(cosmin.muntean)
User Agent  Mozilla/5.0 (X11; Linux x86_64; rv:56.0) Gecko/20100101 Firefox/56.0
Firefox 56.0a1, Build ID: 20170626100316

I have retested this issue on latest Nightly (56.0a1) build, and I have observed the following behavior. If you have at least 4 tabs opened then you open the provided link from comment 2 in other two tabs, when you navigate through the opened tabs, you can observe that at least one page is blank and a loading spinner is displayed in the center of the page. The page is successfully loaded after a few seconds. However, the tabs are closing without any problems.

I have also observed that the browser crashed after restart (ShutDownKill). Here is the crash report: https://crash-stats.mozilla.com/report/index/e4689e8d-ec5d-4057-a111-7d07f0170627

Here is a Gecko profiler made on the latest Nightly build, but I think there is another issue now:
http://bit.ly/2thMoqO

@Dave, can you also test the latest Nightly build in order to see if you can reproduce the issue?
Flags: needinfo?(mconley)
Flags: needinfo?(firefox)
Flags: needinfo?(cosmin.muntean)
Tested with Mozilla Firefox 56.0a1

Works much better, no visible troubles or issues. I tried to open four tabs with the test case URL an other tabs worked well and swiftly.

After closing the four tabs with test case URL, the other (unrelated) tab had spinner on for about 3 seconds, then showed page content.

2 Web Content processes under `top` were showing 113% of CPU used (and growing memory from 8% to 13,5%) for about another 10 seconds, then it dropped to standard CPU use (15-25%).
Flags: needinfo?(firefox)
Has this page changed recently? My content process definitely doesn't spin up when I visit https://eia.cyklokoalicia.sk/debug/project/150 .

Is there another example page that can reproduce the problem? Or is it still somewhat reproducible for you at the same link?
Flags: needinfo?(mconley) → needinfo?(firefox)
OK, I have changed the page in the meantime, but if you need more testing, I changed it back to lop and output content indefinitely.
I have retested this issue on Beta 55.0b11 and I have managed to partially reproduce the issue. Daniel, did you change back the page or maybe now is another issue?

[Steps to reproduce]:
1. Start Firefox Beta 55 browser and open 3 new tabs with different websites.
2. Open in two new tabs the "https://eia.cyklokoalicia.sk/debug/project/150" website.
3. Wait ~5 seconds and start navigate through the opened tabs/
4. Observe the browser behavior when switching tabs.

[Expected results]:
- There is no loading spinner when navigating through the websites.

[Actual results]:
- The page is blank and a loading spinner is displayed in the center it.

[Notes]:
- Here is profiler performed on Ubuntu 14.04 x64 using Beta 55.0b12: https://perfht.ml/2tDAJU0 

Mike, please let me know if you need more information. Also, do you know which is more appropriate component to assign for this bug?
Flags: needinfo?(mconley)
No, the URL / page is correct for this test case (i.e. infinite loop of content output).
Flags: needinfo?(firefox)
That profile suggests we're spending a humongous amount of time painting text. That's not super unsurprising - the page in question is a giant wall of text that seems to be constantly growing.

I'm seeing the tab switch spinner like CosminMCG in comment 9, but that's not surprising - the entire content process is hosed trying to paint this massive wall of text. I suspect this same page would have just crushed single-process Firefox.

After I closed the tab, my resources freed after a few seconds.

Are you still seeing resources not being freed?
Flags: needinfo?(mconley) → needinfo?(firefox)
I am not sure what you are asking me. 

I have already provided a test case and replied to all questions. See:
https://bugzilla.mozilla.org/show_bug.cgi?id=1374995#c6
Flags: needinfo?(firefox)
Thanks. Based on comment 6, closing WFM.
Status: UNCONFIRMED → RESOLVED
Closed: 7 years ago
Resolution: --- → WORKSFORME
You need to log in before you can comment on or make changes to this bug.