emscripten-core / emscripten-core/emscripten

firefox hangs when using fetch api

Open
#12,805 2 comments 0 reactions 0 assignees View on GitHub
wontfix
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

I have code like the following:
```
std::string buffer;
std::thread thd([&buffer, &filepath_absolute] {
emscripten_fetch_attr_t attr;
emscripten_fetch_attr_init(&attr);
strcpy(attr.requestMethod, "GET");
attr.attributes =
EMSCRIPTEN_FETCH_LOAD_TO_MEMORY |
EMSCRIPTEN_FETCH_SYNCHRONOUS |
EMSCRIPTEN_FETCH_REPLACE /* https://github.com/emscripten-core/emscripten/issues/8749 */
;
emscripten_fetch_t* fetch = emscripten_fetch(&attr, filepath_absolute.c_str()); // Blocks here until the operation is complete.
if (fetch->status == 200) {
//Corrade::Utility::Debug{} << "Finished downloading " << fetch->numBytes << " bytes from url: " << fetch->url;
// The data is now available at fetch->data[0] through fetch->data[fetch->numBytes-1];
}
else {
//Corrade::Utility::Debug{} << "Download failed. (url: '" << fetch->url << "', HTTP status code:" << fetch->status << ")";
}

buffer = std::string(fetch->numBytes, ' ');
memcpy(buffer.data(), fetch->data, fetch->numBytes);

emscripten_fetch_close(fetch);
});
thd.join();
```
On firefox, the call seems to just hang on the thd.join(). Things work fine on chrome.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.