Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weโ€™ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[PM-16719] [COMMUNITY] Debounce requestIdleCallback a single time every 100ms, as opposed to call requestIdleCallback on debounce method #12695

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -947,7 +947,9 @@ export class CollectAutofillContentService implements CollectAutofillContentServ
}

if (!this.mutationsQueue.length) {
requestIdleCallbackPolyfill(debounce(this.processMutations, 100), { timeout: 500 });
// # Switch the order of these two to process the list of mutations, within
// # an idle moment in the event loop, only once every 100 ms
debounce(this.processMutations, 100);
}
this.mutationsQueue.push(mutations);
};
Expand Down Expand Up @@ -982,7 +984,9 @@ export class CollectAutofillContentService implements CollectAutofillContentServ
const queueLength = this.mutationsQueue.length;

if (!this.domQueryService.pageContainsShadowDomElements()) {
this.checkPageContainsShadowDom();
// # Request idle callback here, checking if a page contains
// # shadowDOMs is a heavy operation and doesn't have to be done immediately.
requestIdleCallbackPolyfill(this.checkPageContainsShadowDom, { timeout: 500 });
}

for (let queueIndex = 0; queueIndex < queueLength; queueIndex++) {
Expand Down
Loading