There isn't a way to make the JS filesystem operations async currently, but there is some experimentation here:
https://github.com/emscripten-core/emscripten/pull/9151 You can proxy calls to the main thread to do JS FS operations there, for example using proxied EM_ASM https://emscripten.org/docs/api_reference/emscripten.h.html#c.MAIN_THREAD_EM_ASM That has some risks, but as mentioned in the issue you linked PROXY_TO_PTHREAD can avoid them. In general I'd recommend using that flag whenever possible. On Thu, Jan 2, 2020 at 3:27 PM Dan C <[email protected]> wrote: > Hello everyone,. > > I'm calling FS.makedev and FS.registerDevice on the main thread to create > a file, which is shared by all the threads of my multi-threaded > application. I need to use XMLHttpRequest in the read function of this > device. Since the read function is synchronous, the XMLHttpRequest call > would also need to be synchronous. However, since synchronous > XMLHttpRequest is not allowed in the main thread, the browser will throw an > error. > > Is there any way that I can make the filesystem functions passed to > FS.registerDevice asynchronous so that I can call XMLHttpRequest > asynchronously? Alternatively, is there any way to have the filesystem > access occur in a different thread, so synchronous XMLHttpRequest is > available? > > Running the wasm module from a worker is not an option right now due to this > issue <https://github.com/emscripten-core/emscripten/issues/8325>. > > > Dan > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/0d53851a-22d9-44c6-bf6c-bf1255620d9b%40googlegroups.com > <https://groups.google.com/d/msgid/emscripten-discuss/0d53851a-22d9-44c6-bf6c-bf1255620d9b%40googlegroups.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CAEX4NpSmKzoOTW62aNASqW3UCN_aVuGVs4sQFQsmCOAnvb6iMw%40mail.gmail.com.
