onnxruntime: [web] `ort.InferenceSession.create` silently hangs/fails on iOS/iPad browsers if COEP/COOP headers are set
Describe the bug COEP/COOP headers must be set to cross-origin-isolate the page, which allows use of Wasm threads. If these headers are set, then the model doesn’t load on iOS/iPad browsers. It simply “hangs” and never finishes initialization.
Urgency The app is in production for thousands of users per day, but I’m not in a position to hurry you along 😅
System information
- ONNX Runtime version: https://cdn.jsdelivr.net/npm/onnxruntime-web@1.11.0/dist/ort.js
This bug only occurs on iOS and iPad browsers. I’ve tested the latest version of Chrome (v102) and Safari on iOS and iPad.
The bug does not occur on desktop browsers, including Safari and Mac. Every non-iOS/iPad browser that I’ve tested works fine.
To Reproduce
- Visit this minimal reproduction and try both links that you see: https://coop-coep-onnx-ios-1.joe64.repl.co/ The
/with-headerspage includes the COOP/COEP headers (which causes it to fail), and the/without-headerspage doesn’t have the headers (and it works normally/correctly) - Here’s the code for those pages: https://replit.com/@joe64/coop-coep-onnx-ios-1#index.js
Note that I’ve had to use Replit instead of a service like JSBin because JSBin doesn’t allow you to set headers.
Additional context
- Note that, as you can see in the front-end code, I’m pre-downloading the file with
fetchbefore passing it toort.InferenceSession.create. This doesn’t affect loading at all. I’m only doing this to ensure that the problem wasn’t to do with model downloading. - For convenience, here’s a direct link to the model being loaded in the above-linked minimal reproduction: https://huggingface.co/rocca/informative-drawings-line-art-onnx/resolve/main/model.onnx
- The only way I was able to debug Chrome iOS was to visit
chrome://inspectand start the logger. I didn’t observe any error messages, but it could be that error messages aren’t being correctly shown on that page, so perhaps it’s failing with an error that I’m unable to see.
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 15 (9 by maintainers)
I’m also experiencing this issue with multi-threaded + COOP headers with browsers on IOS devices.
I tried this change so in my case I’m not able to work-around this with
ort.env.wasm.numThreads = 1Update: I had to remove COOP headers to make it work again on IOS devices, my model is pretty large, though, 22MB.
I made a change to optimize the feature detection. however this need to be validated before merge.