diff --git a/mediapipe/web/graph_runner/graph_runner.ts b/mediapipe/web/graph_runner/graph_runner.ts index 17ad311f1..bf0337503 100644 --- a/mediapipe/web/graph_runner/graph_runner.ts +++ b/mediapipe/web/graph_runner/graph_runner.ts @@ -1253,23 +1253,24 @@ export async function createMediaPipeLib( assetLoaderScript?: string|null, glCanvas?: HTMLCanvasElement|OffscreenCanvas|null, fileLocator?: FileLocator): Promise { - const scripts = []; // Run wasm-loader script here if (wasmLoaderScript) { - scripts.push(wasmLoaderScript); - } - // Run asset-loader script here - if (assetLoaderScript) { - scripts.push(assetLoaderScript); - } - // Load scripts in parallel, browser will execute them in sequence. - if (scripts.length) { - await Promise.all(scripts.map(runScript)); + await runScript(wasmLoaderScript); } + if (!self.ModuleFactory) { throw new Error('ModuleFactory not set.'); } + // Run asset-loader script here; must be run after wasm-loader script if we + // are re-wrapping the existing MODULARIZE export. + if (assetLoaderScript) { + await runScript(assetLoaderScript); + if (!self.ModuleFactory) { + throw new Error('ModuleFactory not set.'); + } + } + // Until asset scripts work nicely with MODULARIZE, when we are given both // self.Module and a fileLocator, we manually merge them into self.Module and // use that. TODO: Remove this when asset scripts are fixed.