Skip to content

fix: WASM-only ONNX Runtime bundle for the browser demo (WebKit memory) - #31

Open
El1as42 wants to merge 2 commits into
mainfrom
fix/onnx-demo-ort-1.20.1
Open

El1as42 wants to merge 2 commits into
mainfrom
fix/onnx-demo-ort-1.20.1

Conversation

@El1as42

@El1as42 El1as42 commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • The browser demo now loads ONNX Runtime Web through the WASM-only bundle, ort.wasm.min.js 1.20.1 (was ort.min.js 1.22.0). The version appears in two places that must agree: the script URL in mkdocs.yml and wasmPaths in docs/javascripts/onnx_demo.js. Both have a comment explaining the choice.
  • Why: from 1.21.0 on, ort.min.js loads the JSEP build ort-wasm-simd-threaded.jsep.wasm, even when only the CPU wasm backend is used. In WebKit, the Safari engine, that build needs 5–7 GB even for 60 s of audio. With 1.22.0, a 10-minute file reached 12 GB, and one run crashed the page. ort.wasm.min.js loads the plain ort-wasm-simd-threaded.wasm in every release, so a later version bump can't bring the problem back.
  • Why 1.20.1 and not the latest (1.30.0): with the WASM-only bundle, both are fine in WebKit. But 1.20.1's WASM file is smaller (11 MB vs 14 MB), and 1.20.1 matches Python ONNX Runtime box for box, while 1.30.0 differs by two boxes out of 370 in every browser.
  • This is the same problem as [Web] Severe CPU and memory issues in Safari/WebKit 26 with JSEP mode microsoft/onnxruntime#26827, which a stale-bot closed without a fix. An upstream follow-up is linked below.

Which WASM build causes it

WebKit 18.2 (Playwright's Ubuntu 20.04 build). Standalone repro page (model plus 60 s of synthetic audio, executionProviders: ['wasm']), peak RSS:

Release + bundle WASM loaded Peak 5 s after
1.30.0 ort.min.js .jsep.wasm 5.7 GB 6.0 GB
1.30.0 ort.wasm.min.js .wasm 0.96 GB 0.91 GB
1.20.1 ort.min.js .wasm 0.92 GB 0.88 GB

Chromium 156 and Firefox 157 use 0.6–0.7 GB with either build. In the demo itself, every ort.min.js release from 1.21.0 to 1.30.0 used 4.8–7.6 GB on a 60 s file. Turning off the proxy worker made no difference.

Results with this branch

The built page in each browser on a 600 s file (an 11 min input, cut to 600 s by the demo), 32 kHz mono, page defaults conf 0.15 and phrase gap 0.05. All three load onnxruntime-web@1.20.1/dist/ort-wasm-simd-threaded.wasm:

Engine Boxes vs Python ONNX Runtime Mean IoU Inference Largest process
WebKit 18.2 370/370 0.998 53 s 1.7 GB
Chromium 156 370/370 0.998 48 s 1.2 GB
Firefox 157 370/370 0.998 45 s 1.3 GB

For comparison, the same page with 1.30.0 ort.wasm.min.js: 369 boxes in every engine (368 matched), 1.8 GB in WebKit.

Test plan

  • mkdocs build: the built page and onnx_demo.js only reference onnxruntime-web@1.20.1, and the script is ort.wasm.min.js
  • 600 s in headless WebKit, Chromium and Firefox: each loads the plain WASM build, 370/370 boxes against Python, memory as above
  • Real Safari on macOS / iOS. Not available on Linux; the WebKit runs are the closest substitute.

🤖 Generated with Claude Code

El1as42 and others added 2 commits October 21, 2026 15:23
Every onnxruntime-web release from 1.21.0 (checked up to 1.30.0) makes
WebKit, the Safari engine, use 4.8-7.6 GB on a 60 s file; with 1.22.0 a
10 minute file reached 12 GB and once crashed the page. 1.20.1 stays at
about 1 GB on 60 s and 1.8 GB on 600 s, the same as Chromium and Firefox,
and is not slower there. All three engines give 370/370 boxes against
Python ONNX Runtime on a 600 s file.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
The WebKit memory problem comes from the JSEP wasm, not from the release:
from 1.21.0 on, ort.min.js loads ort-wasm-simd-threaded.jsep.wasm even
for the CPU backend. ort.wasm.min.js loads the plain build in every
release (1.30.0: 1.2 GB in WebKit on 60 s instead of 5.6 GB), so a later
version bump cannot bring the problem back.

Stays on 1.20.1: its wasm is the smallest (11 MB; 1.30.0: 14 MB) and it
matches Python ONNX Runtime box for box (370/370 on 600 s in WebKit,
Chromium and Firefox), where 1.30.0 differs by two boxes.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@El1as42 El1as42 changed the title fix: pin ONNX Runtime Web 1.20.1 for the browser demo (WebKit memory) fix: WASM-only ONNX Runtime bundle for the browser demo (WebKit memory) Oct 21, 2026

This branch has not been deployed

No deployments
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.

1 participant