emscripten-core / emscripten-core/emscripten
Emscripten fetch API won't invoke callback if the calling thread is in waiting.
- Lingua principale
- C++
- Stelle
- 27.6k
- Fork
- 3.6k
- Merge medio
- 1g 14h
- PR unite (30g)
- 125
Descrizione
We ran into an issue with Emscripten fetch API in ASYNC mode.
After a thread issued a Emscripten fetch call, we put it in waiting status, meaning we call std::conditional_variable::wait() on the calling thread. In this case, the fetch callbacks never get invoked.
The structure of our code is something like:
- function definition:
```
void invokeNetworkingCall(callback){
_attr.onsuccess = callback;
emscripten_fetch(_attr, ...);
}
```
/////////////////////////////////////////////
- In the calling thread:
```
std::conditional_variable c;
invokeNetworkingCall([&c]{
// some operations
c.notify_all();
});
c.wait();
```
I've read the documentation about the "Waitable" mode, but not sure if that's related to this issue. But anyway, I wonder what's the reason this happens, even I've pass the -pthread + -s PROXY_TO_PTHREAD to the compiler/linker, which enable pthread and ran app on it. Shouldn't the callback of "Fetch API" triggered from a different thread than the calling one?
Thanks!
Guida per i contributori
Apri la guida per i contributori
Direzione di ricerca
Inizia dall’entry point emscripten_fetch e dal comportamento di ASYNC, Waitable, -pthread e PROXY_TO_PTHREAD descritto nel report. Riproduci il fallimento del callback con std::condition_variable::wait(), quindi traccia come vengono pianificati i fetch callbacks e controlla i test esistenti relativi al threading o al fetch. Il lavoro è completato quando il comportamento documentato o previsto del callback è stato stabilito e un test di regressione copre il caso del thread in attesa.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- cpp, wasm
- Ambito
- compilers, networking
- Tipo di issue
- Bug
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100