Skip to content

Race condition between uBlock / Chromium policies #1608

Closed
@anulman

Description

@anulman

Prerequisites

  • I verified that this is not a filter issue
  • This is not a support issue or a question
  • I performed a cursory search of the issue tracker to avoid opening a duplicate issue
    • Your issue may already be reported
  • The issue is not present after wholly disabling uBlock Origin ("uBO") in the browser
    • If the issue is still present after wholly disabling uBO in the browser, then the issue is unrelated to uBO
  • I tried to reproduce the issue when...
    • uBO is the only extension
    • uBO with default lists/settings
    • using a new, unmodified browser profile
  • I checked the documentation to understand that the issue I report is not a normal behavior

Description

I'm managing a uBlock deployment where we need to update the policy on each deploy because the extension ID is not guaranteed to be consistent between deploys. After we update the policy, we restart Chromium, so we know the extension is running its js/start after the policy file has been written.

Meanwhile, uBlock does not consistently apply the policy's settings. I suspect there is a race condition somewhere, where e.g. Chromium does not guarantee chrome.storage.managed has loaded all its policy files before extensions start to load.

I suspect the chrome.storage.onChanged.addListener API could help fix this easily, and also let deployment admins hot-swap policies as necessary. For example, running µBlock.restoreAdminSettings().then(µBlock.loadSelectedFilterLists) seems to work, although I bet we'd want to adopt some other js/start callbacks too.

A specific URL where the issue occurs

N/A, but here's a Loom: https://www.loom.com/share/55aa104db8d649f1aa622b137ed01cfa

Steps to Reproduce

  1. Set up a policy in /etc/chromium/policies/managed/ublock_policy.json
  2. uBlock doesn't load the policy unless you reload the extension, or quit and restart Chromium
  3. Now quit Chromium and update the policy
  4. When you reopen Chromium, uBlock may or may not have loaded the new policy data

Expected behavior:

I expected the policy to be consistently applied in Step 4, and hoped it would have been applied in Step 2

Actual behavior:

The policy was inconsistently applied (today 2/3 times; on Friday's testing 1/4 times) in Step 4, and is never applied in Step 2

Your environment

  • uBlock Origin version: 1.35.2
  • Browser Name and version: Chromium 90.0.4430.93 (via Mighty)
  • Operating System and version: Linux

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingfixedissue has been addressed

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions