Skip to content

Commit c942060

Browse files
committed
[js/web] Use embedded WASM module in Blob URL workers when wasmBinary is provided
When running inside a Blob URL Web Worker with wasmBinary provided and numThreads=1, the isSameOrigin check can fail (blob: URLs have opaque origins in some contexts), causing a fallback to dynamic import of ort-wasm-simd-threaded.mjs which doesn't exist in that context. Since wasmBinary is already provided and no worker spawning is needed (single-threaded), the embedded module can be used directly without requiring a same-origin check. This extends the existing pattern from the !scriptSrc case (line 268) to also apply when scriptSrc is available but fails same-origin checks. Fixes #27317
1 parent a70ac2f commit c942060

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

js/web/lib/wasm/wasm-utils-import.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -272,7 +272,9 @@ export const importWasmModule = async (
272272
}
273273
} else {
274274
// if the script source is available, we can check if it is from the same origin.
275-
useEmbeddedModule = isSameOrigin(scriptSrc);
275+
// Also use the embedded module when wasmBinary is provided and single-threaded (eg. Blob URL workers
276+
// where isSameOrigin fails but no file resolution or worker spawning is needed).
277+
useEmbeddedModule = isSameOrigin(scriptSrc) || (isWasmOverridden && !isMultiThreaded);
276278
}
277279
}
278280
if (useEmbeddedModule) {

0 commit comments

Comments
 (0)