uBlockOrigin / uMatrix-issues

This is the community-maintained issue tracker for uMatrix
https://github.com/gorhill/uMatrix
123 stars 17 forks source link

"Show the number of blocked resources on the icon" may be temporarily forced to default when restoring session #75

Open ssokolow opened 6 years ago

ssokolow commented 6 years ago

Prerequisites

Given that it happens as part of session restore, I couldn't figure out a way that it would be possible to bring the logger into play... even if rulesets were able to control this particular aspect of the UI.

Given the nature of the problem, which I suspect to be a race condition, I'm going to need to block out some serious time to test under the reduced conditions (uMatrix only, default lists/settings, new browser profile), since I don't yet have a standard practice for quickly building a fresh browser profile that's intentionally bogged down and I wanted to know whether what I've submitted is enough before I potentially spend needless time on it.

Description

Sometimes, when I restart my Firefox, uMatrix displays the active tab's browser action with the blocked resource count visible, despite the "Show the number of blocked resources on the icon" checkbox being unchecked.

The browser action for any tab loaded or reloaded after the session restore finishes (including reloading the same tab) will obey the user preferences as expected, so I suspect this is some kind of race where it's falling back to default settings because loading the user preferences was delayed.

A specific URL where the issue occurs

This time, the tab which was active after I restarted the browser was pointed at https://github.com/piroor/treestyletab/issues/2006#issuecomment-420049470

Steps to Reproduce

  1. Check "Restore previous session" in Firefox
  2. Uncheck "Show the number of blocked resources on the icon" in uMatrix
  3. Open a page which has blocked resources
  4. Open up enough stuff to bog down the session restore process (My session contains 443 tabs across four windows on three monitors, plus three dozen browser extensions, running on an Athlon II X2 270 (dual-core) CPU with no SSD and my Firefox starts up as part of a flurry of on-login tasks that bog the desktop down for over a minute as they contend for resources.)
  5. Restart the browser

Supporting evidence

screenshot20

screenshot21

Your environment

uBlock-user commented 6 years ago

My session contains 443 tabs across four windows on three monitors, plus three dozen browser extensions, running on an Athlon II X2 270 (dual-core) CPU with no SSD and my Firefox starts up as part of a flurry of on-login tasks that bog the desktop down for over a minute as they contend for resources.

That's not possible for me to recreate. Is that a specific requirement ?

Aside from that, I cannot reproduce. Most likely a race condition due to Restore previous session settings which forces to restore immediately upon startup.

ssokolow commented 6 years ago

That's not possible for me to recreate. Is that a specific requirement ?

Just a parenthesized clarification on the situation where the problem has been observed outside test conditions. I'll see if I can find time to produce something more reliable later.

(One idea I have is to try with a warm filesystem cache and then clear out the drive and OS read caches before running the test in order to see if that alters the chances of a successful reproduction.)

Aside from that, I cannot reproduce. Most likely a race condition due to Restore previous session settings which forces to restore immediately upon startup.

That was my hypothesis too, given the symptoms.

uBlock-user commented 6 years ago

I tested with 5 tabs of blogs with heavy content blockage on both Chromium and Firefox, the setting sticks, still cannot reproduce.

gorhill commented 6 years ago

Most likely a race condition due to Restore previous session settings which forces to restore immediately upon startup.

Yes. uMatrix is not guaranteed to be fully ready when the browser loads the tabs, and given in the current case there are hundreds of tabs, tens of extensions (of which uMatrix is just one of them), uMatrix probably finishes loading user settings after the tabs finished loading.

You can actually reproduce with a simpler scenario: open uMatrix's dashboard in a separate window, have a tab with blocked stuff in the original window (such that there is a badge for it displayed), and toggle the setting "Show the number of blocked requests on the icon": the badge is not toggled unless it needs to be re-rendered.

It's really a very transient "glitch" though, just switching tab or whenever the tab is reloaded, the issue disappear. I consider this a bottom-of-the-list issue given that: difficult to reproduce + only cosmetic + very transient.

ssokolow commented 6 years ago

I'm guessing this is another facet of the ongoing problem of WebExtensions not yet providing a way for early tab loading to block on extensions being ready to filter the requests?

(Because, otherwise, I'd wonder why you're not storing all the settings in whatever datastore is currently used for user rulesets.)

uBlock-user commented 6 years ago

The race condition is an issue which hasn't been addressed as expected.

gorhill commented 6 years ago

I'd wonder why you're not storing all the settings in whatever datastore is currently used for user rulesets.

You are assuming wrong, they are saved in the same datastore.

ssokolow commented 6 years ago

You are assuming wrong, they are saved in the same datastore.

I wasn't assuming anything. I wrote that as an "otherwise" case after saying something that boils down to "I'm guessing this is another symptom of WebExtensions not giving uMatrix sufficient power to ensure proper ordering of operations?".

gorhill commented 6 years ago

Note that whenever I fix #69 the current issue could go away as well.

ssokolow commented 6 years ago

Hopefully.

Either way, I'm in no rush. I just wanted it to be "on file".