Date 2025/03/10
Author Michael Schmuki (@boardend )
Contact michael at opengis dot ch
Version QGIS 3.44
qgis-js has demonstrated that it is possible to cross-compile QGIS core and it's dependencies with Emscripten to WebAssembly in order to use it on the web platform as well as other JavaScript runtimes like Node and Deno.
To achieve this, some patching of QGIS was needed:
- Some small patches to disable certain features that are not (yet) supported
- Tweaking of the CMake structure/scripts
- Some heavy, horizontal patches, for example, the exclusion of the
QgsAuthManager
Especially the horizontal patches prevent qgis-js from following the QGIS roadmap and keeping it up to date to the latest QGIS version. With this proposal we want to bring those patches upstream to the QGIS project and adopt wasm32-emscripten as a supported build target for QGIS.
The primary goal of qgis-js is to port QGIS core to WebAssembly for rendering QGIS projects on the client side, serving as a replacement for QGIS Server. It also includes optional OpenLayers integration for seamless embedding into web applications. While qgis-js's API surface is currently limited, we aim to expand it in the future.
Additionally, compiling QGIS to WebAssembly opens new possibilities, such as porting QGIS processing, bringing PyQGIS to the browser, and building full-screen QGIS apps using Qt Classic or Qt Quick (e.g., porting QField). Although this is outside the scope of qgis-js, upstreaming this work will provide a foundation for developers to explore these opportunities.
The proposed solution involves the following steps:
- Rebase all patches from qgis-js and integrate them into the main QGIS repository for use by qgis-js and other projects.
- Update qgis-js to the latest QGIS version and ensure future compatibility and updates.
- Integration of qgis-js patches into the main QGIS repository on master.
- Adopting
wasm32-emscriptenas a build target in CMake/vcpkg - Continuous Integration test on Github Actions to ensure Emscripten compatibility in the future.
- A new major version of qgis-js based on QGIS 3.44
- CMake build scripts
- Turning off certain features when the Emscripten toolchain is detected (e.g.
-DWITH_AUTH:BOOL=FALSE) - We might introduce new feature flags to disable certain features that won't work with Emscripten in CMake
- Turning off certain features when the Emscripten toolchain is detected (e.g.
- Various source files
- Conditionally exclude certain code blocks with
#ifndef Q_OS_WASM- see
QtGlobaldocs
- see
- Conditionally exclude certain code blocks with
- New Github Action
- Additional complexity (build system and QGIS sources)
Running QGIS in a web browser may have performance implications due to the limitations of the wasm32-emscripten target. These implications will need to be evaluated and optimized during the development process but won't affect any other build target of QGIS.
This enhancement should not affect the existing build targets.
- qgis-js
- Geospatial C++ libraries
- Qt Classic
- Qt Quick
- Python