Skip to content

Commit 8e17e47

Browse files
1 parent ecb34b0 commit 8e17e47

1 file changed

Lines changed: 25 additions & 0 deletions

File tree

Source/Workbench/Electron/Workbench.ts

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,31 @@ console.log(
6363
);
6464

6565
// Stubs for APIs that VS Code uses but don't exist in Tauri's WKWebView.
66+
67+
// requestIdleCallback/cancelIdleCallback: WKWebView doesn't support these.
68+
// VS Code uses them in workbench.js for deferred canvas cleanup and other
69+
// non-critical tasks. Without this polyfill, the workbench crashes on load.
70+
if (typeof window.requestIdleCallback !== "function") {
71+
(window as any).requestIdleCallback = (
72+
Callback: IdleRequestCallback,
73+
Options?: IdleRequestOptions,
74+
): number => {
75+
const Timeout = Options?.timeout ?? 1;
76+
const Start = Date.now();
77+
return setTimeout(() => {
78+
Callback({
79+
didTimeout: Timeout <= 0,
80+
timeRemaining: () => Math.max(0, Timeout - (Date.now() - Start)),
81+
});
82+
}, Timeout) as unknown as number;
83+
};
84+
}
85+
if (typeof window.cancelIdleCallback !== "function") {
86+
(window as any).cancelIdleCallback = (Id: number): void => {
87+
clearTimeout(Id);
88+
};
89+
}
90+
6691
// queryLocalFonts: VS Code's fonts.js calls mainWindow.queryLocalFonts() to
6792
// enumerate system fonts. Returns empty array = VS Code falls back to defaults.
6893
if (typeof (window as any).queryLocalFonts !== "function") {

0 commit comments

Comments
 (0)