Skip to content

Commit ce9ebce

Browse files
authored
Add note on emscripten_set_main_loop with Wasm EH (#16871)
When `simulate_infinite_loop` is true, `emscripten_set_main_loop` does not work with the new Wasm EH because throwing a JS exception will cause destructors in the Wasm stack frames to run. This can be fixed in future by either by fixing the LLVM compilation by adding an additional `catch` to every `catch_all` so that we can rethrow JS exceptions of this kind, or possibly using the new stack switching proposal. This PR adds a note that this features currently doesn't work with Wasm EH.
1 parent 88d870b commit ce9ebce

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

site/source/docs/api_reference/emscripten.h.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -361,6 +361,8 @@ Functions
361361
362362
.. note:: Calling this function overrides the effect of any previous calls to :c:func:`emscripten_set_main_loop_timing` in the calling thread by applying the timing mode specified by the parameter ``fps``. To specify a different timing mode for the current thread, call the function :c:func:`emscripten_set_main_loop_timing` after setting up the main loop.
363363
364+
.. note:: Currently, using `the new Wasm exception handling <https://emscripten.org/docs/porting/exceptions.html#webassembly-exception-handling-proposal>`_ and ``simulate_infinite_loop`` == true at the same time does not work yet in C++ projects that have objects with destructors on the stack at the time of the call.
365+
364366
:param em_callback_func func: C function to set as main event loop for the calling thread.
365367
:param int fps: Number of frames per second that the JavaScript will call the function. Setting ``int <=0`` (recommended) uses the browser’s ``requestAnimationFrame`` mechanism to call the function.
366368
:param int simulate_infinite_loop: If true, this function will throw an exception in order to stop execution of the caller.

0 commit comments

Comments
 (0)