Closed Bug 1384094 Opened 7 years ago Closed 6 years ago

High CPU. network traffic and memory usage when open Newtab page if you have opened / bookmarked a problematic/ huge game page in the past

Categories

(Firefox :: New Tab Page, defect, P1)

Unspecified
Windows 10
defect

Tracking

()

VERIFIED FIXED
Firefox 61
Iteration:
61.1 - Mar 26
Tracking Status
firefox-esr52 --- wontfix
firefox54 --- wontfix
firefox55 --- wontfix
firefox56 --- wontfix
firefox57 --- wontfix
firefox58 --- wontfix
firefox59 --- wontfix
firefox60 --- wontfix
firefox61 --- verified
firefox62 --- verified

People

(Reporter: alice0775, Assigned: Mardak)

References

(Blocks 3 open bugs, )

Details

(5 keywords, Whiteboard: [thumbnails])

Attachments

(5 files)

Attached file hang.html
Reproducible:  always

Steps To Reproduce:
0. Start with new profile
1. Open attached html and wait until the tab loading circle turns green
2. Exit browser and restart
3. Open Newtab Page (click [+] button)
   ---- observe CPU and Memory usage

Actual Results:
Even if there are about:home and Newtab page, browser consumes High CPU and memory.

Expected Results:
Very low CPU and memory usage.



WORKAROUND:
browser.newtabpage.enabled = false
and
browser.newtabpage.activity-stream.enabled = false (if activity-stream enabled)
Summary: High CPU and memory usage when open Newtab → High CPU and memory usage when open Newtab page
Blocks: 1383489
Another sample page attachment 8889630 [details]
Summary: High CPU and memory usage when open Newtab page → High CPU and memory usage when open Newtab page if you have opened a problematic page in the past
Regression window:
https://hg.mozilla.org/mozilla-central/pushloghtml?fromchange=5ceea82a79c7&tochange=2983ca6d4d1a

Regressed by:
Bug 870100 - Use BackgroundPageThumbs to capture user top sites that we don't currently capture

Mark Hammond [:markh],
Your patch trigger the problem. Could you look this?
Blocks: 870100
Flags: needinfo?(markh)
We attempt to thumbnail pages, and yeah, if those pages manage to chew lots of CPU or memory, then the thumbnailer will too - while it's done in a content process, it will still be noticeable. Ideally we'd be able to use a sandbox and limit the memory and CPU used, but I'm not aware if that's possible yet.
Flags: needinfo?(markh)
Priority: -- → P3
Still happen. Reproduce easily.

If you encounter this problem at least once, you can not solve it except by destroy the user profile

Steps To Reproduce:
0. Start with new profile
1. Open attachment 8950552 [details] and wait for a while
2. Exit browser(kill all nightly process) and restart browser
3. Open Newtab Page (click [+] button)
   ---- observe CPU and Memory usage
