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

uBlock modifies the file com.apple.Safari.Extensions.plist every few minutes #56

Open
quantumgolem opened this issue Jun 27, 2017 · 15 comments

Comments

@quantumgolem
Copy link

quantumgolem commented Jun 27, 2017

Describe the issue

Because of uBlock, my com.apple.Safari.Extensions.plist file, located in /Users/sn0wyfall/Library/Preferences/com.apple.Safari.Extensions.plist, is nearly 40 MB big. This is fine, but there is a big problem: for some reason, uBlock seems to like modifying this file every couple of minutes. A lot of the time literally nothing seems to change in the file. I tried diffing two versions, and it seemed as though nothing changed.

Now normally this wouldn't be a big issue, but Time Machine views these as different files. It backs them up and this has added nearly a gigabyte to my backup over the past few days.

Would it be possible to prevent the file from being updated so often?

I tried looking at whether any of my lists were being updated, but it looked like they weren't. It seems as though this isn't related to which lists I have active.

This issue goes away when I disable uBlock.

If you want to check whether this happens to you, go to:

/Users/myUsername/Library/Preferences/com.apple.Safari.Extensions.plist

and then check the last modified date. Does it reflect the time a few minutes ago?

Your settings

[If you fail to provide this info, I will mark the issue as invalid. Lists all settings which differs from default settings]

  • MacOS version: 10.12.5
  • Safari version: 10.1.1
  • uBlock Origin version: 1.12.5b
Your filter lists

Will update in a bit

Your custom filters (if any)
@quantumgolem
Copy link
Author

I disabled all filter lists but it still happens

@quantumgolem quantumgolem changed the title Extension modified com.apple.Safari.Extensions.plist every few minutes uBlock modifies the file com.apple.Safari.Extensions.plist every few minutes Jun 27, 2017
@the-real-tokai
Copy link

the-real-tokai commented Jul 14, 2017

I think Safari triggers the rewrite. Try disabling uBlock and just let Safari sit there and do nothing with it. Now start Terminal and write something like:

$ sudo fs_usage cfprefsd | fgrep com.apple.Safari.Extensions.plist

You'll notice the file gets rewritten every 3 to 4 minutes. No matter what.

It especially gets nasty when you had or still have AdBlock extension installed. It stores all its blocking lists in a way they end up in this extensions preferences file causing it to blow out of proportion and cfprefsd writing GiBs of data every day onto your disk for no real reason at all. Just with uBlock the file should be only some hundred KiB in size which reduces disk stress greatly. I agree though that the whole deal shouldn't be rewritten constantly for no real reason (it is like a Damocles' sword hanging above your disk waiting to trigger Apple's carefully planned obsolescence.)

Best is to open the com.apple.Safari.Extensions.plist with Xcode and see what's stored in there causing the huge file size and delete the respective entries. Quit Safari, uninstall AdBlock extension(s) (or other culprits), now save the edited preferences file in Xcode and quickly kill the cfprefsd of your user (e.g. via Activity Monitor). This usually should adjust things to a more sane state.

I've been there too just recently. 😁

@quantumgolem
Copy link
Author

@the-real-tokai Wow, thanks a lot for the detailed comment! I have to say, I was looking for something like this without any hope of finding it.

Yes, the file does get continuously rewritten. It’s a big problem for me. I actually don’t (and didn’t) use Adblock, just uBlock – however, my file is nearly 40 MB large! It’s not just a few hundred kilobytes. That means that cfprefsd does write a lot of data to my disk – over 20 GB a day (something I believe this goes up to 50 GB, which is crazy). That amounts to nearly 1 TB (or more!) in a month. I know that people say that you should never worry about SSDs wearing out as they always will outlive the machine they are in, but this cfprefsd issue, combined with my occasional heavy usage, suggests that I might not be as lucky.

I’ve actually been trying to find out what’s behind this cfprefsd issue for months now, and never could find a relevant proposed solution – until now!

However, I did try what you suggested – to disable uBlock and to not use Safari – and it looks like the file isn’t being written to anymore, after running the command for about ten minutes. Then I tried using Safari with it disabled, and still no activity. Then I enabled uBlock and left Safari in the background, and started to open and rename it. So it seems like the problem for me really is with uBlock. What can I do? I’m not disabling uBlock, but there has to be a way to reduce the size of the file to save my poor disk. I'll try your suggestion with opening the plist and see if there is anything I can get rid of (most likely some large filter lists).

@quantumgolem
Copy link
Author

Okay, so I quickly disabled easylist, as well as some other lists (which added up to around 100,000 filters), but the file size remained the same. I'm not sure whether these are stored in the plist's "cache." I probably could figure it out by diffing these files, but as you can tell, diffing these files is not an easy task!

