gorhill / uMatrix

uMatrix: Point and click matrix to filter net requests according to source, destination and type
GNU General Public License v3.0
4.56k stars 473 forks source link

µMatrix can cause Chrome to hang #147

Closed Nojevah closed 9 years ago

Nojevah commented 9 years ago

If you took this site for example: http://heckyeahreactiongifs.tumblr.com/

If you scroll for a certain time, Chrome will hang (in my case, it was after images from Jul 25, 2014). If you disable µMatrix, you can scroll down without freezes. I've hard of the popup memory consumption, I don't know if it's linked... My Chrome version: 42.0.2311.60 beta-m (64-bit) I'm on Windows 8.1; µMatrix 8.1.3; I don't use hosts files option and I have a short personal rules list.

gorhill commented 9 years ago

What are your rules for that site?

Nojevah commented 9 years ago

http://pastebin.com/FcXkDmLa

gorhill commented 9 years ago

Ok, I didn't see any difference between browsing the site with or without uMatrix.

There are two quirks I noticed with the site itself -- which occurs with or without uMatrix.

Once you reach the bottom of the page, the page will pull in more images from the server. The two quirks are:

  1. Sometimes it may take many seconds after the spinner disappear for the pulled images to appear.
  2. Sometimes the images won't appear: scrolling one line back and then forth to force a refetch will usually work.

This happens without uMatrix too. I went past the point you said has a problem.

Using Chromium 41.

Nojevah commented 9 years ago

These quirks indeed are not linked to µMatrix or my problem. Maybe it does not hang for you because you have a better processor. I can reproduce it each time, and 1 core is at max use. It will unfreeze after some seconds, but if you scroll down, it will freeze again.

gorhill commented 9 years ago

That kind of page with hundreds of GIF required GBs of memory. It was consuming over 2 GBs when I reached July 13. This has nothing to do with uMatrix, GIFs are memory-hungry resources. How much memory do you have on your computer?

gorhill commented 9 years ago

If you disable µMatrix, you can scroll down without freezes

How did you disable uMatrix?

Nojevah commented 9 years ago

8 GB. It is not the RAM limit which is reached. But 1 Core (on 4) is at max (25%). I either disable extension, or use incognito mode without extension to test. If I disable µMatrix from popup, it will still freeze (because µMatrix still lists/counts elements).

gorhill commented 9 years ago

will still freeze

Describe "freeze" please.

Nojevah commented 9 years ago

All latest loaded gif are not moving anymore. And if I scroll Up or down, nothing happens. If I try to close the tab (clicking on the "close button"), it will need several seconds before to close. But computer does not freeze, I can even click on another tab in the same time.

gorhill commented 9 years ago

gif are not moving anymore

What you describes is similar to what happens when memory starts to be paged in and out of swap space. I just can't reproduce what you describes. But loading hundreds of GIF in memory of course will be a huge drain on memory and CPU.

Chromium's Task Manager currently shows 71% usage, while the page has been idle for a while now, not downloading GIFs anymore. That's the price of animating hundreds of GIFs animated onto one single page. Currently consuming ~2 GBs.

Activating another tab causes the CPU usage to drop to 0% for the tab containing all the GIFs, and the memory to somewhat drop. Go back to the tab, CPU go back up, and memory usage for that tab increases somewhat too.

So if you went to the Extensions tab to disable uMatrix, just going to that new tab caused a chunk of memory to be garbage collected, and CPU to drop to 0%. This has nothing to do with uMatrix. So if you were swapping memory by then, this will give you the impression disabling uMatrix helped a lot, while this has nothing to do with uMatrix.

Nojevah commented 9 years ago

When doing my tests (enable/disable µMatrix), I have closed and reopened the webpage each time.

I guess µMatrix needs a bit of CPU/RAM, then it reaches the machine limit earlier than without µMatrix.

gorhill commented 9 years ago

I guess µMatrix needs a bit of CPU/RAM, then it reaches the machine limit earlier than without µMatrix.

It depends.

I ran three benchmarks, being very careful to use the same steps for all three. I pressed page down, waited to be sure no images were pulled as a result, then paged down again. If images were pulled (watching "Network" column), I waited for this to be over. Then paged down. Etc. Until I reached July 25th, at exactly the same point for all three benchmarks. Here are the results for the target tab:

Figures are "memory / CPU" (from Chromium's Task Manager).

No extension uMatrix uMatrix w/ all frames blocked
Tab (before moving away) 1.4 GB / 60% 1.7 GB / 62% 1.15 GB / 58%
Activate another tab 885 MB / 0% 1.2 GB / 0% 713 MB / 0%
Tab (after moving away) 999 MB / 55% 1.3 GB / 57% 868 MB / 54%

I didn't realized there were a lot of frames on the page, I had assumed it was only GIFs. But the page has hundreds of invisible iframe in it, probably one for each GIF (to embed social widgets).

iframe incurs an overhead in uMatrix, because each is injected with uMatrix's content script, which is not something that can be worked around -- this is necessary to take care of many basic tasks: UA spoofing, detecting dynamically added scripts/frames, etc.

Also, I do believe the overhead incurred by content script injections with the latest iterations of Chromium is higher than it used to be, something that has been noticed elsewhere -- there is an issue which was opened in Chromium about this.

Chromium 41 64-bit on Linux.

Nojevah commented 9 years ago

Oh you're right. If I block frames from "assets.tumblr.com", it does not freeze anymore.