Now, Bug 1433324 has been landed in m-c,
No longer available workaround....
Blocks: 1433324
If it's caused by thumbnailing a top site, does browser.newtabpage.activity-stream.showTopSites=false avoid the problematic site?
(In reply to Ed Lee :Mardak from comment #7)
> If it's caused by thumbnailing a top site, does
> browser.newtabpage.activity-stream.showTopSites=false avoid the problematic
> site?

I can still reproduce :(
Oops sorry, can you also try setting browser.newtabpage.activity-stream.feeds.topsites=false ?
(In reply to Ed Lee :Mardak from comment #9)
> Oops sorry, can you also try setting
> browser.newtabpage.activity-stream.feeds.topsites=false ?

confirmed. 
Setting the browser.newtabpage.activity-stream.feeds.topsites=false fixes the problem.
"Refresh Firefox" would not fix the problem.



It is wrong to try to load the page again without user permission when opening "New Tab".
I think the logic of making thumbnails is wrong. 
Seems a security issue.
Component: New Tab Page → Activity Streams: Newtab
This page is also affected.
http://mzl.la/webassemblydemo

So, this bug is affected not only for a problematic page but also some game page.


I think that the thumbnail should be disabled until this bug is fixed. Because there are no way to fix the problem except about:config hack.


I will raise the importance of this bug.
Add "qawanted", this is very bad experiences. It impairs the reliability of the product.
Severity: normal → major
Keywords: qawanted
Summary: High CPU and memory usage when open Newtab page if you have opened a problematic page in the past → High CPU. network traffic and memory usage when open Newtab page if you have opened a problematic/ huge game page in the past
Whiteboard: [this is very bad experiences. It impairs the reliability of the product]
This page is also affected.
http://www.squarefree.com/bug523950/523950.gif
Whiteboard: [this is very bad experiences. It impairs the reliability of the product] → [thumbnails]
A partial fix would be to have a static "blank image" and use this whenever BackgroundPageThumbs gets a timeout capturing the page - that should mean the problem happens when the thumbnail is missing, then will not happen again until the thumbnail expires. Not a perfect fix, but possibly a good enough start.
(In reply to Mark Hammond [:markh] from comment #14)
> A partial fix would be to have a static "blank image" and use this whenever
> BackgroundPageThumbs gets a timeout capturing the page
Oh, that's an interesting "fix." We run into the recurring high CPU problem because we don't persist across restart failed thumbnails. We've previously had a temporary blacklist for twitch in bug 1412505, but that got reverted when the video error issue got fixed. But in general, there will be ways that loading pages will use up a lot of resources via javascript, large files, etc; and there won't really be ways to detect if even loading a page will be "bad" ahead of time.

So markh's suggestion is basically a dynamic blacklist implemented through the existing thumbnail storage mechanism so there doesn't need to be that much additional logic…

The main downside is what if the page actually becomes thumbnailable? Perhaps unlikely and oh well?
See Also: → 1412505
(In reply to Ed Lee :Mardak from comment #15)
> The main downside is what if the page actually becomes thumbnailable?
> Perhaps unlikely and oh well?

I believe thumbnails expire after 2 days - so I think the biggest downside is that we are likely to hit this that often, which might not appear like a "fix" at all.
(In reply to Mark Hammond [:markh] from comment #16)
> I believe thumbnails expire after 2 days
I think we can avoid the expiration with our explicit requests to not expire them.

https://github.com/mozilla/activity-stream/blob/e1ae13a2398f4702d71a0d5b03487618544f104c/system-addon/lib/TopSitesFeed.jsm#L70-L72
Blocks: 1437659
Iteration: --- → 61.1 - Mar 26
Summary: High CPU. network traffic and memory usage when open Newtab page if you have opened a problematic/ huge game page in the past → High CPU. network traffic and memory usage when open Newtab page if you have opened / bookmarked a problematic/ huge game page in the past
A quick hack and adding a top site of attachment 8948365 [details] seems to result in a white thumbnail with a 0-size file c3bb58cac6c9e281db3ca33867e4829f.png And restarting results in no new request and top site shows a white image (attached) and no more error messages in console after restarting.

```diff
diff --git a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
index 91063d9e9a28..c6313403c106 100644
--- a/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
+++ b/toolkit/components/thumbnails/BackgroundPageThumbs.jsm
@@ -518,12 +518,14 @@ Capture.prototype = {
         Services.obs.notifyObservers(null, "clear-origin-attributes-data",
           JSON.stringify({ userContextId: privateIdentity.userContextId }));
       }
     };
 
+    // If this background attempt failed, cause a dummy file to be saved, so
+    // that gets loaded instead of attempting again (and again).
     if (!data) {
-      done();
+      PageThumbs._store(this.url, this.url, null, true).then(done, done);
       return;
     }
 
     PageThumbs._store(this.url, data.finalURL, data.imageData, true)
               .then(done, done);
```
Iteration: 61.1 - Mar 26 → ---
Priority: P3 → --
Assignee: nobody → edilee
Priority: -- → P1
Iteration: --- → 61.1 - Mar 26
Blocks: 1445085
Commit pushed to master at https://github.com/mozilla/activity-stream

https://github.com/mozilla/activity-stream/commit/c41b4e5fbb38820666e5ff2f67f293233f0602ce
fix(screenshots): Store an empty screenshot to avoid repeatedly requesting failures (#4050)

Fix Bug 1384094 - High CPU. network traffic and memory usage when open Newtab page if you have opened / bookmarked a problematic/ huge game page in the past
Status: NEW → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Commit pushed to master at https://github.com/mozilla/activity-stream

https://github.com/mozilla/activity-stream/commit/9632262414f4a99d2fbad56209927ed8df53e3df
Revert "Fix Bug 1384094 - High CPU. network traffic and memory usage when open Newtab page if you have opened / bookmarked a problematic/ huge game page in the past" (#4051)

This reverts commit c41b4e5fbb38820666e5ff2f67f293233f0602ce.
Status: RESOLVED → REOPENED
Resolution: FIXED → ---
Commit pushed to master at https://github.com/mozilla/activity-stream

https://github.com/mozilla/activity-stream/commit/111ba085faa2d5b9685c79b7fa59b03f69555b17
fix(screenshots): Store an empty screenshot to return failure without repeat requests (#4052)

Fix Bug 1384094 - High CPU. network traffic and memory usage when open Newtab page if you have opened / bookmarked a problematic/ huge game page in the past
Status: REOPENED → RESOLVED
Closed: 6 years ago6 years ago
Resolution: --- → FIXED
Blocks: 1448443
Flags: qe-verify+
This issue has been reproduced on Firefox 56.0a1 (2017-07-24) with the exact same repro steps as per described in both Comment 5 and Description of the ticket.

The issue was not reproduced however on Nightly 62.0a1 (2018-05-09) and Firefox 61.0b3 on a Windows 10x64 machine with the following hardware configuration: 16GB’s of RAM and 8CPU’s with ~3.5GhZ. 

Please see the below results for a more detailed overview of the CPU/Memory Usage: 


56.0.1 :

Default:                            ~7% CPU  / 35% Memory  
After(during) opening HTML attach:  ~20% CPU / 41% Memory
After restart+new Tab:              ~47% CPU / 56% Memory                


61.0b3 
Default:                            ~5%   CPU/ 33% Memory 
After(during) opening HTML attach:  ~17% CPU / 47% Memory
After restart+new Tab:              ~17% CPU /47% Memory


62.0a.1:

Default:                            ~5%  CPU / 33% Memory 
After(during) opening HTML attach:  ~17% CPU / 44% Memory
After restart+new Tab:              ~18 %CPU / 44%Memory 

Marking this issue as Verified-Fixed.
Status: RESOLVED → VERIFIED
Flags: qe-verify+
Hello Ed, could you please take a look at the comment above and give us your input on the results provided? Are those percentages of CPU/Memory usages the intended ones? Thank you
Flags: needinfo?(edilee)
Thanks for those numbers. Looks like CPU usage does avoid spiking after restart with the thumbnail fix.
Flags: needinfo?(edilee)
I'm still getting sky high CPU usage on 61.0b10, after a short while of idle time. 

If replace "thumbnailed" new page with the "blank" one, everything's good.
(In reply to mirh from comment #30)
> I'm still getting sky high CPU usage on 61.0b10, after a short while of idle
> time. 
> 
> If replace "thumbnailed" new page with the "blank" one, everything's good.

After b13 or b14, everything seems perfect. Sorry for the noise.
I'm not sure if this will be relevant or not, but I ran into a PC freeze while running a test-case related to this.
While I'm aware that PC resources are relevant, the one I ran the test on had 8GB RAM, your typical HDD with an integrated Intel Graphics card.

Here are the steps followed:
1. Launch Firefox using a fresh profile.
2. Open and bookmark the following pages: 
- http://www.mozdev.org/projects/nav.html
- http://www.squarefree.com/bug523950/523950.gif
3. Exit the browser and then reopen it. 
- Make sure to check the CPU, network traffic and memory usage

I ran this test twice. On the second run, I got the PC freeze. Please note that this only occurred once and after I did a forced shutdown (killing the PC from the button) the issue was no longer reproducible (either using the old Fx profile or a new one).

Upon further investigation, I noticed that the Service Host: SuperFetch went into overdrive when Fx was open and those pages were loaded. Even after closing Fx the service would still overload the system.

Does Firefox interact with that service in any way?

Another colleague ran into a freeze on a laptop(4GB RAM) with Ubuntu 16.04 x32, running the same test case.
Blocks: 1509084
Component: Activity Streams: Newtab → New Tab Page
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: