mirror of
https://github.com/Microsoft/vscode
synced 2024-09-14 06:08:12 +00:00
perf - warm up canvas in idle callback (#120916)
* perf - warm up canvas in idle callback * also warmup for sandbox
This commit is contained in:
parent
c82eb7d498
commit
5bf85d71d8
|
@ -46,6 +46,20 @@
|
|||
},
|
||||
beforeRequire: function () {
|
||||
performance.mark('code/willLoadWorkbenchMain');
|
||||
|
||||
// It looks like browsers only lazily enable
|
||||
// the <canvas> element when needed. Since we
|
||||
// leverage canvas elements in our code in many
|
||||
// locations, we try to help the browser to
|
||||
// initialize canvas when it is idle, right
|
||||
// before we wait for the scripts to be loaded.
|
||||
// @ts-ignore
|
||||
window.requestIdleCallback(() => {
|
||||
const canvas = document.createElement('canvas');
|
||||
const context = canvas.getContext('2d');
|
||||
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||
canvas.remove();
|
||||
}, { timeout: 50 });
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
|
@ -46,6 +46,20 @@
|
|||
},
|
||||
beforeRequire: function () {
|
||||
performance.mark('code/willLoadWorkbenchMain');
|
||||
|
||||
// It looks like browsers only lazily enable
|
||||
// the <canvas> element when needed. Since we
|
||||
// leverage canvas elements in our code in many
|
||||
// locations, we try to help the browser to
|
||||
// initialize canvas when it is idle, right
|
||||
// before we wait for the scripts to be loaded.
|
||||
// @ts-ignore
|
||||
window.requestIdleCallback(() => {
|
||||
const canvas = document.createElement('canvas');
|
||||
const context = canvas.getContext('2d');
|
||||
context.clearRect(0, 0, canvas.width, canvas.height);
|
||||
canvas.remove();
|
||||
}, { timeout: 50 });
|
||||
}
|
||||
}
|
||||
);
|
||||
|
|
Loading…
Reference in a new issue