Skip to content

[js/web] Use embedded WASM module in Blob URL workers when wasmBinary is provided#27318

Open
0-don wants to merge 1 commit intomicrosoft:mainfrom
0-don:fix/blob-url-worker-embedded-module
Open

[js/web] Use embedded WASM module in Blob URL workers when wasmBinary is provided#27318
0-don wants to merge 1 commit intomicrosoft:mainfrom
0-don:fix/blob-url-worker-embedded-module

Conversation

@0-don
Copy link

@0-don 0-don commented Feb 11, 2026

Fixes #27317

When running inside a Blob URL Web Worker with wasmBinary provided and numThreads=1, isSameOrigin(scriptSrc) can fail because blob: URLs have opaque origins. This causes a fallback to dynamic import('./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 Emscripten module can be used directly — no URL resolution or same-origin check is needed.

Change: One line in wasm-utils-import.ts line 275:

// Before:
useEmbeddedModule = isSameOrigin(scriptSrc);

// After:
useEmbeddedModule = isSameOrigin(scriptSrc) || (isWasmOverridden && !isMultiThreaded);

This extends the existing pattern from the !scriptSrc case (line 268) to also apply when scriptSrc is available but fails same-origin checks. The condition (wasmBinary provided + single-threaded) guarantees no file resolution or worker spawning is needed.

… 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 microsoft#27317
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

onnxruntime-web: Bundle variant fails in Blob URL Web Workers

1 participant