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

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

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 fetch before passing it to ort.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://inspect and 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)

Most upvoted comments

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 = 1

Update: 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.