FreeCAD (Qt 6.11 Widgets, JSPI, wasm64) running in the browser
-
FreeCAD 1.1.3 with its Qt Widgets UI, compiled with Qt 6.11.2 for WebAssembly built from source with -feature-wasm-exceptions -feature-wasm-jspi, threaded, targeting wasm64-emscripten. https://freecad.virtastic.app
Two Qt-specific things worth knowing if you run a large Widgets app under JSPI:
- QtEventListener in qstdweb.cpp is not a promising entry point, so QDialog::exec from a real DOM event throws SuspendError while the same call from a promising export works. We replace the listener with one that dispatches through a promising export.
- Qt-wasm only focuses its hidden input element for text widgets, so with anything else focused keydown never reaches Qt. We forward trusted key events to the canvas.
Both patches, with the measurements that found them: https://virtastic.app/blog/freecad-web-wasm64-runtime/
Source (LGPL): https://github.com/Virtastic/freecad-web
Two and a half minutes of it running: https://youtu.be/LJs-75_wSMI -
FreeCAD 1.1.3 with its Qt Widgets UI, compiled with Qt 6.11.2 for WebAssembly built from source with -feature-wasm-exceptions -feature-wasm-jspi, threaded, targeting wasm64-emscripten. https://freecad.virtastic.app
Two Qt-specific things worth knowing if you run a large Widgets app under JSPI:
- QtEventListener in qstdweb.cpp is not a promising entry point, so QDialog::exec from a real DOM event throws SuspendError while the same call from a promising export works. We replace the listener with one that dispatches through a promising export.
- Qt-wasm only focuses its hidden input element for text widgets, so with anything else focused keydown never reaches Qt. We forward trusted key events to the canvas.
Both patches, with the measurements that found them: https://virtastic.app/blog/freecad-web-wasm64-runtime/
Source (LGPL): https://github.com/Virtastic/freecad-web
Two and a half minutes of it running: https://youtu.be/LJs-75_wSMI@Virtastic Thanks for sharing!
It seems to run well on Google Chrome, but on Firefox 156.0 I get spammed with never-ending popups that say, "That operation failed and was stopped (can't convert 123456789 to BigInt). Your document is unchanged -- please report this."
- QtEventListener in qstdweb.cpp is not a promising entry point, so QDialog::exec from a real DOM event throws SuspendError while the same call from a promising export works.
Note: nested event loops are known to be problematic so they are discouraged now. https://doc.qt.io/qt-6/qdialog.html#exec says, "Avoid using this function; instead, use open()."
-
@Virtastic I can confirm the same issue on macOS with Firefox 155.1