-
Notifications
You must be signed in to change notification settings - Fork 3.1k
Commit
This commit will force-reload active tabs at launch for environments not supporting suspend network request listeners, or configured to not suspend network request listeners.
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1138,15 +1138,29 @@ const webRequest = { | |
vAPI.net = new vAPI.Net(); | ||
vAPI.net.suspend(); | ||
|
||
return ( ) => { | ||
return async ( ) => { | ||
vAPI.net.setSuspendableListener(onBeforeRequest); | ||
vAPI.net.addListener( | ||
'onHeadersReceived', | ||
onHeadersReceived, | ||
{ urls: [ 'http://*/*', 'https://*/*' ] }, | ||
[ 'blocking', 'responseHeaders' ] | ||
); | ||
vAPI.net.unsuspend(true); | ||
vAPI.net.unsuspend({ force: true }); | ||
This comment has been minimized.
Sorry, something went wrong.
This comment has been minimized.
Sorry, something went wrong.
gorhill
Author
Owner
|
||
// Mitigation: force-reload active tabs for environments not | ||
// supporting suspended network request listeners. | ||
if ( | ||
vAPI.net.canSuspend() !== true || | ||
µb.hiddenSettings.suspendTabsUntilReady === 'no' | ||
) { | ||
const tabs = await vAPI.tabs.query({ | ||
active: true, | ||
windowType: 'normal', | ||
}); | ||
for ( const tab of tabs ) { | ||
vAPI.tabs.reload(tab.id); | ||
} | ||
} | ||
}; | ||
})(), | ||
|
||
|
4 comments
on commit a0a9497
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gorhill I think 80b758e broke suspending on Chrome. After this commit suspend()
is never called with true
to be forced
canSuspend()
returnsfalse
by default and is not overridden in Chromevapi-background-ext.js
suspendDepth
uBlock/platform/common/vapi-background.js
Lines 1223 to 1226 in 57e660e
suspend(force = false) { if ( this.canSuspend() || force ) { this.suspendDepth += 1; } suspendOneRequest
uBlock/platform/common/vapi-background.js
Lines 1148 to 1153 in 57e660e
browser.webRequest.onBeforeRequest.addListener( details => { this.normalizeDetails(details); if ( this.suspendDepth !== 0 && details.tabId >= 0 ) { return this.suspendOneRequest(details); }
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're right, so this could explain your earlier observations.
Not sure setting suspendTabsUntilReady
to yes
is still worth it though, I think inactive tabs are no longer loaded by default in Chromium -- maybe this whole Chromium-specific code should go now and keep only the reloading of active tabs.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I find out that https://www.google.com/search?q=home&client=firefox-b-d&tbm=isch
is a good page to test this. It clearly reloads on every browser restart. I think it may be annoying for some people. Allowing to turn reloading off can be a good idea.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am thinking a new checkbox in "Filter lists" pane for this might be the solution, something like:
- Do not wait for filter lists to be fully loaded at launch
or whatever better formulation.
So un-chcked would mean current behavior, checked would mean unsuspended and not reloading active tab.
@gorhill where you get this
force
from? Should beall
?