Skip to content
This repository has been archived by the owner on Mar 19, 2024. It is now read-only.

Run WASM in web worker #1346

Open
Sejmou opened this issue Aug 29, 2023 · 1 comment
Open

Run WASM in web worker #1346

Sejmou opened this issue Aug 29, 2023 · 1 comment

Comments

@Sejmou
Copy link

Sejmou commented Aug 29, 2023

Hello,

I was wondering: should it be possible to run the web assembly version of fasttext in a web worker?

I tried using it inside a web worker myself, but got errors like this (logs copied from the developer console of my machine):

fasttext_wasm.js:2594 Compiled code throwing an exception, 5289056,30532,27
___cxa_throw @ fasttext_wasm.js:2594
$dynCall_viii @ fasttext_wasm.wasm:0xe5378
(anonymous) @ fasttext_wasm.js:2200
invoke_viii @ fasttext_wasm.js:9247
$func2482 @ fasttext_wasm.wasm:0x661dc
$dynCall_vii @ fasttext_wasm.wasm:0xe536a
(anonymous) @ fasttext_wasm.js:2200
invoke_vii @ fasttext_wasm.js:9269
$func4119 @ fasttext_wasm.wasm:0xa821b
$dynCall_viii @ fasttext_wasm.wasm:0xe5378
(anonymous) @ fasttext_wasm.js:2200
dynCall_viii_586 @ VM62:4
FastText$loadModel @ VM237:9
(anonymous) @ fasttext.js:79
Promise.then (async)
(anonymous) @ fasttext.js:78
loadModel @ fasttext.js:68
initModel @ index.ts:53
await in initModel (async)
predict @ index.ts:106
callback @ comlink.ts:329
Show 1 more frame
Show less
fasttext_wasm.js:2503 can_catch on 5289056
fasttext_wasm.js:2631 Resuming exception 5289056,5289056
fasttext_wasm.js:2503 can_catch on 5289056
fasttext_wasm.js:2631 

For reference: I built the wasm module as outlined here under the 'Fasttext WebAssembly integration' heading.

The main reason I even considered running fasttext in a web worker is that while I managed to load and run inference on a model on the main thread, the loadModel() function blocks (and hence freezes the UI) for around 2 to 3 seconds. I would really appreciate any workaround that would solve this issue.

Best regards,
Samo

@yunsii
Copy link

yunsii commented Jan 6, 2024

Maybe my project https://github.com/yunsii/fasttext.wasm.js will help, it works in background script (worker) of browser extension.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants