EFForg / privacybadger

Privacy Badger is a browser extension that automatically learns to block invisible trackers.
https://privacybadger.org
Other
3.19k stars 386 forks source link

Don't wait for managed storage on startup #2982

Closed ghostwords closed 5 months ago

ghostwords commented 5 months ago

To work around chrome.storage.managed.get() taking a wildly long time to return sometimes during browser startup.

Follows up on #2971 and https://github.com/EFForg/privacybadger/issues/2966#issuecomment-2153316523

The diff is best viewed with whitespace ignored.

To test, we are going to want to reuse a browser profile. Install the dev version of Privacy Badger in Chrome beta [^1], configure Chrome to "continue where you left off" in chrome://settings/onStartup, open some tabs, then restart Chrome beta and check the total time for "initialization complete" before and after this patch. Restart a few times to get a sense of timing.

We should also verify that managed storage settings still get applied.

[^1]: make crx and drag and drop the CRX into chrome://extensions on Linux. On macOS, since non-CWS CRXs can only be installed via policy, it's easier to "load unpacked" instead.

ghostwords commented 5 months ago

In the Chrome MV3 branch, if I have a few tabs open and the active tab is a typical news website that has a lot going on, I consistently reproduce mega delays for managed storage. For example, after this patch, we get to "Storage is ready" in 0.54s, "Initialization complete" in 0.96s, and chrome.storage.managed.get() returns in 11.63s on browser startup.