I want to show a progress bar during an emscripten webassembly is running. But the progress bar is updatet AFTER the webassembly is finished. Is there a way to either interrupt webassembly (main thread) and then continue or force javascript (main thread) to render the GUI?
main.js
Module.cwrap('calc', 'undefined', [])();
calc.cpp
void calc() {
EM_ASM({ progressBar($0); }, value); // here the progress bar should be updated immedately
...
calc something
...
}
// but it's updated only here
I also tried it with
progressbar(val) {
setTimeout(function(){ updateBar(val); }, 0);
}
Unfortunately for me it's not possible to use a webworker in a seperate file. Thanks...
@schteppe: Thxs! For who have the same issue. I solved it with emscripten_async_call().
main.js
Module.cwrap('calc', 'undefined', [])();
calc.cpp
void calc() {
EM_ASM({ progressBar($0); }, value);
emscripten_async_call("calcfunction, NULL, msec");
}
void calcfunction() {
...
calc something
...
}