1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-07-18 10:41:26 +02:00

Do not exceed rate-limited calls to handlerBehaviorChanged()

Related issue:
https://github.com/uBlockOrigin/uBlock-issues/issues/3063

To prevent spurious performance warnings by chromium-based browsers.
This commit is contained in:
Raymond Hill 2024-01-11 13:25:19 -05:00
parent ba3a8d58a7
commit 63fe18a761
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2

View File

@ -69,7 +69,19 @@ export function filteringBehaviorChanged(details = {}) {
}
filteringBehaviorChanged.throttle = vAPI.defer.create(( ) => {
const { history, max } = filteringBehaviorChanged;
const now = (Date.now() / 1000) | 0;
if ( history.length >= max ) {
if ( (now - history[0]) <= (10 * 60) ) { return; }
history.shift();
}
history.push(now);
vAPI.net.handlerBehaviorChanged();
});
filteringBehaviorChanged.history = [];
filteringBehaviorChanged.max = Math.min(
browser.webRequest.MAX_HANDLER_BEHAVIOR_CHANGED_CALLS_PER_10_MINUTES - 1,
19
);
/******************************************************************************/