el1t / uBlock-Safari

uBlock Origin - An efficient blocker for Chromium, Firefox, and Safari. Fast and lean.
GNU General Public License v3.0
2.74k stars 97 forks source link

Restarting Safari requires uBlock purge & update or pages/filters break every time #26

Closed BillyJoeJimBob closed 7 years ago

BillyJoeJimBob commented 7 years ago

Describe the issue

Every time I restart Safari, many elements are hidden on some websites until I go to the "3rd Party Filters" tab and hit the "Purge All Caches" button followed by the "Update" button. This happens whether my mac has been running all day or after a cold restart. Simply refreshing the page has no effect.

It also appears that some, but not all, of uBlock's filters remain operative even after deselecting individual 3rd party and custom "My Filters" on the 3rd Party Filters Tab and the "I Am An Advanced User" button in the "Settings Tab"; then restarting Safari. All of this happens even if I uncheck every option and filter box in the Settings and 3rd-Partys tabs.

This is not desirable because I can't control which elements are or aren't hidden.

All other extensions are disabled, Safari is on either default or less restrictive settings.

None of this occurs when using the current version of uBlock Origin in Chrome or Firefox. Disabling uBlock Origin in Safari returns to the expected behavior: no filtering at all.

This may be related to issue # 13 on cosmetic filtering, which you addressed previously. My best guess is a cache issue, but I don't really know.

One or more specific URLs where the issue occurs

http://www.cnn.com http://money.cnn.com https://www.bing.com http://www.bing.com http://www.pcmag.com

Screenshot in which the issue can be seen

in each example below, part a is after Safari has been restarted with all filters unchecked.

1a: uBlock dashboard after unchecking all filters and restarting Safari, note the number of network and cosmetic filters listed is as over 100,000 even though all filters are unchecked:

ublock dashboard before purge update

1b: uBlock dashboard above after further clicking Purge, then Update:

ublock dashboard after purge update

2a: bing.com before purge & update (entire background is black/blank):

bing before purge update

2b.: bing .com after purge & update:

bing after purge update

3a.: cnn.com before purge & update:

cnn - before purge update

3b.: cnn.com after purge & update:

cnn - after purge update

4a.: money.cnn.com before purge & update:

cnnmoney - before purge update

4b.: money.cnn.com after purge & update:

cnnmoney - afterpurge update 1 cnnmoney - afterpurge update2 cnnmoney - afterpurge update3 cnnmoney - afterpurge update4

5a.: pcmag.com, before purge & update:

pcmag before purge update

5b.: pcmag after purge & update:

pcmag after purge update

Steps for anyone to reproduce the issue

  1. Restart Safari.
  2. Go to one of these web sites: money.cnn.com; cnn.com; bing.com; pcmag.com
  3. View the web page, in my case, page elements that should be visible are missing, other elements are visible that should be blocked by uBlock filters.
  4. Go to the 3rd Party filters tab, first click the Purge button, then hit the Update button in uBlock settings, wait for the update to complete.
  5. View the web page(s) after the purge & update. In my case, they are now functioning as expected.

--Alternative-- Before restarting Safari in step 1, above, uncheck all the filter boxes in the 3rd-party filters tab including the my filters box, and uncheck the advanced user box in the settings tab. In my case, the page acts as though many of the filters are still enabled.

Your settings

Your filter lists

1: "Default filter lists + Anti-Adblock Killer + Fanboy's Enhanced Tracking List", or 2: all filters disabled

Custom filters:

cnn.com#@#.OUTBRAIN cnn.com##.AR_33.ob_strip_container cnn.com##.cnn-politics-tos--visible.cnn-politics-tos cnn.com##.CRAB_1.ob-strip-layout.ob-widget cnn.com##.CRAB_3.ob-strip-layout.ob-widget cnn.com##.CRAB_4.ob-one-column-layout.ob-widget cnn.com##.ob_dual_left cnn.com##.ob-hover.ob_what cnn.com###health-zone-8 cnn.com###homepage3-zone-1 > > > .zn__column--idx-2.column cnn.com###living-zone-8 cnn.com###politics-zone-6 cnn.com###travel-zone-8 cnn.com###us-zone-7 cnn.com###world-zone-6

Thank you for your work on this project.

gorhill commented 7 years ago

1a: did you click "Apply changes" after un-checking all filter lists?

1b: can you provide a screenshot of the whole "3rd-party filters" pane? "57 network filters + 802 cosmetic filters from" matches exactly what one would have with the filter list "EU: Prebake - Filter Obtrusive Cookie Notices".

BillyJoeJimBob commented 7 years ago

Thank you for the quick reply. You are correct, I had the EU: Prebake list checked. I retraced my steps and have new, more complete screen shots below.

First, I opened Safari, opened the 3rd Party filters tab and deselected all filters, including "My Filters", leaving only "Auto-update filter lists" and "Parse and enforce cosmetic filters" as the only checked options. Then I clicked Apply changes. I then opened the Settings tab and deselected the "I am an advanced user" option. Next I closed and quit Safari. I then restarted Safari and took screen shots 1a-5a below. The 3rd party filters tab shows 100,000+ filters active at this point and websites respond as if some of the filters are enabled.

