Emscripten: Move the Qt event loop off the JS main thread

...so that spawning and joining new threads works now and we no longer need a
hardcoded -sPTHREAD_POOL_SIZE of pre-spawned threads (see
b84ef4d67eaf9f9fd7fd700ca05339cb0cdff742 "Adapt comphelper::ThreadPool to
Emscripten's threading needs"; lets keep MAX_CONCURRENCY capped at 4, at least
for now, though).

This requires
<167b08844d>
"Minimal support for Emscripten -sPROXY_TO_PTHREAD=1" and
<c722a25630>
"Implement QWasmCursor::changeCursor for Emscripten PROXY_TO_PTHREAD case" (see
TODOs there).

Change-Id: I8cea827bd7786e3c9fd9401b4b2bef9d3ec00d5a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/171758
Reviewed-by: Stephan Bergmann <stephan.bergmann@allotropia.de>
Tested-by: Jenkins
This commit is contained in:
Stephan Bergmann 2024-08-12 13:04:48 +02:00
parent 221667db03
commit 6e6451ce96
4 changed files with 7 additions and 2 deletions

View File

@ -63,6 +63,7 @@ $(call gb_Executable_get_linktarget_target,soffice_bin): \
$(eval $(call gb_Executable_add_ldflags,soffice_bin,\
-s EXPORTED_FUNCTIONS=@$(gb_CustomTarget_workdir)/desktop/soffice_bin-emscripten-exports/exports -Wl$(COMMA)--whole-archive $(call gb_StaticLibrary_get_target,unoembind) -Wl$(COMMA)--no-whole-archive \
-sPROXY_TO_PTHREAD=1 -sOFFSCREENCANVAS_SUPPORT=1 -sOFFSCREENCANVASES_TO_PTHREAD=\#qtcanvas \
))
ifeq ($(ENABLE_QT6),TRUE)
$(eval $(call gb_Executable_add_ldflags,soffice_bin, \

View File

@ -15,7 +15,7 @@ gb_EMSCRIPTEN_CPPFLAGS := -pthread -s USE_PTHREADS=1 -D_LARGEFILE64_SOURCE -D_LA
gb_EMSCRIPTEN_LDFLAGS := $(gb_EMSCRIPTEN_CPPFLAGS)
# Initial memory size and worker thread pool
gb_EMSCRIPTEN_LDFLAGS += -s TOTAL_MEMORY=1GB -s PTHREAD_POOL_SIZE=6
gb_EMSCRIPTEN_LDFLAGS += -s TOTAL_MEMORY=1GB
# To keep the link time (and memory) down, prevent all rewriting options from wasm-emscripten-finalize
# See emscripten.py, finalize_wasm, modify_wasm = True

View File

@ -64,11 +64,14 @@ With "-opensource -confirm-license" you agree to the open source license.
git clone https://github.com/allotropia/qt5.git
cd qt5
git checkout v5.15.2+wasm
git checkout 5.15.2+wasm
./init-repository --module-subset=qtbase
./configure -opensource -confirm-license -xplatform wasm-emscripten -feature-thread -prefix <whatever> QMAKE_CFLAGS+=-sSUPPORT_LONGJMP=wasm QMAKE_CXXFLAGS+=-sSUPPORT_LONGJMP=wasm
make -j<CORES> module-qtbase
Note that `5.15.2+wasm` is a branch that is expected to contain further fixes as they become
necessary.
Do not include `-fwasm-exceptions` in the above `QMAKE_CXXFLAGS`, see
<https://emscripten.org/docs/api_reference/emscripten.h.html#c.emscripten_set_main_loop> "Note:
Currently, using the new Wasm exception handling and simulate_infinite_loop == true at the same time

View File

@ -5,3 +5,4 @@ Module.preRun.push(function() {
ENV.MAX_CONCURRENCY = '4';
ENV.SAL_LOG = "+WARN"
});
Module.ignoreApplicationExit = true;