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

Improve startup #2438

Merged
merged 7 commits into from
Mar 4, 2020
Merged

Improve startup #2438

merged 7 commits into from
Mar 4, 2020

Conversation

ghostwords
Copy link
Member

@ghostwords ghostwords commented Aug 21, 2019

Related to #1845.

  • Fixes badger.INITIALIZED to account for asynchronous initialization tasks (such as seed data loading). This removes the need for workarounds in places that care about Badger being fully initialized (might want to keep them though in badger-sett for a while longer to enable running with Badgers that won't have this fix).
  • Postpones non-essential initialization tasks (such as fetching yellowlist/DNT hashes from eff.org)
  • Sets up an early chrome.onBeforeRequest listener to cancel all requests before Badger is done initializing. Reloads the tabs for the cancelled requests upon Badger being ready. (fb68766, 0de95d8) This should be guaranteed to catch all requests on startup in Firefox thanks to a "persistent" listener, and should catch more requests on startup in Chrome thanks to initializing a blocking listener faster.

* @returns {Object}
*/
function onBeforeReady(details) {
if (!pendingTabs || details.tabId < 0) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when would pendingTabs be falsey here?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We set pendingTabs to null at the end of reloadPendingTabs(). Is it possible to still have requests queued for onBeforeReady() after stopBeforeReadyListener() is called? I would have to look into it.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We may want to ignore "main_frame" resources to avoid running into gorhill/uBlock#3130

}

function stopBeforeReadyListener() {
chrome.webRequest.onBeforeRequest.removeListener(onBeforeReady);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the listener not be removed for it to be treated as "persistent" by Firefox? See uBlockOrigin/uBlock-issues#128 (comment)

Called in a loop on (seed) data import.
Removes a getBaseDomain() call from a loop.
@ghostwords ghostwords merged commit 6cfcfa6 into master Mar 4, 2020
@ghostwords ghostwords deleted the improve-startup branch March 4, 2020 23:18
ghostwords added a commit that referenced this pull request Mar 5, 2020
@ghostwords ghostwords mentioned this pull request Mar 21, 2023
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

Successfully merging this pull request may close these issues.

None yet

2 participants