JavaScript-Blocker-5 icon indicating copy to clipboard operation
JavaScript-Blocker-5 copied to clipboard

High CPU usage

Open m4rkw opened this issue 8 years ago • 29 comments

I occasionally see Safari using 100% CPU continuously. Looking in activity monitor there is one single safari tab causing the load, all of them show around 0-5%, yet Safari itself is using 100%.

When this is happening if I disable the extension the cpu load drops immediately.

m4rkw avatar Nov 03 '17 13:11 m4rkw

Are you on any particular website when this happens? Do you have user scripts installed?

infernoboy avatar Nov 09 '17 08:11 infernoboy

No user scripts, not noticed it connected to any particular website. I've nuked my local safari directories and started fresh, will monitor in case it was a local file corruption issue.

m4rkw avatar Nov 09 '17 14:11 m4rkw

I get this problem too, exactly as described. Interestingly, CPU usage doesn't immediately spike after re-enabling the plugin, it just seems to build up over time.

I do have one user script installed but it's set to only work on one site. I don't see this on particular websites, it seems pretty general.

Finally, I did a clean reinstall of MacOS about 3 weeks ago.

boncey avatar Nov 18 '17 11:11 boncey

This happens for me too. I suddenly have CPU usage from 95-125% and closing all tabs does not have any effect - it will go on for up to half an hour - as long as I have been able to leave Safari without having to quit and relaunch. It is definitely JS Blocker as Safari CPU drops to a more reasonable 20% as soon as it is deselected in preferences without even reloading any pages.

I have tried installing the latest versions from both the Apple Extensions repository and from JS Blocker site and neither have made any difference. The only solution has been to disable JS Blocker so that the fan noise does not drive me insane.

Section25 avatar Dec 09 '17 13:12 Section25

Will the CPU usage ever drop? Can you force the CPU usage to spike by trying this: Settings > Rules > click "Update Filter Lists"?

infernoboy avatar Dec 10 '17 23:12 infernoboy

I just tried that but when I did so it said that the rules had been updated just over a day ago anyway.

I just left my MBP for ten minutes (before doing the above) and came back to my fans screaming and Safari (with no open windows) fighting with kernel_task for CPU (~100% each) and only 200MB of 8GB of RAM free. I couldn't even get the extensions pane in Safari to show - just SBBoD and as soon as I quit Safari, kernel_task CPU dropped to about 5%.

I'm not saying that this incident was down to JS Blocker but other than not being able to access the Extensions pane in Safari preferences to do so, it fits the pattern, i.e. Safari with no windows open hogs CPU until JS Blocker is disabled.

Section25 avatar Dec 11 '17 21:12 Section25

Does the issue persists with a clean install of JSB? That is, restore to default settings by opening the Settings menu and clicking Restore Defaults twice. You can create a backup from that same menu. If possible, it could be helpful if you posted your backup so I can run JSB using your exact settings (and rules, if you allow it).

infernoboy avatar Dec 11 '17 22:12 infernoboy

Here is my backup.

As you will see, I have only added my own rules on two sites - one was twitter.com as it was causing ballistic CPU usage whenever I scrolled very far down the page and the other was tpb.tw which was doing the same using a coin mining script. In both cases, JS Blocker successfully solved these problems.

JSB-Backup.json.zip

Section25 avatar Dec 12 '17 09:12 Section25

The next update will disable compression, which could be a cause of the CPU spikes. If you'd like to test it now, I've included it here.

Edit: This version also includes the ability to see how long it takes JSB to save certain data. To see it, turn on debug mode from Menu > Console. After a while, messages will start appearing there.

JSB5-5.3.0-beta1.safariextz.zip

infernoboy avatar Dec 12 '17 22:12 infernoboy

It's installed. I'll report back in a days or so.

Section25 avatar Dec 13 '17 09:12 Section25

Er, all I can say is that it is different.

I'm not getting the CPU spikes but everything is much slower. If I am entering text on Twitter, I am typing about 5-10 characters ahead of them appearing on screen and nearly all pages are loading slowly. I restart Safari with JS Blocker enabled and there is no change. Disable JS Blocker and everything returns to normal speed. Quite frustrating.

Section25 avatar Dec 14 '17 11:12 Section25

Are you seeing CPU spikes while typing that disappear once you stop? I'm not seeing any issues using your backup myself so I have no idea what could be wrong.

Are there any useful log messages in Safari's web console while on twitter?

infernoboy avatar Dec 14 '17 22:12 infernoboy

I just rebooted my Mac and I'm having a relatively quiet CPU period but I will monitor the Twitter activity.

Section25 avatar Dec 15 '17 09:12 Section25

Hey, how is progress with this issue? I've stopped using the extension due to the cpu spikes. Would be good to know if it's fixed yet.

m4rkw avatar Jan 04 '18 11:01 m4rkw

The latest update, 5.3.0, disabled compression which should help with cpu usage. It's difficult for me to test personally as I've not had any problems even with compression on.

On Jan 4, 2018, at 6:16 AM, Mark Wadham [email protected] wrote:

Hey, how is progress with this issue? I've stopped using the extension due to the cpu spikes. Would be good to know if it's fixed yet.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.

infernoboy avatar Jan 04 '18 11:01 infernoboy

Ok i've installed it, will keep an eye and report back in a week or so.

m4rkw avatar Jan 04 '18 11:01 m4rkw

Still having the problem so have disabled the extension again. It would be good to get to the bottom of this.

m4rkw avatar Jan 10 '18 23:01 m4rkw

I too frequently get the 100% CPU usage with JSBlocker enabled. Running High Sierra and a clean JSB.

e1782753 avatar Jan 16 '18 13:01 e1782753

I'm also seeing the CPU issue on High Sierra 10.13.4, but in my case it's caused by a massive memory usage, and subsequently the CPU is busy writing RAM to the SSD.

maia avatar Apr 05 '18 13:04 maia

@infernoboy it would be nice to see some progress on this as i frequently wish i had a selectable javascript blocker but i can't have an extension eating all my cpu. is there any way we can capture some debug logs for you to debug this?

m4rkw avatar Apr 26 '18 13:04 m4rkw

Unfortunately there hasn't been much improvement here. It happens maybe twice a month for me and by the time I catch it, Safari is unusable and I can't diagnose what's going on. There isn't enough debug code to catch something like this. Safari spin dumps are unhelpful.

infernoboy avatar Apr 26 '18 14:04 infernoboy

In the past weeks I've been seeing the excessive memory (and cpu-load caused by swapping) on a daily basis. Three tabs are usually open all the time: Heroku Dashboard, Scoutapp and New Relic. Whoever has logins with any of these webapps, might want to test if they can reproduce the issue.

maia avatar Apr 27 '18 13:04 maia

@maia presumably you're allowing those webapps to run javascript, i wonder if there's some kind of overhead that jsblocker introduces when scripts are allowed to run.

m4rkw avatar May 02 '18 07:05 m4rkw

Oh, I just looked at the source code. This entire extension is implemented in javascript, no wonder it's slow!

m4rkw avatar May 02 '18 07:05 m4rkw

I've reinstalled the extension, going to try running it with everything disabled except for script blocking. Hopefully the cpu issue is buried somewhere in the extra features that I don't really care about. Will post back here after a while with results.

m4rkw avatar May 02 '18 07:05 m4rkw

I have exactly the same problem as people here. The newest version of an extension (5.3.1), Safari Version 11.1.2 (13605.3.8). Had to uninstall JS Block because every few pages CPU went 100%. I am not able to reproduce it on a specific page though :/

sirmike avatar Jul 23 '18 20:07 sirmike

Pretty disappointing that this has been open since November with no progress at all.

m4rkw avatar Aug 13 '18 13:08 m4rkw

Those kind of problems are very hard to reproduce. The more info we provide here, the easier it will be to fix. Let's hope that @infernoboy will be able to identify the root cause.

sirmike avatar Aug 13 '18 13:08 sirmike

It happens for me from time to time whenever my computer wakes up. I usually restart Safari and it helps. Next time it happens to me again, I will try to capture some details.

kyrylo avatar Aug 22 '18 05:08 kyrylo