LCUI
LCUI copied to clipboard
[WebAssembly] the test program will block on the main thread
Describe the bug I tried to compile the source code of LCUI into WebAssembly, but when running the test program, I found that it would block on the main thread
To Reproduce Steps to reproduce the behavior:
emconfigure ./configure --enable-video-output=no --with-openmp=no --disable-shared
make
cd test
emcc -s WASM=1 -s USE_PTHREADS=1 -I../include -Wall -D _GNU_SOURCE -pthread -O2 -o test.html test.o libtest.o test_mainloop.o test_charset.o test_string.o test_strpool.o test_linkedlist.o test_object.o test_thread.o test_font_load.o test_css_parser.o test_xml_parser.o test_image_reader.o test_block_layout.o test_flex_layout.o test_widget_rect.o test_widget_opacity.o test_widget_event.o test_textview_resize.o test_textedit.o ../src/.libs/libLCUI.a -lm -pthread
Expected behavior Not blocking.
Screenshots
If applicable, add screenshots to help explain your problem.

Environment (please complete the following information):
- LCUI version: develop branch
- Build tools: emscripten
- OS and version: Ubuntu 18.04.3 LTS
Additional context
- https://github.com/emscripten-core/emsdk
- https://emscripten.org/docs/compiling/Building-Projects.html#build-system-issues
After commenting out the function that uses the thread, the test program can exit correctly.
#include <stdio.h>
#include <wchar.h>
#include <LCUI_Build.h>
#include <LCUI/LCUI.h>
#include "test.h"
#include "libtest.h"
int tests_count = 0;
int main(void)
{
int ret = 0;
Logger_SetLevel(LOGGER_LEVEL_OFF);
ret += test_charset();
ret += test_linkedlist();
ret += test_string();
ret += test_strpool();
ret += test_object();
//ret += test_thread();
ret += test_font_load();
ret += test_image_reader();
//ret += test_xml_parser();
//ret += test_widget_event();
//ret += test_widget_opacity();
//ret += test_textview_resize();
//ret += test_textedit();
//describe("test mainloop", test_mainloop);
//describe("test css parser", test_css_parser);
//describe("test block layout", test_block_layout);
//describe("test flex layout", test_flex_layout);
//describe("test widget rect", test_widget_rect);
//PRINT_TEST_RESULT(ret);
return ret - print_test_result();
}

Run test.js on node:
node --experimental-wasm-threads --experimental-wasm-bulk-memory test.js
