Added workaround for Firefox performance bug

This commit is contained in:
saturn 2020-01-17 19:19:13 -06:00
parent 2ecd4edcb7
commit 36951432cf

View File

@ -166,20 +166,30 @@ function restoreScrollability() {
*/ */
function startConstantVigilance() { function startConstantVigilance() {
// console.log("startConstantVigilance"); // console.log("startConstantVigilance");
var observer = new MutationObserver((mutationsList, observer) => { var observer;
window.requestIdleCallback(() => { var starter = function() {
for (var mutation of mutationsList) {
killSticky(mutation.target);
}
});
});
console.log("Commencing vigilance for stickies!");
observer.observe(document.querySelector("html"), { observer.observe(document.querySelector("html"), {
attributes: true, attributes: true,
childList: true, childList: true,
subtree: true subtree: true
}); });
};
observer = new MutationObserver((mutationsList, observer) => {
// Workaround for Firefox performance bug. Firefox does not properly
// coalesce mutations into the mutationsList, instead calling the
// callback potentially thousands of times. Therefore we must
// disconnect the observer, wait for the main thread to become idle,
// and then restart it.
observer.disconnect();
window.requestIdleCallback(() => {
killSticky();
starter();
});
});
console.log("Commencing vigilance for stickies!");
starter();
} }
/*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/ /*++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/