0
0

fix: response to experimental rIC support on Safari removed due to Google Login bug?

This commit is contained in:
Acid Chicken (硫酸鶏) 2023-07-21 10:53:37 +00:00 committed by GitHub
parent 561683f097
commit a87dd5ddec
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1,3 +1,20 @@
const requestIdleCallback: typeof globalThis.requestIdleCallback = globalThis.requestIdleCallback ?? (callback) => {
const start = performance.now();
const timeoutId = setTimeout(() => {
callback({
didTimeout: false, // polyfill でタイムアウト発火することはない
timeRemaining() {
const diff = performance.now() - start;
return Math.max(0, 50 - diff); // <https://www.w3.org/TR/requestidlecallback/#idle-periods>
},
});
});
return timeoutId;
};
const cancelIdleCallback: typeof globalThis.cancelIdleCallback = globalThis.cancelIdleCallback ?? (timeoutId) => {
clearTimeout(timeoutId);
};
class IdlingRenderScheduler {
#renderers: Set<FrameRequestCallback>;
#rafId: number;