After taking screens shots 1a-5a, I returned to the 3rd Party filters tab, which was still showing 100,000+ filters active and the "Update Now" and "Purge all caches" were greyed out. I selected one of the filter boxes which caused the "Apply changes" button to appear. I clicked the "Apply changes" and the number of active filters changed. I deselected that same filter followed by the "Apply changes" button again, now the number of active filters is 0 and webpages . I then took screen shots 1b-5b below. At this point, if I close, quit and restart Safari, the 3rd Party filters tab will revert to showing 100,000+ filters active, even though all of the filters remain unchecked. It will again treat web pages as though many filters are enabled until I repeat the above steps.

1a. uBlock Origin dashboard after unchecking all filters, closing and quitting Safari, then restarting:

image image image image

1b. uBlock Origin dashboard after checking a filter, clicking apply changes, deselecting that filter, the clicking apply changes again:

image image image image

Screenshots of example websites 2a/2b - 5a/5b will follow in a subsequent post.

gorhill commented 7 years ago

You don't need to show all filter lists, my original demand was because your 3rd-party filters pane was saying "57 network filters + 802 cosmetic filters from" which you confirmed because EU Cookies was still selected.

gorhill commented 7 years ago

First, I opened Safari, opened the 3rd Party filters tab and deselected all filters, including "My Filters", leaving only "Auto-update filter lists" and "Parse and enforce cosmetic filters" as the only checked options. Then I clicked Apply changes.

When you un-select all filters (before 1a) then click "Apply change" and before quitting Safari, do the filter counts change to zero in the 3rd-party filters pane?

BillyJoeJimBob commented 7 years ago

Screenshot 2a, showing bing.com after filters deselected and Safari restarted, but before "Apply changes" button clicked:

bing 2017-02-10 10-13-08

Screenshot 2b, bing.com after "Apply changes" button clicked:

bing 2017-02-10 10-20-10

Screenshot 3a, cnn.com before:

cnn - breaking news latest news and videos 2017-02-10 10-13-43 image image image

Screenshot 3b, cnn.com after:

image image image image image

Screenshot 4a, money.cnn.com before:

image image image

Screenshot 4b, money.cnn.com after:

image image image image image

Screenshot 5a, pcmag.com before:

image image image image

Screenshot 5b, pcmag.com after:

image image image image image

-- Again, thank you for you assistance.

BillyJoeJimBob commented 7 years ago

When I un-select all filters at 1a, then click "Apply change" and before quitting Safari, the filter counts do indeed change to zero in the 3rd-party filters plane. When I subsequently close, then quit, then restart Safari, the 3rd-party filters pane reverts to showing 100,000+ filters enabled while at the same time, all of the individual filter boxes remain unchecked.

gorhill commented 7 years ago

When I subsequently close, then quit, then restart Safari, the 3rd-party filters pane reverts to showing 100,000+

@el1t From the look of it, it is as if the selfie is not removed from the cache storage. This is were the call is made: https://github.com/gorhill/uBlock/blob/cbca48307c50d4e243462c4c86af03453bbdf766/src/js/storage.js#L919.

When the user clicks Apply changes, the line above should be executed. Given that there is no callback passed to localForage.removeItem, I wonder if it's possible that the operation never actually completes in the current scenario, though that would be quite surprising given the delay between clicking Apply changes and quitting the browser.

BillyJoeJimBob commented 7 years ago

Do you think this issue is universal or is it just my machine?

el1t commented 7 years ago

Sorry for the delay. I can't seem to trigger this behavior; here's what I've tried:

  1. Check only default filters, click apply
  2. Uncheck all filters, click apply (number active changes to 0+0)
  3. Visit website (money.cnn.com, no filters visible)
  4. Restart Safari
  5. Check 3rd party filters, shows 0+0 enabled
  6. Visit website (same, no filters visible)

Let me know if I missed something there. I tried closing Safari quickly after applying changes, but the changes still commit. Also, I verified that selfie is undefined after hitting apply.

BillyJoeJimBob commented 7 years ago

Following your steps, if at step 4 I just close Safari via the red button and then reopen, I get the behavior you described. If I quit Safari from the drop menu and then reopen, I get the following results:

Screenshot 1, uBlock Origin with default filters checked:

ublock dashboard 2017-02-13 05-45-33

Screenshot 2, uBlock Origin with no filters checked and the number of filters enabled reads as zero:

ublock dashboard 2017-02-13 05-46-17

Screenshot 3, uBlock Origin after quitting Safari and then reopening now showing a large number of filters enabled (larger number than in screenshot 1):

ublock dashboard 2017-02-13 05-47-04

The advanced user option for dynamic filters is disabled, all other add-ons disabled. I will try and replicate this on a different Mac today.

BillyJoeJimBob commented 7 years ago

After step 3 above, if I check any one of the 3rd party filters and then apply, the number of filters indicated changes to just that of the newly checked filter. Further unchecking that filter again results in the total number returning to zero.

BillyJoeJimBob commented 7 years ago

I tried this again on another Mac and there were no issues. I uninstalled and trashed uBlock Origin on the problematic Mac and downloaded it again and the issue is no longer present, so it was likely unique to this Mac. The only remaining quirk is the bing.com background is still black when using EasyPrivacy filter, which doesn't occur in Chrome or Firefox. Thank you for your assistance.