-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Closed
Description
See the comment in the code below:
unsigned int futexVal = 0;
void* WakingThread(void* arg)
{
Sleep(1000);
using namespace emscripten;
val offscreen = val::global("OffscreenCanvas").new_(256, 256);
val context3 = offscreen.call<val>("getContext", std::string("2d"));
///////////////////////////////////////////////
// After that line, the App freeze ! it seem to me a dead lock !
// Without this line everything is ok.
val imageData = context3.call<val>("getImageData", 0, 0, 50, 50);
/////////////////////////////////////////////////
``
emscripten_atomic_store_u32(&futexVal, 1);
emscripten_futex_wake(&futexVal, INT_MAX);
pthread_exit(0);
}
// the main() run in main thread
OnButton()
{
pthread_t thread;
pthread_attr_t attr1;
pthread_attr_init(&attr1);
int rct = pthread_create(&thread, &attr1, (void* (*)(void*))WakingThread, nullptr);
while (emscripten_atomic_load_u32(&futexVal) == 0)
{
emscripten_console_log("in __");
emscripten_futex_wait(&futexVal, 0, INFINITY);
emscripten_console_log("end __");
}
}
Version of emscripten/emsdk:
emcc (Emscripten gcc/clang-like replacement + linker emulating GNU ld) 3.1.9 (54675ba)
clang version 15.0.0 (https://github.com/llvm/llvm-project faef447e72a5c63dfb12bb7b02d44c3c916d31cd)
Target: wasm32-unknown-emscripten
Thread model: posix
Metadata
Metadata
Assignees
Labels
No labels