1
0
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:
Raymond Hill 2020-04-04 11:34:43 -04:00
parent 1295e25961
commit df08b12d48
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
4 changed files with 10 additions and 1 deletions

View File

@ -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,

View File

@ -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;

View File

@ -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 ) {

View File

@ -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();