perf - warm up canvas in idle callback (#120916)

* perf - warm up canvas in idle callback

* also warmup for sandbox
This commit is contained in:
Benjamin Pasero 2021-04-09 12:15:03 +02:00 committed by GitHub
parent c82eb7d498
commit 5bf85d71d8
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 28 additions and 0 deletions

View file

@ -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 });
}
}
);

View file

@ -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 });
}
}
);