-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Closed
Labels
platform:webissues related to ONNX Runtime web; typically submitted using templateissues related to ONNX Runtime web; typically submitted using templatestaleissues that have not been addressed in a while; categorized by a botissues that have not been addressed in a while; categorized by a bot
Description
Describe the issue
I use the onnxruntime-node in the electron app with web worker. When I first create the web worker, it's OK. But, when I create the web worker again, the app will breakdown.
To reproduce
A vue component
<script setup>
import {ref} from "vue";
const num = ref(0)
let worker = undefined
function startWorker() {
if (worker===undefined) {
worker = new Worker('./worker.js')
worker.onmessage = function(event){
num.value = event.data;
};
}
}
function terminateWorker () {
if (worker !== undefined) {
worker.terminate()
}
worker = undefined
}
</script>
<template>
<v-btn @click="startWorker">
start worker
</v-btn>
<v-btn @click="terminateWorker">
end worker
</v-btn>
<div>
{{num}}
</div>
</template>
<style scoped>
</style>The worker.js
const ort = require("onnxruntime-node");
const fs = require("fs");
var i = 0;
function timedCount() {
i = i + 1;
postMessage(i);
setTimeout("timedCount()",500);
}
timedCount();
ort.InferenceSession.create(fs.readFileSync("someModel.onnx"), { executionProviders: ['cuda', 'wasm', 'cpu'])If I delete the last line, I can restart the worker for many times. If I add the last line, if I restart the web worker, the app will crash. I suspect that is because the inferenceSession may not be closed properly when the worker is terminated. However, I can not find any api to close the inferenceSession. Another finding is that the memory is not released after the web worker is terminated.
Urgency
No response
ONNX Runtime Installation
Released Package
ONNX Runtime Version or Commit ID
"onnxruntime-node": "^1.12.1",
Execution Provider
Other / Unknown
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
platform:webissues related to ONNX Runtime web; typically submitted using templateissues related to ONNX Runtime web; typically submitted using templatestaleissues that have not been addressed in a while; categorized by a botissues that have not been addressed in a while; categorized by a bot