summaryrefslogtreecommitdiffstats
path: root/platform/common/vapi-client.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 05:50:19 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-17 05:50:19 +0000
commitb6a97bcbb33b667a7ee4acb2eb8e482333e95a1b (patch)
tree89830d7d7c2cd02e552447883d02800d56cdf323 /platform/common/vapi-client.js
parentReleasing progress-linux version 1.55.0+dfsg-1~progress7.99u1. (diff)
downloadublock-origin-b6a97bcbb33b667a7ee4acb2eb8e482333e95a1b.tar.xz
ublock-origin-b6a97bcbb33b667a7ee4acb2eb8e482333e95a1b.zip
Merging upstream version 1.57.0+dfsg.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--platform/common/vapi-client.js29
1 files changed, 13 insertions, 16 deletions
diff --git a/platform/common/vapi-client.js b/platform/common/vapi-client.js
index 9375e88..a6d46c6 100644
--- a/platform/common/vapi-client.js
+++ b/platform/common/vapi-client.js
@@ -22,10 +22,6 @@
// For non-background page
-/* globals browser */
-
-'use strict';
-
/******************************************************************************/
// https://github.com/chrisaljoudi/uBlock/issues/456
@@ -85,6 +81,7 @@ vAPI.messaging = {
portTimerDelay: 10000,
msgIdGenerator: 1,
pending: new Map(),
+ waitStartTime: 0,
shuttingDown: false,
shutdown: function() {
@@ -115,16 +112,11 @@ vAPI.messaging = {
// revisited to isolate the picker dialog DOM from the page DOM.
messageListener: function(details) {
if ( typeof details !== 'object' || details === null ) { return; }
-
- // Response to specific message previously sent
- if ( details.msgId !== undefined ) {
- const resolver = this.pending.get(details.msgId);
- if ( resolver !== undefined ) {
- this.pending.delete(details.msgId);
- resolver(details.msg);
- return;
- }
- }
+ if ( details.msgId === undefined ) { return; }
+ const resolver = this.pending.get(details.msgId);
+ if ( resolver === undefined ) { return; }
+ this.pending.delete(details.msgId);
+ resolver(details.msg);
},
messageListenerBound: null,
@@ -203,13 +195,18 @@ vAPI.messaging = {
// the main process is no longer reachable: memory leaks and bad
// performance become a risk -- especially for long-lived, dynamic
// pages. Guard against this.
- if ( this.pending.size > 50 ) {
- vAPI.shutdown.exec();
+ if ( this.pending.size > 64 ) {
+ if ( (Date.now() - this.waitStartTime) > 60000 ) {
+ vAPI.shutdown.exec();
+ }
}
const port = this.getPort();
if ( port === null ) {
return Promise.resolve();
}
+ if ( this.pending.size === 0 ) {
+ this.waitStartTime = Date.now();
+ }
const msgId = this.msgIdGenerator++;
const promise = new Promise(resolve => {
this.pending.set(msgId, resolve);