WASM/SimConnect and Asynchronous execution

I regard myself a novice in C++ development, so please excuse my lack of experience. I started developing MSFS WASM/SimConnect module by looking at the included SDK examples. I developed a WASM/SimConnect module which, at a press of a button, reads in and parses a bunch of rather large XML files. The whole operation takes about 14 seconds. During this time, the sim freezes, and then unfreezes when the task is done.

I was under impression that a WASM module is asynchronous: it runs within its own loop and sends/receives events to the server (sim) which doesn’t care what the module is doing. Why is it then that the sim freezes? Is there anything I can do about this? I tried threading but WASM is not supporting threading…

WASM code runs on the main thread. Multithreading was requested some time ago but is not available yet. About WASM and threads

SimConnect is available in-process in the sim (via wasm) or out-of-process (another EXE on the computer). SimConnect calls are asynchronous either way. When you get a callback it will be executed on the main thread at the next available opportunity.

Some options you might have:

  • Use JS fetch API to retrieve data, which is asynchronous.
  • Use WASM network API, which is probably asynchronous.
  • Use WASM I/O on the main thread, but read the data over a range of frames instead of all on one frame. This probably reduces the delay but ultimately I/O on the main thread is unacceptable due to latency.
  • Use an external program

I don’t think any async I/O is available in WASM but I would be very happy to be corrected on that point.