Cookie-autodelete: [BUG] High CPU usage when CAD button is clicked, and while popup is displayed

Created on 3 Apr 2020  路  20Comments  路  Source: Cookie-AutoDelete/Cookie-AutoDelete

-- PLEASE READ THE FAQ AND DOCUMENTATION BEFORE POSTING:

Yes, I have.

Describe the bug

High CPU usage on a Chrome's process constantly when the CAD extension button at the top right of the browser window is clicked, and while the popup is displayed.

However, the Chrome's process' CPU usage comes back to normal as soon as the popup is closed.

To Reproduce

Steps to reproduce the behavior:

  1. Open Chrome.
  2. Click on the CAD extension button at the top right.
  3. Observe the Chrome's process in the Task Manager's "Details" tab.

Expected behavior

The Chrome's process' CPU usage should just briefly go up once the CAD button is clicked, and it should come back down.

Screenshots

I believe a screenshot is not needed in this case.
But please let me know if you do.

Your System Info (please complete the following information):

  • OS: Windows 10 (x64) (Version 1909) (OS Build 18363.752)

    • Browser Info: Chrome 80.0.3987.163 (x64)

    • CookieAutoDelete Version: 3.1.1

Additional context

This was tested on a new and clean Chrome installation.

On Vivaldi (2.11.1811.52), the situation is worse. The process' CPU usage never comes back down until the browser is restarted. (Yes, I'm aware that Vivaldi is not officially supported. Just an FYI.)

I'm not sure when this started happening, but it shouldn't be further than a few releases back.

Thank you.

bug pr

Most helpful comment

3.2.0 is compiled and ready for use in GitHub Releases. Official release platforms are all under review.

All 20 comments

I believe @Telhub was also having the same issue.

Yes, I can confirm the exact same behavior for both browsers on the same system. I didn't open a new bug report lately as the issue was partly solved with the update to 3.1.1. With Chrome the cpu load falls back to idle now as soon as the pop-up is closed, whereas it still remains on 100% in Vivaldi until the process is killed manually. But, as聽@mizzuri mentioned already, Vivaldi is not the pure Chrome browser. I'm sorry that I can't contribute any additional information (yet).

Firefox Nightly 64 latest update:
I confirm that I have the same thing - while menu of your extension is displayed(right upper corner, click on icon) one of the my CPU cores is 100% loaded, since there are a lot of cores, it seems to be hidden from view, but this is not normal.

I came here to report this bug and saw it's already here. Once CPU is high, it never goes down. I'm on Vivaldi 2.11.1811.49 (Stable channel) (64-bit), which is Chrome 80.0.3987.158. But, I have observed this for almost 2 weeks, previously with an older version of Vivaldi.

For me, I don't really have to do anything explicitly with CAD. Just having CAD extension on, and using the browser with open tabs visiting multiple domains will get the CPU usage high. If I close Vivaldi, then reopen (3 windows, multiple tabs, which by VIvaldi is still hibernated until visited), the CPU usage will go up pretty fast.

As soon as I turn off CAD extension, CPU goes down immediately. I'm on a laptop with customized fan speed control, with CPU task bar icons, so in addition to hearing the fans, I notice the high CPU in real time.

I am running Cookiebro for now.

This regression is not present in CAD 3.0.4.
I couldn't test CAD 3.1.0, since there isn't a compiled release.

3.1.0 does not function properly in Chrome as after the browser-polyfill update the autoclean stops working, so I removed it.

Thanks for trying to narrow it down. You can compare the version tags to see what changed between versions.

If you guys would like to try and narrow it down further, here's the source comparison between 3.0.4 and 3.1.1. https://github.com/Cookie-AutoDelete/Cookie-AutoDelete/compare/3.0.4...3.1.1

I'm not a developer, so I can't tell which commit has introduced the regression by inspecting the code. However, I've tried to test some of the commits to narrow it down a bit further.

_Please note that my testing method could be entirely wrong, since I just started learning today on how to build using NPM._

