From a87dd5ddec2e9e6b53e8eb9883277ec582f1bc0a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Fri, 21 Jul 2023 10:53:37 +0000 Subject: [PATCH] fix: response to experimental rIC support on Safari removed due to Google Login bug? --- packages/frontend/src/scripts/idle-render.ts | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/packages/frontend/src/scripts/idle-render.ts b/packages/frontend/src/scripts/idle-render.ts index ccce8b02bf..781b624cdf 100644 --- a/packages/frontend/src/scripts/idle-render.ts +++ b/packages/frontend/src/scripts/idle-render.ts @@ -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); // + }, + }); + }); + return timeoutId; +}; +const cancelIdleCallback: typeof globalThis.cancelIdleCallback = globalThis.cancelIdleCallback ?? (timeoutId) => { + clearTimeout(timeoutId); +}; + class IdlingRenderScheduler { #renderers: Set; #rafId: number;