Emscripten main loop