calling mainloop from JS never returns

14 views
Skip to first unread message

nevo natan

unread,
Jul 8, 2019, 11:13:32 AM7/8/19
to emscripten-discuss
I have a straight forward CPP flow as follows:

  emscripten_set_main_loop_arg(one_iter,this, 0, 1);
    while (1) {
     one_iter(this);
     SDL_Delay(time_to_next_frame());
   }


in my JS it looks like this:
function init() {
myObj = new Module.myObj();
myObj.myAction() ;
}


but myObj works great.
but the next js line never gets executed.


Any ideas how I can add myAction functionality to the mainloop?

Help much appreciated!

Floh

unread,
Jul 10, 2019, 4:40:44 AM7/10/19
to emscripten-discuss
I don't quite understand what you want to achieve, but the emscripten_set_main_loop_arg() function will not return because its "simulate_infinite_loop" argument is true (or rather 1), this is explained here:


The infinite while-loop in the next line will block the browser-tab though and after a couple of second the browser will kill your application. The emscripten documentation has more information on that behaviour here: https://emscripten.org/docs/porting/emscripten-runtime-environment.html#emscripten-runtime-environment

I don't understand how the JS snippet is related to this though, too little information :)

-Floh.
Reply all
Reply to author
Forward
0 new messages