Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[WebAssembly] the test program will block on the main thread #207

Closed
lc-soft opened this issue Apr 4, 2020 · 2 comments
Closed

[WebAssembly] the test program will block on the main thread #207

lc-soft opened this issue Apr 4, 2020 · 2 comments

Comments

@lc-soft
Copy link
Owner

lc-soft commented Apr 4, 2020

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.
QQ截图20200404213424

Environment (please complete the following information):

  • LCUI version: develop branch
  • Build tools: emscripten
  • OS and version: Ubuntu 18.04.3 LTS

Additional context

@lc-soft
Copy link
Owner Author

lc-soft commented Apr 4, 2020

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();
}

20200404220025

@lc-soft
Copy link
Owner Author

lc-soft commented Apr 4, 2020

Run test.js on node:

node --experimental-wasm-threads --experimental-wasm-bulk-memory test.js

image

@lc-soft lc-soft closed this as completed May 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant