From ee6cef10e5fbbe729ce3d05190734f2f495a3075 Mon Sep 17 00:00:00 2001 From: Xiaohan-Tian <157918347+Xiaohan-Tian@users.noreply.github.com> Date: Fri, 29 May 2026 15:01:11 -0700 Subject: [PATCH] fix: load onnx runtime mjs from assets folder --- src/util/local-separator/runtime.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/util/local-separator/runtime.ts b/src/util/local-separator/runtime.ts index 497a282..8c37163 100644 --- a/src/util/local-separator/runtime.ts +++ b/src/util/local-separator/runtime.ts @@ -1,4 +1,5 @@ import * as ort from 'onnxruntime-web/webgpu'; +import ortWasmAsyncifyMjsUrl from 'onnxruntime-web/ort-wasm-simd-threaded.asyncify.mjs?url'; import ortWasmAsyncifyUrl from 'onnxruntime-web/ort-wasm-simd-threaded.asyncify.wasm?url'; import type { LocalRuntimeState, LocalRuntimeSupport, LocalSeparatorModelConfig } from './types'; @@ -43,10 +44,15 @@ export class LocalOrtRuntimeManager { } if (!LocalOrtRuntimeManager.wasmPathsConfigured) { + // Pin both loader and wasm binary to Vite-emitted same-origin assets so + // static hosting never falls back to package-relative or third-party URLs. ort.env.wasm.wasmPaths = { + mjs: ortWasmAsyncifyMjsUrl, wasm: ortWasmAsyncifyUrl, }; + ort.env.wasm.numThreads = 1; log('Configured ONNX Runtime wasm paths.', ort.env.wasm.wasmPaths); + log('Configured ONNX Runtime wasm threading.', { numThreads: ort.env.wasm.numThreads }); LocalOrtRuntimeManager.wasmPathsConfigured = true; }