Not sure if this relates... I had a very similar issue with a node addon,
and promises just not resolving.  I'm not sure specifially how your
browsers Promises get scheduled, but in V8, the library schedules them as
microtasks, that you basically have to call process.tick() in order to kick
that event loop.  I don't know if the same functionality exists in the JS
browser...
You're not supposed to have to worry about such details, but in a thread,
if I didn't also call the runmicrotasks sort of thing, the promises
resolved never got dispatched.

On Wed, Mar 25, 2020 at 5:52 PM Kevin McGrath <[email protected]>
wrote:

>   Ah!  Thanks for the details!  I looked into Asyncify and ruled it out
> because of this from the emscripten documentation:
>
> It is not safe to start an async operation while another is already
>> running. The first must complete before the second begins.
>
>
>   That would mean one HTTP request at a time, one after another, and any
> time we want to use Asyncify for any other async JavaScript tasks we may
> run into trouble that would be a nightmare to debug.  Plus there's more
> issues described in that doc, such as if we get an event (like a keypress)
> while the async JavaScript is running it doesn't sound too stable when it
> calls into compiled code.  Lastly, they mention that you should always run
> optimized builds if you're using Asyncify, which will not be fun to debug.
> Taking all of that into consideration, it didn't sound like a good option
> to me, especially since I wasn't sure it would work in the first place with
> USE_PTHREADS=1.
>
>   I'm not sure I understand how emscripten_set_main_loop() will help my
> JavaScript execute the async code... are you saying that the compiled code
> in each thread is blocking the JavaScript code?
>
>   Sorry for so many questions, I'm very new to JavaScript and know very
> little about its internal workings.  Also seems impossible to Google for
> this kind of stuff.
>
>   Thank you!
>
> --
> 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/1445b398-abcb-483e-8384-6c5bebfc3e29%40googlegroups.com
> <https://groups.google.com/d/msgid/emscripten-discuss/1445b398-abcb-483e-8384-6c5bebfc3e29%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/CAA2GJqVgXMhVHxXE5zc7F3rd-sfVv7_nBj-ZY9zDa61yLVCsRQ%40mail.gmail.com.

Reply via email to