mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-05 18:32:30 +01:00
Fix race condition at browser launch re. cosmetic filtering
Related issue: - https://github.com/uBlockOrigin/uBlock-issues/issues/974 Related feedback: - https://www.reddit.com/r/uBlockOrigin/comments/fuscia/ The race condition was that a content script could query the main process to retrieve cosmetic filters while the cosmetic filters had not been yet fully loaded into memory. The fix ensure that an already injected content script will re-query once the cosmetic filters are fully loaded in memory at browser launch time.
This commit is contained in:
parent
1295e25961
commit
df08b12d48
@ -165,6 +165,10 @@ const µBlock = (( ) => { // jshint ignore:line
|
||||
selectedFilterLists: [],
|
||||
availableFilterLists: {},
|
||||
|
||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/974
|
||||
// This can be used to defer filtering decision-making.
|
||||
readyToFilter: false,
|
||||
|
||||
pageStores: new Map(),
|
||||
pageStoresToken: 0,
|
||||
|
||||
|
@ -509,6 +509,7 @@ vAPI.messaging.listen({
|
||||
const µb = µBlock;
|
||||
|
||||
const retrieveContentScriptParameters = function(senderDetails, request) {
|
||||
if ( µb.readyToFilter !== true ) { return; }
|
||||
const { url, tabId, frameId } = senderDetails;
|
||||
if ( url === undefined || tabId === undefined || frameId === undefined ) {
|
||||
return;
|
||||
|
@ -27,7 +27,7 @@
|
||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/403
|
||||
// If the content script was not boostrapped, give it another try.
|
||||
|
||||
(function() {
|
||||
(( ) => {
|
||||
try {
|
||||
let status = vAPI.uBO !== true;
|
||||
if ( status === false && vAPI.bootstrap ) {
|
||||
|
@ -333,6 +333,10 @@ if ( selfieIsValid !== true ) {
|
||||
|
||||
// Final initialization steps after all needed assets are in memory.
|
||||
|
||||
// https://github.com/uBlockOrigin/uBlock-issues/issues/974
|
||||
// This can be used to defer filtering decision-making.
|
||||
µb.readyToFilter = true;
|
||||
|
||||
// Start network observers.
|
||||
µb.webRequest.start();
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user