Oh, by the way, I had to exclude com.apple.Safari.Extensions.plist from my Time Machine backup, since it's modified so frequently! Time Machine backs it up every time, and eats up my backup disk space...

@the-real-tokai
Copy link

the-real-tokai commented Jul 19, 2017

Did you load up the file in Xcode to see what's inside exactly? There might be a lot of old ballast inside (from extensions you had installed previously). I don't think old stuff gets wiped automatically here (I'm not entirely sure how Safari handles this)

Or try this command to get a quick overview via Terminal:

$ /usr/libexec/PlistBuddy -c 'print' ~/Library/Preferences/com.apple.Safari.Extensions.plist | fgrep 'ExtensionSettings-'

What does that print for you?

BTW, uBlock's lists are stored in a different place: ~/Library/Safari/Databases/safari-extension_com.el1t.ublock-<some cryptic number>/, so whatever lists you have enabled it should change the com.apple.Safari.Extensions.plist file only very minimally (flags which lists are enabled or not).

@bryandmlee
Copy link

bryandmlee commented Jul 19, 2017

I checked my com.apple.Safari.Extensions.plist file, and even though mine's only 57KB, it is being (not just modified, but re-) created every few minutes or every time Safari is opened. I guess that's why Time Machine keeps backing up "new" copies of the plist file even though the contents don't seem to have changed? Because it is literally a new file being created every time.

I'm not really sure how I might further troubleshoot this, but I hope my observation helps any of you get closer to figuring out what's causing the constant re-writes and/or how to resolve it!

@gorhill
Copy link

gorhill commented Jul 19, 2017

uBO will save to its settings the block/allow counts (the "since install" stats) when all conditions below are met:

  • If the allow or block count changed;
  • If the last save was more than 4 minutes ago

@quantumgolem
Copy link
Author

@gorhill Thanks! That would explain why this file keeps being rewritten.

@quantumgolem
Copy link
Author

@the-real-tokai Nice command! I ran it, and this is what it shows:

ExtensionSettings-com.el1t.uBlock-3NU33NW2M3 = Dict {

And that's the only thing is shows, which confirms my suspicion that only uBlock is causing this. Why it's not so for all of you is a question I have.

I tried opening it with Sublime Text instead of Xcode (it's much faster). It seems like I have filter lists in this file. There are a lot of sites listed. However, my lists are indeed stored in that folder you mentioned, so I can't figure out why they're in my com.apple.Safari.Extensions.plist as well. I'm very tempted to delete this file but I'm scared my Safari settings will be wiped or something.

@the-real-tokai
Copy link

the-real-tokai commented Jul 25, 2017

@sn0wyfall I would create a back-up of the plist file, after that go to uBlock's settings and use 'Backup to file', then quit Safari, use the defaults command (see below) to wipe the settings file (plist), restart Safari, go to uBlock's settings page and use 'Restore from file'. In theory this should wipe old stuff without loosing all of uBlock's current settings.

$ defaults delete ~/Library/Preferences/com.apple.Safari.Extensions.plist

Just in case also make a few screenshots of all of uBlock's settings pages, then you can compare/ verify later.

@the-real-tokai
Copy link

@gorhill Maybe this duration should be configurable and the whole feature also disable-able? Personally I don't care much about some 'since the beginning of time' stats, for example, so all this saving could be omitted in my case. 😄

@quantumgolem
Copy link
Author

@the-real-tokai Whew, thanks for the quick reply! I can try this out right now. Seems like a pretty smart way to go about doing it.

@quantumgolem
Copy link
Author

@the-real-tokai Awesome, nice! It worked! Now it's only 100 KB, which is great. The only problem is that I see is that my stats were reset (which I actually do care about), but that's not a huge deal. I had around 200,000, almost like you. Editing the figure in the file doesn't change uBlock's figure, so it's probably going to be overwritten by uBlock, so that won't work. I do support your idea for the duration to be changeable, or at least made to 60 minutes – I think that would be fine for most use case scenarios

@the-real-tokai
Copy link

the-real-tokai commented Jul 25, 2017

@sn0wyfall Glad it worked out! 😃

When you edit the plist file manually you have to kill the cprefsd of your user quickly afterwards, or better use the defaults command to update the respective attribute. The cprefsd caches all preferences files and overwrites your manual edits if it feels like it. If you use the defaults command then this situation is handled (it actually instructs the cprefsd to update too.)

But then...
better lose some stats than kill your disk! 👍

@quantumgolem
Copy link
Author

Yeah, right, better lose some stats instead of losing my disk! I'll monitor the usage and see if this has finally fixed it (I can't tell yet)

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

No branches or pull requests

4 participants