Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Privacy Badger on Chrome on Linux consuming high CPU #2954

Open
ghostwords opened this issue Mar 6, 2024 Discussed in #2953 · 14 comments
Open

Privacy Badger on Chrome on Linux consuming high CPU #2954

ghostwords opened this issue Mar 6, 2024 Discussed in #2953 · 14 comments

Comments

@ghostwords
Copy link
Member

Discussed in #2953

How does one debug (to see if it is related to a specific tab)?

Originally posted by nhed March 6, 2024
Seen it happen several times (over several PB versions). Laptop fans spinning up, htop showing high cpu taken by chrome, chrome's task manager shows PB as highest CPU user.

image

  • uname -r: 6.5.10-200.fc38.x86_64
  • rpm -q google-chrome-stable: google-chrome-stable-120.0.6099.224-1.x86_64
  • PB version: 2024.2.6

Disabled & Re-enabled and things quieted down

Did not see any discussion re CPU usage (is this the right place to have this convo?)

@ghostwords
Copy link
Member Author

@nhed Are you able to reproduce this bug? For example, does this happen regularly while using Google Meet or some other specific website?

@nhed
Copy link

nhed commented Mar 6, 2024

Seen it very high couple of time before in both I disabled and issue went away. Unrelated to Google Meet - I thing it started before I had to get on the call.
I am unable to correlate to a specific website but I do have many tabs open (shame, i know)

Worth nothing that I run with two profile-dirs, personal and work (i think task manager shows a global view, so shows tasks from both profiles?) and at the time I had the PB extension only installed on the profile that was not running the Google Meet.

Right now when I'm not running a google meet I just saw 65% usage and non-responsive extension button.
Disabled and re-enabled extension cpu dropped but extension (button and options) is non responsive

@ghostwords
Copy link
Member Author

ghostwords commented Mar 6, 2024

Thanks for the additional information! It sounds like it's something about your particular installation of Privacy Badger. Uninstalling and reinstalling Privacy Badger may fix the problem.

If you would like to try debugging though, you could navigate to chrome://extensions, enable developer mode in the upper right corner, and then click on the "background.html" link in Privacy Badger's listing. This will open developer tools for Privacy Badger's background process.

The first thing to do once you've got developer tools open is to see if there are any meaningful errors in the Console tab.

If you can consistently reproduce excessive CPU use, you can also switch over to the Performance tab, start recording a performance profile, and while recording, perform the actions that cause your Privacy Badger to use excessive CPU. We could then review what exactly Privacy Badger did at the time of high CPU use.

Once you finish making a performance recording, you can right-click inside the Performance tab and select "Save profile" to export the performance data.

@nhed
Copy link

nhed commented Mar 6, 2024

image

Seeing this also after re-installing (but see below, I should have confirmed removal from underlying filesystem and probably browser restart).

@nhed
Copy link

nhed commented Mar 6, 2024

well - maybe uninstalling extension and restarting chrome would have done the trick - not sure

When I checked underlying storage to see which LOCK file was attempted - I noticed there were two - one under Local Extension Settings and one under Managed Extension Settings (is the latter because my browser is managed by my org?)

Noticed that the date on the LOCK file was old and renamed whole dir while reinstalling ext - but only then noticed with lsof that chrome was holding on to said renamed dir even when the ext was uninstalled.

after forcing restart of chrome - things came back ok (ext is now responsive)

I will now monitor for the CPU issues and come back here if it recurs

Thanks

@ghostwords
Copy link
Member Author

Sounds good, thank you!

@ghostwords
Copy link
Member Author

ghostwords commented Mar 7, 2024

Looks like the Chrome IO lock error means that Chrome extension storage is broken, which would break pretty much all browser extensions. Restarting Chrome should fix it though. Not sure why or when this happens.

@nhed
Copy link

nhed commented Mar 27, 2024

Just started seeing it again today. Seeing the same LOCK issue - not sure if there is a point in doing the performance recording but did anyway and sent while awaiting disabled the extension (I think it will recreate as long as I do not restart browser - and guarantee proper cleanup in between)

@ghostwords
Copy link
Member Author

ghostwords commented Mar 27, 2024

Thanks for the performance recording!

It looks like the CPU is maxed out because while Privacy Badger failed to properly initialize, probably because of JS errors, maybe the one above, Privacy Badger still injected "content scripts" into the page (for example to help remove tracking from some links inside Gmail) and the content scripts want to know whether they should proceed but Privacy Badger isn't ready to respond to them yet but it will never be ready because of the JS errors and we get an infinite loop at this point.

So ... I should be able to fix the infinite loop, which will fix the CPU issue. However, Privacy Badger will still break now and then for you, where it will fail to finish initializing because something is badly wrong with browser extension storage.

It would be good to figure out what to do to fix the underlying extension storage Chrome issue. Will removing your Chrome profile and starting from scratch do it? Do other people run into this problem? It doesn't seem specific to Privacy Badger.

@nhed
Copy link

nhed commented Mar 28, 2024

Would your fix have any visual indications that the extension failed to initialize?
Let me know if you want me to test - I intentionally left the browser going and just disabled the extention. I cloned your PR branch and I think I'm supposed to "load unpacked" while pointing to the src dir but not sure if there is some prep step to run on the local repo

@ghostwords
Copy link
Member Author

ghostwords commented Mar 29, 2024

Sure, testing would be really nice! We could also then take another look at the errors that cause Privacy Badger to fail on initialization.

There are no extra steps, no build process, just load from src/. Let me know here or over email if you have any questions, and thank you!

@ghostwords
Copy link
Member Author

Would your fix have any visual indications that the extension failed to initialize?

No, the only the thing I changed in #2955 is that the CPU-consuming infinite loop should terminate in under ten seconds.

@nhed
Copy link

nhed commented Mar 29, 2024

unfortunately since offering to test my browser did crash so it will probably be a while before I run into the lock/local-storage issues (but I have the extension loaded from source - had issue running it before the browser restart)

@ghostwords
Copy link
Member Author

I updated #2955 to also style the badge with a red exclamation mark and to show an error message in the popup once failed initialization is detected (after ten seconds or so).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants