You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
std::promise::get() often uses 100% cpu, starving the thread it is waiting for. This happens sporadically with std::thread's, but consistently with emscripten_async_wget2_data. The behaviour appears the same in WASM/ASM.js. This affects both 1.38.13 and 1.38.14 (Edit: still an issue in 1.38.26).
So I should be calling 'emscripten_async_wget2_data(...)' like 'std::thread(emscripten_async_wget2_data, ...)'? I kind of thought that this was all handled internally by that function. I'll give that a shot and see how that goes.
Edit:
Calling 'emscripten_async_wget2_data(...)' like 'std::thread(emscripten_async_wget2_data, ...).detach()' doesn't seem to change anything.
Looking at the JS callstack it seems to be stuck in 'emscripten_futex_wait', which seems weird since JS natively has promises/futures. I would have thought that a std::promise would just get converted into a JS promise.
Looking back at this with more experience, I'm pretty sure that emscripten_async_wget2_data is trying to execute on the main thread, but since the main thread is waiting on a promise, it never gets executed.
I'd still consider this a bug, as waiting on a promise should still execute queued calls on the main thread. There's other cases in Emscripten where sleeping the main thread really sleeps for a bit, waked up to check the event queue (emscripten_main_thread_process_queued_calls), then goes back to sleeping. Eg timedwait here.
Edit: _emscripten_futex_wait does call emscripten_main_thread_process_queued_calls, so I'm not really sure why that's not working.
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.
Activity
VirtualTim commentedon Oct 25, 2018
Possibly related to #7261?
kripken commentedon Oct 25, 2018
I think you'd actually need to run the operation on another thread for this to work, but I'm not sure.
VirtualTim commentedon Oct 26, 2018
So I should be calling 'emscripten_async_wget2_data(...)' like 'std::thread(emscripten_async_wget2_data, ...)'? I kind of thought that this was all handled internally by that function. I'll give that a shot and see how that goes.
Edit:
Calling 'emscripten_async_wget2_data(...)' like 'std::thread(emscripten_async_wget2_data, ...).detach()' doesn't seem to change anything.
Looking at the JS callstack it seems to be stuck in 'emscripten_futex_wait', which seems weird since JS natively has promises/futures. I would have thought that a std::promise would just get converted into a JS promise.
VirtualTim commentedon Mar 6, 2019
Looking back at this with more experience, I'm pretty sure that emscripten_async_wget2_data is trying to execute on the main thread, but since the main thread is waiting on a promise, it never gets executed.
I'd still consider this a bug, as waiting on a promise should still execute queued calls on the main thread. There's other cases in Emscripten where sleeping the main thread really sleeps for a bit, waked up to check the event queue (emscripten_main_thread_process_queued_calls), then goes back to sleeping. Eg timedwait here.
Edit:
_emscripten_futex_waitdoes callemscripten_main_thread_process_queued_calls, so I'm not really sure why that's not working.stale commentedon Mar 10, 2020
This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.