onnxruntime: [Web] ort-wasm-simd.wasm can't be loaded in Electron renderer (using webpack)
Describe the issue
I‘m building a electron app, the ort.js is loaded using script tag, but the wasm file is not loaded in webpack-dev-server
electron packed into an App won’t load either.
<head>
<base href="../../"> <!-- without this line, the issue still remains -->
<title>my app</title>
<script type="text/javascript" src="apps/videoAnalyzer/js/ort.js"></script>
</head>
i’m sure i have copyed .wasm file near the ort.js file

the path is incorrect http://ort-wasm-simd.wasm
ort-web.min.js?e269:6 GET http://ort-wasm-simd.wasm/ net::ERR_ABORTED 502 (Bad Gateway)

after some testing i guess the problem is in the “ort-wasm.js” file, but it’s been minified so i can’t do further test; or maybe it is because Electron’s issue
any help would be appreciated
To reproduce
electron app, using webpack boundle and set target to “electron-renderer” test electron version: 22.0.0 and 16.0.6 both version won’t work properly
Urgency
No response
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
1.12.0
Execution Provider
WASM
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 3
- Comments: 17 (4 by maintainers)
if you’re already using onnxruntime-web, a tricky workaround would be:
copy wasm like this (electron builder):
will be placed to and load from:
release/linux-unpacked/resources/ort-wasm-simd-threaded.wasm@fs-eire thanks for your reply that solve the problem of loading wasm file! but the file finding related function is still not working, now i’m stuck at
TypeError: Worker is not a constructorwhich means when importing the working.js file, it can’t find the js filecaused by this function in ort-wasm-threaded.js
function ma(a){return w.locateFile?w.locateFile(a,E):E+a}var na,F,G,fs,H,J;i guess the
locateFile()function is implemented without testing in Electron environmenti’m using electron-builder, with no hack! here are the versions i use:
in production, you have to build onnx-runtime binding for differient platforms, darwin, win64, win32 etc.
@FangliangBai 这也回答了你的问题