proginosko / LeechBlockNG

LeechBlock NG (Next Generation) for Firefox is a simple productivity tool designed to block those time-wasting sites that can suck the life out of your working day. All you need to do is specify which sites to block and when to block them.
https://www.proginosko.com/leechblock/
Mozilla Public License 2.0
721 stars 66 forks source link

High CPU usage #268

Open Germano0 opened 2 years ago

Germano0 commented 2 years ago

When Firefox 104 is using a lot of CPU and you open about:performance, you will often find out that the reason is LeechBlock NG 1.5.1

proginosko commented 2 years ago

Do you have a lot of tabs open?

peitl commented 2 years ago

I can confirm I have the same issue, and yes, I do have a lot of tabs open.

proginosko commented 2 years ago

Select the option "Process only active tabs" under General options and see if that helps.

Germano0 commented 2 years ago

I selected Process only active tabs, restarted Firefox, but the CPU usage is still high. Yes I have many tabs, but for example UBlock Origin is not suffering from the high amount of opened tabs immagine

proginosko commented 2 years ago

Please export your options to a file and email it to leechblockng@proginosko.com so I can investigate further.

peitl commented 2 years ago

For the record, I selected Process only active tabs and it seems to have fixed the issue. I still wonder though, where the issue was coming from in the first place. I thought LeechBlock was only in operation when a new page is being loaded, is that not so?

proginosko commented 2 years ago

No, LB regularly checks tabs in case the blocking conditions have been met since the page originally loaded (e.g., the time limit has been reached, or a page with dynamic content has introduced a keyword that should trigger a block). This is necessary to support the "Immediately block pages on these sites once blocking conditions are met" option.

peitl commented 2 years ago

Fair enough, but if that option is off (as it is in my case), then LB should only activate when a new page is being loaded, shouldn't it?

proginosko commented 2 years ago

Sorry, I should have added that LB regularly checks tabs also to keep track of the amount of time spent on sites. That will happen regardless of the "Immediately block" setting. If you've selected "Process only active tabs" you shouldn't have high CPU usage though. Do you have a very long block list?

peitl commented 2 years ago

No, I'm blocking around 20 domains in total. I also don't have any rules set up to block pages after a certain amount of time. I don't have a high CPU usage all the time now (having ticked "Process only active tabs"), but there are still CPU usage spikes from LB every now and then.

Even if LB has to regularly check a large number of tabs for time spent, I don't see how that should make it use a lot of CPU, that is not a complicated operation, is it? It's not like I have millions of tabs.

mtmkls commented 1 year ago

Sorry, I should have added that LB regularly checks tabs also to keep track of the amount of time spent on sites. That will happen regardless of the "Immediately block" setting. If you've selected "Process only active tabs" you shouldn't have high CPU usage though. Do you have a very long block list?

Why does LB keep track of the amount of time when I have not set time limits? Why does LB keep track of the amount of time on all (active) tabs instead of just the focused one?

proginosko commented 1 year ago

Why does LB keep track of the amount of time when I have not set time limits?

(1) For the Statistics page. (2) In case a time limit is added on the fly.

Keeping track of the time is not itself CPU intensive. Even without a time limit for a block set, the processing would be much the same.

Why does LB keep track of the amount of time on all (active) tabs instead of just the focused one?

"Active tab" just means the focused tab in this context.

mtmkls commented 1 year ago

Keeping track of the time is not itself CPU intensive.

Okay, then why is this extension by far the highest energy impact in the firefox task manager constantly?

proginosko commented 1 year ago

In your case, I don't know (yet). You make it sound like this is an issue for all users, but as far as I can tell, it's only an issue for a small number of users. If you want to help, you could do some diagnostics to narrow down the cause. Disable all but one of the block sets (see option to disable under Advanced Options) and see if the CPU impact is still high. Repeat for the other (used) block sets. See if the issue can be traced to one particular block set, and if so, we can take a closer look.