Skip to content

Qt for WebAssembly

Specific issues when using Qt for WebAssembly

454 Topics 1.8k Posts
  • QT WebAssembly for 32bit programs

    Unsolved 31 Dec 2019, 20:10
    0 Votes
    2 Posts
    450 Views
    It depends entirely on what your application actually does, as there are quite a few features present in the desktop and embedded platforms that will not work on WebAssembly platform. There are plenty of example apps: https://www.qt.io/qt-examples-for-webassembly https://s3.eu-west-2.amazonaws.com/wasm-qt-examples/last/index.html
  • 0 Votes
    4 Posts
    976 Views
    For those wondering, I got it set up like this: [image: d99fa163-7a7c-46ba-aad7-8382d71ade29.png] You have to manually copy the environment variables set when you run source ./emsdk_env.sh in the shell. I did not know that source was a shell builtin
  • Qt for WebAssembly binaries for Mac OS

    Unsolved 11 Dec 2019, 12:02
    0 Votes
    4 Posts
    1k Views
    You need to explicitly enable the webassembly plugin. From the menu: QtCreator->About plugins->Device Support->WebAssembly (experimental) Depending on your version of emscripten that you installed, it may or may not successfully detect the emscripten compiler.
  • Add qml plugins in wasm

    Unsolved 10 Dec 2019, 17:34
    0 Votes
    5 Posts
    2k Views
    Success :) To remove clipboard error, i disabled clipboard in source code : void QWasmClipboard::initClipboardEvents() { if (!hasClipboardApi) return; /*val permissions = val::global("navigator")["permissions"]; val readPermissionsMap = val::object(); readPermissionsMap.set("name", val("clipboard-read")); permissions.call<val>("query", readPermissionsMap); val writePermissionsMap = val::object(); writePermissionsMap.set("name", val("clipboard-write")); permissions.call<val>("query", writePermissionsMap);*/ hasClipboardApi = false; } Clipboard permission is not managed on my firefox (63.0.3 64bit). And to the blank page, i used QQuickView with resizeMode at SizeRootObjectToView : QQuickView* view = new QQuickView(); view->setResizeMode(QQuickView::SizeRootObjectToView); view->setSource(QUrl(QStringLiteral("qrc:///main.qml"))); view->show();
  • Qt 5.13.2 and recommended emscripten

    Solved 19 Nov 2019, 01:45
    1 Votes
    3 Posts
    764 Views
    Thanks Lorn. It was easier to rebuild Qt at the end, and it solved the issue.
  • Run webassembly app without server

    Unsolved 18 Nov 2019, 14:36
    0 Votes
    2 Posts
    535 Views
    It needs to be served from a server. Luckily, there is a development tool in emscripten called emrun that you can use to serve the html file that gets generated when building.
  • 0 Votes
    4 Posts
    2k Views
    @tham your browser has a variety of option for you to do so. For chrome you could do one of the following: CTRL-Shift-R Use incognito mode Use the dev settings to disable it- Use Chrome profiles to create a profile with all caching disabled I don't know if there's a command or something the server could send to your browser to force a complete reload.
  • Android chrome black screen

    Unsolved 10 Nov 2019, 10:39
    0 Votes
    2 Posts
    518 Views
    You can attach remote debugging and get some console output, which may help. You might need to enable webassembly from chrome://flags
  • Using QThread in a webassembly app with latest upstream

    Unsolved 6 Nov 2019, 16:05
    0 Votes
    4 Posts
    1k Views
    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.
  • 0 Votes
    4 Posts
    718 Views
    Do anyone know workarounds to avoid this bug?Thanks
  • 0 Votes
    3 Posts
    540 Views
    Okay, thanks! I would prefer it to use less CPU in that case so I will open a bug after I tried it without multithreading. Edit: Single threaded its fine (QTBUG-79953)
  • 0 Votes
    3 Posts
    798 Views
    I was able to configure an out-of-source build, passing win32-msvc2019 as the argument for -platform, I got the output shown in this Gist: https://gist.github.com/DragonOsman/3c198095a61a7c38e2b019d3a964d416 . Notice the errors. I configured with this command: C:/qt5/configure -static -release -opensource -feature-thread -qt-zlib -qt-libjpeg -qt-libpng -platform win32-msvc2019 -prefix C:/qt5/qtbase/win32-msvc2019 from a separate directory outside the Qt source directory and tried to build by running just nmake with no arguments. Any help is appreciated. Thanks in advance. Edit: I tried again after re-configuring and this time not passing -static at all, but it still failed. Here's the build log from the recent try: https://gist.github.com/DragonOsman/c13d23ceca50244fb4a195f67d8e613d .
  • Building QT for WebAssembly on windows

    Unsolved 6 Nov 2019, 16:03
    0 Votes
    5 Posts
    826 Views
    That is great news. Thanks again.
  • /home/web_user @ start of app is empty.

    Unsolved 5 Nov 2019, 09:53
    0 Votes
    2 Posts
    686 Views
    The javascript FS functions we use for syncing the settings are asynchronous, so the c'tor will complete before the settings file has synced into the wasm sandbox filesystem. That said, there is a change that I have found helps somewhat. If you build Qt yourself, you could try this: https://codereview.qt-project.org/c/qt/qtbase/+/264618
  • Problems building Qt5 for WebAssembly

    Unsolved 5 Nov 2019, 21:58
    0 Votes
    2 Posts
    502 Views
    You can use the prebuilt Qt for WebAssembly from the official Qt installer. Anyway, since your compilation fails on Qt3D, try skipping that module.
  • 0 Votes
    16 Posts
    2k Views
    I think the reason for the Assert Failure errors is that I forgot to delete the files in the qtbase folder after a given build attempt. I think that's fixed now, but I still have some issues in building Qt so I'll open a thread now.
  • Qt WebGL Font Issues

    Unsolved 31 Oct 2019, 20:11
    0 Votes
    4 Posts
    748 Views
    I am not even sure QtWebGL works with emscripten/ QtWebAssembly
  • 0 Votes
    6 Posts
    2k Views
    @DamienL QFileDialog::getOpenFileContent is the workaround for accessing system/local files due to the javascript sandbox that webassembly lives in.
  • How to link 3rd party libraries?

    Unsolved 3 Oct 2019, 16:02
    0 Votes
    8 Posts
    2k Views
    @Vadi2 Other than adding your libs with LIBS += -lblahblah you shouldn't have to pass anything extra to Qt to get it to link statically, as QtWebAssembly does that anyway. You could try QMAKE_LFLAGS += -static in your project if there is any issues, or it tries to link dynamically.
  • Qt Design Viewer .qmlrc?

    Unsolved 24 Oct 2019, 12:51
    1 Votes
    2 Posts
    829 Views
    This thread can be closed. For those who are looking for an answer: Build Qt UI Application for .qmlproject file. Attention: JS doesnt work within the project if the aim is to deploy with Qt design viewer