bring back promise cache

just in case loadWorklets is called more than once
This commit is contained in:
Felix Roos 2024-05-31 10:36:49 +02:00
parent ff85f2307f
commit 07f58c023f

View File

@ -41,8 +41,12 @@ export const getAudioContext = () => {
return audioContext;
};
async function loadWorklets() {
return await getAudioContext().audioWorklet.addModule(workletsUrl);
let workletsLoading;
function loadWorklets() {
if (!workletsLoading) {
workletsLoading = getAudioContext().audioWorklet.addModule(workletsUrl);
}
return workletsLoading;
}
// this function should be called on first user interaction (to avoid console warning)