Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Web] Add ability to use custom worker script to avoid CSP policy violations when 'worker-src' doesn't allow 'blob:' path #19708

Open
rdolgov opened this issue Feb 29, 2024 · 1 comment
Labels
feature request request for unsupported feature or enhancement platform:web issues related to ONNX Runtime web; typically submitted using template

Comments

@rdolgov
Copy link

rdolgov commented Feb 29, 2024

Describe the issue

When trying to user proxy mode or muti-threaded mode, for example setting ort flags to:

ort.wasm.proxy=true; ort.wasm.numThreads=4;

when hosted app has strict CSP policy and doesn't allow using 'blob:' schema for web workers (doesn't explicitly adds 'blob:' to 'worker-src' and 'script-src') the following error happens:

Refused to create a worker from 'blob:...because it violates the following Content Security Policy directive: "worker-src...

Ideally would be good to have some env settings to allow specify path to custom worker and provide some pre-bundled script that can be loaded directly from the hosted app (for example something similar to https://docs.sentry.io/platforms/javascript/session-replay/configuration/#using-a-custom-compression-worker)

To reproduce

Host onnx web runtime on site with script CSP policy that for example only specify the following directive:

"worker-src 'self'"

Urgency

As more site adds CSP policy, having this option would have wider / easier adoption of onnx web runtime, otherwise you either need to revert to slower in UI thread only mode, or prevent adoption altogether.

ONNX Runtime Installation

Built from Source

ONNX Runtime Version or Commit ID

1.17.0

Execution Provider

'wasm'/'cpu' (WebAssembly CPU)

@rdolgov rdolgov added the platform:web issues related to ONNX Runtime web; typically submitted using template label Feb 29, 2024
@fs-eire fs-eire added the feature request request for unsupported feature or enhancement label Feb 29, 2024
@rdolgov
Copy link
Author

rdolgov commented Mar 5, 2024

In case someone needs the same and okay to use custom build:
https://github.com/microsoft/onnxruntime/pull/19771/files

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature request request for unsupported feature or enhancement platform:web issues related to ONNX Runtime web; typically submitted using template
Projects
None yet
Development

No branches or pull requests

2 participants