onnxruntime icon indicating copy to clipboard operation
onnxruntime copied to clipboard

[Web] warning about the use of eval in Vite

Open jclaessens97 opened this issue 1 year ago • 4 comments

Describe the issue

Whenever I build with Vite I get the following warning message:

image

To reproduce

  1. Install onnxruntime-web
  2. Build application with Vite

Urgency

No response

ONNX Runtime Installation

Released Package

ONNX Runtime Version or Commit ID

1.19.2

Execution Provider

'webgl' (WebGL)

jclaessens97 avatar Sep 19 '24 14:09 jclaessens97

The only eval is introduced by dependency protobufjs: https://github.com/protobufjs/protobuf.js/blob/master/lib/inquire/index.js#L12

fs-eire avatar Sep 19 '24 18:09 fs-eire

We still need protobufjs if using WebGL.

If using CPU only, you can import onnxruntime-web/wasm If using WebGPU, you can import onnxruntime-web/webgpu

They both do not depend on protobufjs and there should be no eval() in the corresponding bundles.

fs-eire avatar Sep 19 '24 22:09 fs-eire

I tried using wasm import before, but then I get a related issue.

jclaessens97 avatar Sep 20 '24 11:09 jclaessens97

This issue has been automatically marked as stale due to inactivity and will be closed in 30 days if no further activity occurs. If further support is needed, please provide an update and/or more details.

github-actions[bot] avatar Oct 20 '24 15:10 github-actions[bot]

Any update?

jclaessens97 avatar Oct 21 '24 10:10 jclaessens97

The "use of eval" warning will exist for a while until WebGL backend is eventually go out of lifetime and be replaced by WebGPU.

The specific code that uses "eval" is from protobuf.js to ensure the call to require() is not preprocessed by bundlers. Technically it does not get called in a web environment so it should be pretty much fine.

I will close this issue because there is no further action item. Will revisit the other issue when I get some time.

fs-eire avatar Oct 22 '24 04:10 fs-eire

If people are having problems importing /webgpu or /wasm in a chrome plugin, it can be solved with webpack. Please see my solution in this related issue.

michaelmunie avatar Jul 25 '25 17:07 michaelmunie