Compile to WASM
I am trying to port Mapbox GL Native (https://github.com/mapbox/mapbox-gl-native) to WASM and final piece is getting libuv to compile under emscripten/wasm.
I am able to compile libuv using pure posix headers and posix-only source and pthread-fixes (for pthread_signal workaround) but it still does not work finally because:
libuv depends on poll(file_descriptor, ....) and that is not supported in emscripten.
Assertion thrown:
https://github.com/libuv/libuv/blob/v1.x/src/unix/posix-poll.c around line 200:
if (nfds == 0) { assert(timeout != -1); return; }
Related issue:
poll() should respect timeout value when there are no fds to poll: https://github.com/emscripten-core/emscripten/issues/2590
Using linux headers and source causes epoll failure because epoll isn't supported in emscripten either.
Related issue: https://github.com/emscripten-core/emscripten/issues/5033
is there anyway to get libuv to work inside emscripten/wasm using any of emscripten constructs ?
I don't want to use emscripten/browser's event loop for callback into my c++ code - I think it will be slow and that hasn't worked well so far also and will require more changes to Mapbox than I am comfortable with.
thanks,
I'm moving this to libuv/help because it's not really an issue with libuv itself.
I suspect the answer to your question is "you're out of luck" - the ability to sleep/suspend by polling on a possibly empty set of file descriptors is central to libuv's design.