Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Using QThread in a webassembly app with latest upstream



  • Hi All,

    There's a thing regarding emscripten SDK and Qt threads that has to be clarified.

    In one hand, Qt indicates the following (from October 2019, 8th):

    The known-good versions are:

    Qt 5.12: 1.38.16
    Qt 5.13: 1.38.27 (multithreading: 1.38.30)
    Use emsdk to install specific emscripten versions (example):

    ./emsdk install sdk-1.38.16-64bit
    ./emsdk activate --embedded sdk-1.38.16-64bit

    but on the other hand, beneficiating from a fast build requires to follow these steps (from here):

    emsdk install latest-upstream
    emsdk activate latest-upstream
    

    The "lastest" implies now it will install emscripten version 1.39.0:

    MACBOOKs-MacBook-Pro:mandelbrot macbook$ which em++
    /Users/macbook/emsdks/emsdk/upstream/emscripten/em++
    MACBOOKs-MacBook-Pro:mandelbrot macbook$ em++ --version
    emcc (Emscripten gcc/clang-like replacement) 1.39.0 (commit ae5044e7797654f2ed5fb7c0e174e7c8ead5187b)
    Copyright (C) 2014 the Emscripten authors (see AUTHORS.txt)
    This is free and open source software under the MIT license.
    There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
    

    There is an incoherence in the installation process, as versions differ.
    And using 1.39 does not allow me to enjoy multithreading, as it simly freezes the wep app (i.e the "Mandelbrot" project, or my own projects whuch use QThread).

    Is it related ? Is there a way to combine both fast build using the latest sdk with upstream and QThread ?

    Thanks a lot.



  • @DamienL said in Using QThread in a webassembly app with latest upstream:

    There is an incoherence in the installation process, as versions differ.
    And using 1.39 does not allow me to enjoy multithreading, as it simly freezes the wep app (i.e the "Mandelbrot" project, or my own projects whuch use QThread).
    Is it related ? Is there a way to combine both fast build using the latest sdk with upstream and QThread ?

    There is a known issue where a wakeup event doesn't reach the app so it doesn't update, but if you move the mouse it will update.

    https://bugreports.qt.io/browse/QTBUG-75793

    Other than that, I haven't had any problem with 1.39.0 with threads.



  • @lorn-potter

    None of the examples using QThreads works. Among them:

    QueudCustomTypes
    Mandelbrot
    TextureInThread

    I built Qt sources 5.13.1 using upstream 1.39.0

    here's my Qt setup:

    Qt Creator 4.8.1
    Based on Qt 5.12.0 (Clang 10.0 (Apple), 64 bit)
    From revision e8df914ef2
    Built on Jan 15 2019 22:17:21
    

    But I still have Sources from Qt 5.13.1
    I can't update my Qt as I run it on Sierra 10.12 when Qt 5.13 needs Sierra 10.13.

    Project WARNING: Qt requires at least version 10.13 of the platform SDK, you're using 10.12. Please upgrade.
    

    Is it related to this warning ?

    Thank you.



  • Ok, so I updated my OS, and rebuilt my sources using the configure options :

    ./configure -xplatform wasm-emscripten -nomake examples -prefix $PWD/qtbase -no-warnings-are-errors -device-option WASM_OBJECT_FILES=1 -feature-thread
    

    And building my sources with the command:

    gmake -j4 module-qtbase module-qtdeclarative module-qtquickcontrols2 module-qtwebsockets module-qtsvg module-qtcharts module-qtmqtt module-qtdatavisualization
    

    It all compiles pretty well.

    But know when I try to compile a thread example (Mandelbrot for example) the building gives my this:

    Qt/5.13.1/Src/qtbase/plugins/imageformats/libqwebp.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libQt5Widgets.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libQt5Gui.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libqtlibpng.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libqtharfbuzz.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libQt5Core.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libqtpcre2.a   
    wasm-ld: error: 'atomics' feature is disallowed by main_7512882a.o, so --shared-memory must not be used
    wasm-ld: error: Target feature 'atomics' used in main.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in mandelbrotwidget.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in renderthread.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in mandelbrot.js_plugin_import.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in moc_mandelbrotwidget.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in moc_renderthread.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in main_ad242c24.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in qwasmintegration_b84335f2.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in qwasmwindow_9693253c.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in qwasmscreen_5d172ee8.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in qwasmfontdatabase_96baba53.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in qwasmeventtranslator_b3a8cbb6.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in qwasmeventdispatcher_d440ff3d.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in qwasmcompositor_943e9174.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in qwasmcursor_54ea64f6.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in qwasmopenglcontext_242faabc.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in qwasmtheme_592c2dd9.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in qwasmclipboard_11896fc1.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: Target feature 'atomics' used in qwasmservices_bcfe057a.o is disallowed by main_7512882a.o. Use --no-check-features to suppress.
    wasm-ld: error: too many errors emitted, stopping now (use -error-limit=0 to see all errors)
    shared:ERROR: '/Users/macbook/emsdks/emsdk/upstream/bin/wasm-ld -o /var/folders/l_/53ppf0452z7bcrt24txtwfq00000gn/T/emscripten_temp_chKBFJ/mandelbrot.wasm --allow-undefined --lto-O0 /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libqtfreetype.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libqtlibpng.a -L/Users/macbook/emsdks/emsdk/upstream/emscripten/system/local/lib main.o -L/Users/macbook/emsdks/emsdk/upstream/emscripten/system/lib mandelbrotwidget.o -L/Users/macbook/.emscripten_cache/wasm-obj renderthread.o mandelbrot.js_plugin_import.o moc_mandelbrotwidget.o moc_renderthread.o /Users/macbook/Qt/5.13.1/Src/qtbase/plugins/platforms/libqwasm.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libQt5EventDispatcherSupport.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libQt5FontDatabaseSupport.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libqtfreetype.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libQt5EglSupport.a /Users/macbook/Qt/5.13.1/Src/qtbase/plugins/imageformats/libqgif.a /Users/macbook/Qt/5.13.1/Src/qtbase/plugins/imageformats/libqicns.a /Users/macbook/Qt/5.13.1/Src/qtbase/plugins/imageformats/libqico.a /Users/macbook/Qt/5.13.1/Src/qtbase/plugins/imageformats/libqjpeg.a /Users/macbook/Qt/5.13.1/Src/qtbase/plugins/imageformats/libqtga.a /Users/macbook/Qt/5.13.1/Src/qtbase/plugins/imageformats/libqtiff.a /Users/macbook/Qt/5.13.1/Src/qtbase/plugins/imageformats/libqwbmp.a /Users/macbook/Qt/5.13.1/Src/qtbase/plugins/imageformats/libqwebp.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libQt5Widgets.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libQt5Gui.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libqtlibpng.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libqtharfbuzz.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libQt5Core.a /Users/macbook/Qt/5.13.1/Src/qtbase/lib/libqtpcre2.a /Users/macbook/.emscripten_cache/wasm-obj/libc-mt.a /Users/macbook/.emscripten_cache/wasm-obj/libcompiler_rt.a /Users/macbook/.emscripten_cache/wasm-obj/libc-wasm.a /Users/macbook/.emscripten_cache/wasm-obj/libc++-mt-noexcept.a /Users/macbook/.emscripten_cache/wasm-obj/libc++abi-mt-noexcept.a --whole-archive /Users/macbook/.emscripten_cache/wasm-obj/libembind-rtti.a --no-whole-archive /Users/macbook/.emscripten_cache/wasm-obj/libgl-mt-webgl2.a /Users/macbook/.emscripten_cache/wasm-obj/libdlmalloc-mt.a /Users/macbook/.emscripten_cache/wasm-obj/libpthread-mt.a /Users/macbook/.emscripten_cache/wasm-obj/libc_rt_wasm.a --import-memory --import-table --shared-memory -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --export __wasm_call_ctors --export __data_end --export main --export malloc --export free --export setThrew --export __errno_location --export fflush --export emscripten_get_global_libc --export __pthread_tsd_run_dtors --export _register_pthread_ptr --export pthread_self --export __emscripten_pthread_data_constructor --export emscripten_futex_wake --export memalign --export emscripten_builtin_memalign --export realloc --export emscripten_builtin_free --export _get_environ --export _ZSt18uncaught_exceptionv --export emscripten_GetProcAddress --export emscripten_webgl_make_context_current --export emscripten_webgl_get_current_context --export strstr --export _get_tzname --export _get_daylight --export _get_timezone --export strlen -z stack-size=5242880 --initial-memory=1073741824 --no-entry --max-memory=1073741824 --global-base=1024' failed (1)
    gmake: *** [Makefile:320: mandelbrot.js] Error 1
    10:58:20: The process "/usr/local/bin/gmake" exited with code 2.
    Error while building/deploying project mandelbrot (kit: Qt 5.13.1 (Src))
    When executing step "Make"
    10:58:20: Elapsed time: 00:58.
    

    And I have no clue what it means.

    Thanks.


Log in to reply