Status | Date and Time | Description | Commit hash
--- | --- | --- | ---
C | 2020-03-17_1358 | Bump to version 3.1.0 | b02e39076a306715f99d7c979c7652257872922d
C | 2020-03-17_0623 | Tons of Updates, mostly backend development stuff. (#650) | 011a18875b76d89d28b75f238fdf9f4b400e435c
N | 2020-03-15_1947 | Add regexp support for white-list rules | 5b187f1d2cc321b79b30f4c76053cebdfe9a740c
N | 2020-03-08_1238 | New Crowdin translations (#644) | 3aabff692b0a77b99785402239f16de2ead6be93
N | 2020-03-06_0748 | Update .travis.yml | e8cfcb8eabdfb789b691ae18771625907a2a0b87
N | 2020-03-04_1621 | Fixed minor bug and updated copyright year on webpack config. | cab28dbf768208429e6082afd5d07dbd95d74cea
B | 2020-03-04_1600 | Merge branch '3.X.X-Branch' into more-enhancements | 2acb2e161b90eebdd24374d8b992e5caa49148fb
B | 2020-03-04_1557 | Dependency update for webpack to 4.42.0 | edcdd8452459606ddfde32e32c8632af73591374
O | 2020-03-04_1440 | Update crowdin.yml | e3370fd623b788590606f4c459d0b80457e67b9f
O | 2020-03-04_1427 | Update crowdin.yml | 84823e1d243a79a75788b1389726af7c5b59470d
O | 2020-02-26_1736 | Bump version to 3.0.4 | dafa4ee1486d58e8f100009fc90e552822e70e5a

C = High CPU load
N = Not functional; Cookies are not detected. Clicking on CAD button shows nothing in the popup, etc.
B = Build fail
O = OK; CPU usage is as expected

I've actually omitted many non functional builds.
So, it seems the commit 011a18875b76d89d28b75f238fdf9f4b400e435c is the one causing the issue.

...which is essentially a squashed commit...welp that should be fun to decipher...

So 3.1.0 (main update)/3.1.1 (Chrome Bugfix) has:

  • Added: Title and Version to popup.

    • This was adding in static html to popup. Don't think this should take any CPU at all as it is only compiled when popup loads/renders.

  • Added: BrowserAction Title now contains number of cookies for that domain. More useful for mobile devices.

    • May use CPU as it queries the cookie jar for cookies of that specific domain. This was already used in the cookie badge count, thus I only added a function to include it in the title on mouseover of icon.

  • Added: Cookie Count in popup.

    • Similar idea with above, though may have been implemented differently.

  • Added: "Menu" string below the menu hamburger icon. Menu button now expanded across the entire top of screen.

    • A small static html insert with CSS adjustments. Should not use any CPU aside from querying for international string.

  • Changed: Minor CSS styling on Expressions Table in Settings.
  • Changed/Updated: Locale strings.

    • Firefox querying international strings

  • Chore: Copyright Year update along with GitHub Contributors and License Link in most source code headers.
  • Fixed: Cookie Badge count should now reflect an accurate cookie count when cookies for that domain are added or removed.

    • New Function/file added that uses cookie.onChanged listener for All cookie events. Unsure if this may be the culprit.

  • Updated: With the backend webpack update: Bootstrap to 4.4.1, browser-polyfill to 0.6.0, jQuery to 3.4.1.

    • Unsure if dependency updates may have caused it as well.

Backend items:

  • Added: Crowdin Integration. Previously locales were manually compiled and updated.
  • Updated: Webpack builds will now copy jQuery, Bootstrap, and browser-polyfill minified versions from their respective dist folders from their latest npm packages.

    • per note above re:dependency.

Yep. That's a big commit 馃槅 ...
I'm afraid that I don't know how to further troubleshoot.

Please also make sure that the commit 011a18875b76d89d28b75f238fdf9f4b400e435c is the actual culprit.
I could've been entirely wrong with my testing methods.

Thank you.

Something I noticed on Vivaldi..

As I've mentioned before, the issue is worse on Vivaldi. The process CPU usage never comes back down, once the CAD button is clicked.

However, if any other extension that has a button, which shows a pop-up display, is clicked, the CPU usage becomes idle again.

So, I think it has something to do with the popup display mechanism.

Wow! Great observation @mizzuri .
I can reproduce and confirm this behaviour. CPU usages drops back to normal, when another pop up opens.

@kennethtran93 maybe this will help https://perfht.ml/2Vj41SM

Popup is calling for cookie count repeatedly(?), whole messaging is taking lot of time.

@gwarser Thank you! That really helps. I wasn't sure where to even start nitpicking away at the code I wrote.

I'll see what I can do with lowering the cookie count usage. I was originally aiming for the count to only be updated when cookies.onChanged was called. I'll have to see how react does its calls.

Could somebody give this a shot in regards to the performance? I've switched over to using browser.runtime.Ports for triggering updates so calls on setPopupCookieCount should only be triggered if a cookie related to that domain (regardless of containers/windows) were changed. This portion now uses cookies.onChanged in the background page, and sends a message to the popup (if loaded) that corresponds to that main domain so that it can update its cookie count.

Note that this file includes the Chrome LocalStorage and all the other items I had planned to release in 3.2.0. Please do let me know if something breaks.

Cookie-AutoDelete_Dev_20200420_212700_Chrome.zip
Cookie-AutoDelete_Dev_20200420_212700_Firefox.zip

Looks good.

Chrome: Seems the CPU issue is solved. Good work!
Couldn't check Firefox.

Could somebody give this a shot in regards to the performance? ...

Previously reported symptoms no longer show on the following browsers:
Firefox (Developer Edition - 76.0b6 x64)
Chrome (81.0.4044.113 x64)
Vivaldi (2.11.1811.52 x64)

Awesome. Thanks.

3.2.0 is compiled and ready for use in GitHub Releases. Official release platforms are all under review.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

tedomedo picture tedomedo  路  3Comments

frankclaassens picture frankclaassens  路  4Comments

gwarser picture gwarser  路  5Comments

erotavlasme picture erotavlasme  路  3Comments

gwarser picture gwarser  路  7Comments