Terrain Viewer QGIS Plugin: Internals
How the Terrain Viewer QGIS plugin is built, tested and released: its release history, how Esri Wayback's dates are listed, how the repository follows releases, the packaged tile service, the tests, crashes at exit and quit, and the design history.
The developer side of the Terrain Viewer QGIS plugin: what a QGIS user needs is on that page.
Release history
Newest first, up to the release this page was last revised for (the changelog has them all).
0.12.5: 0.12.4 with a warning banner when Google Earth historical is ticked under the Python backend, and a button to the packaged tile server. 0.12.4 was 0.12.3 with Historical fixes (an unticked source's dates gone at once, listings stopped with their requests) and a time axis that zooms. 0.12.3 was 0.12.2 with several historical sources ticked at once, their dates in one series, each in its source's color. 0.12.2 was 0.12.1 with fixes (UNESCO's components drawn in their categories, PMTiles through the plugin's own server where GDAL has no PMTiles driver, what Save setup keeps checked under the tile servers, the headless tests' crash at exit on QGIS 3.44 explained: the scripts, not the plugin). 0.12.1 was 0.12.0 with the plugin's folder renamed to iconem_terrain_viewer (coming from 0.12.0 or earlier). What 0.12.0 added is marked so below (keeping a setup, the Vector library, out of experimental). What 0.11.0 changed (the Temporal Controller's default step, the backend control on the Historical page, Buildings from).
Library sources missing until 2026-12-01
2026-12-01. Reported: the plugin did not list "GRC Amphipolis" (still in the app's Library, lib/custom-sources.json, a 10 cm COG). The cause was the tile service's list, not the plugin: tile-server/build.mjs kept only Library ids of the form custom-<word>, taking custom-<timestamp> for an entry saved on one machine. Seven Library sources have such ids, so /terrain-sources missed them, and so did the plugin's snapshot (assets/catalog.json, made from that list), which was also older than the GEM-15 Barcelona entry. Both fixed: every SAMPLE_TERRAIN_SOURCES entry is listed (6 Worldwide Defaults and 149 Library sources: 155), and python make_assets.py --sources-only refreshes the snapshot's sources alone. The packaged tile server gets the seven with the next bundle pinned; until then it does not list them, and the panel says so (below).
A hillshade that showed nothing over a raw input (0.9.3)
The tiles were computed; they were hidden. A raw input is an opaque raster, and 0.9.2 put Raw elevation inputs at the top of the layer tree: with a Terrain Viewer (live) group there already (any mode or the basemap checked before), the raw layer covered every mode. With the modes on top, the hillshade multiplies over the raw layer, which QGIS stretched once to the whole raster's range (0 to 5900 m for Canada): black lowlands, and a hillshade multiplied over black stays black. Now the group is kept right under the live group (moved there when a mode's layer joins the tree), and the raw layer's grey is stretched to the 2nd to 98th percentile of what the canvas shows, again at every view. To see a shaded mode alone, uncheck the raw layer.
Esri Wayback's dates: how they are listed
Listing Esri Wayback's dates, and what the panel says meanwhile
Esri answers slowly, so the listing runs in a worker thread (urllib, as the Python backend reads its tiles), the panel reading its progress, and QGIS stays free:
- The catalog, one request: some 200 releases.
- The walk (
tilemap, about 25 requests in eight chains started across the catalog): the 10 to 30 releases whose imagery changed at the centre's tile. This is the app's own shortcut (lib/wayback.ts): the other releases repeat their neighbour's picture there, and are never asked for a date. - One metadata query per kept release, six at a time, shared by every listing since 0.12.4 (six per listing before), for its capture date (Esri's metadata service answers in 1 to 60 s; below). Several releases in a row often carry the same capture: one date per capture, the newest release of it. A release whose date does not answer (asked twice) stands at its release date, marked.
What 0.10.1 changed:
- The dates are added as they answer to the list, the axis and the layer group, with a thin progress bar and "3 of 14 releases dated", also after a pan (0.10.0 waited for the whole list then). Only dated releases appear: a release date is not a capture date. The layers on screen stay until the new list is whole, so the imagery does not go and come back.
- The releases that can hold the date asked for are dated first (imagery is never newer than its release: the first release at or after the date, then outward), the newest first when no date is asked.
- What was found is kept between sessions, in
<profile>/terrain_viewer/wayback-dates.json(the last 300 places): a walk until a new release comes out, a capture date for good. A place seen before costs one request. - A notice above the dates says what the dates shown are worth: The map moved: these dates are of the previous place. Updating (3 of 14 releases dated)... from the moment the centre leaves the tile (a quarter of a tile, as the app) until the new list is whole; Dates still arriving during a first listing; and, zoomed out, Zoom in to see the capture dates. Esri Wayback dates a place from zoom 10 on (about 1:250 000 here); the map is at zoom 7.3. Until then only the newest release is listed: a wider view has no one date. With Follow the map off the dates are not listed again, and the notice says how to (the list button).
Measured at the Eiffel Tower (2026-11-26, QGIS 4.2 and 3.44): the first date after 5 s, all nine after 25 s, 40 requests; listed again in another session, 0.9 s.
Esri Wayback's dates slow, and listings stopped
Reported on 0.12.3: "0 of 15 releases dated", minutes later "2 of 15", with the packaged tile server and with the Python backend (neither is involved: the dates are asked of Esri by the panel itself). Two causes, measured 2026-11-30 from this machine with plain Python against the same addresses:
- Esri's metadata service itself. One query answers in 1 to 90 s, unevenly: twelve releases at a fresh place took a median of 18 to 58 s a query, whether one or six queries were open at once. Twelve queries took 575 s one at a time, 96 s four at a time, 70 s six at a time and 96 s eight at a time (the queries slowed, median 49 s). At the Eiffel Tower, with nothing kept from before, the walk took 4 s (24
tilemaprequests, 0.6 s each) and the fifteen metadata queries 110 s, 23 s each on average, two of them cut at the 40 s timeout and asked again. The app meets the same service (its own queue of four, 60 s). - What the panel added to it, up to 0.12.3. A listing replaced (the map moved past a quarter tile, a source ticked or unticked) was only flagged: its queries in flight ran on to their answer or their 40 s timeout, and a query already started went on to the next finer level (up to four per release, twice). Each listing had its own six queries, so a few pans put a dozen or more queries in front of the current place's, and the service slows past six.
What 0.12.4 does:
- A listing stopped is stopped at once: each listing has an
Abort(historical.py); stopping it (the map leaving the place, as soon as it moves, not when it settles; a source ticked or unticked; the panel closed; Remove) shuts the sockets of its requests in flight, so they end at once (a request to a server that never answers: cut in 0.5 s, checked by the tests), and no further request or finer level is asked. - Six metadata queries at a time across every listing (
META_WORKERS, a shared semaphore), the best of the measures above. - A 60 s timeout for the metadata queries (the app's): an answer at 45 s was cut at 40 s and asked again.
- A listing's answers are shown only while it is the one asked for (its place and its sources); and the dates of a source unticked go at once (above).
What it cannot do: make Esri's service answer faster. A place seen before is listed from what was kept (0.9 s); a new place costs what Esri takes. Timed on 2026-11-30 (two listings replaced after 5 s each, as two pans, then a third at the Louvre timed to its end, plain Python): 99 s and 158 s with 0.12.3's code, 130 s with 0.12.4's; Esri's variance from one run to the next is larger than the difference, so the gain is in what is no longer sent (the replaced listings' queries, cut), not in a measured time.
Distribution, tests and releases
A button that opens QGIS with the repository added: there is none
Asked for the docs' download button. What was checked (2026-11-27):
- No URL scheme. QGIS's sources register none on any platform: the Linux desktop entry runs
qgis %Ffor file types only (nox-scheme-handler), the macOSInfo.plistdeclares document types and noCFBundleURLSchemes, and nothing in the application handles an address handed over by the system. On this Windows machine the registry has noqgisprotocol; the installer registers four file types (.qgzand.qgsQGIS Project,.qlrQGIS Layer Definition,.qmlQGIS Layer Settings,.qpta print template), each opened withqgis.bat "%1". - What a file could do. A
.qlradds layers and nothing else. A.qgzcan carry Python macros that would run such a line when the project opens, but QGIS asks before running them (Settings › Options › General, "Enable macros": Ask by default), and a project that changes the plugin repositories of whoever opens it is not something to publish. A.pyis opened by the system's Python, not by QGIS;qgis --code file.pyruns one, from a command line only. - So: the docs keep a download button and show the one line above, which a reader copies from its code block.
How the repository follows releases
The repository's address (added once) follows new releases by itself: it is a fixed release, qgis-plugins-repository, whose one file each run of the release workflow replaces with the new release's plugins.xml (gh release upload qgis-plugins-repository plugins.xml --clobber in .github/workflows/qgis-plugins.yml), which points at the new zips on their dated release. Nothing to change in QGIS after a release. A dated release's own plugins.xml (.../releases/download/qgis-plugins-2026-11-26e/plugins.xml) stays on that version for ever: use the fixed address.
How often QGIS looks. There is no interval to set in QGIS 3.44 or 4.2 (older versions had a list, from every start to once a month): with Check for Updates on Startup ticked, QGIS fetches the repositories at start when the last check is at least three days old (CHECK_ON_START_INTERVAL = 3 in QGIS's pyplugin_installer/installer_data.py, the same in both versions), and tells in its main window when a plugin can be upgraded. Opening Manage and Install Plugins fetches them at any time, and Reload Repository, on the Settings tab, again. The panel's own check (below) runs once a day whatever these settings.
When the Upgradeable tab shows. Only while at least one installed plugin has a newer version in an enabled repository: QGIS hides the tab when the list would be empty, as it hides New and Invalid (and Not installed with no repository fetched). So yes: no plugin to upgrade, no tab. Checked inside QGIS 4.2 itself (2026-11-26, an empty profile): the tab is hidden; one installed plugin marked upgradeable and it appears; back, and it hides again. A plugin is upgradeable when the version a repository offers is greater than the installed one (QGIS compares the version numbers), counting experimental versions only with Show also Experimental Plugins ticked. For Terrain Viewer, three things can therefore keep the tab away while a newer version exists: the repository not added (or disabled), the list not fetched since the release (open the Plugin Manager, or Reload Repository), or, up to 0.11.0 only, Show also Experimental Plugins not ticked (below).
Experimental until 0.11.0
Up to 0.11.0, Terrain Viewer's metadata.txt said experimental=True, and QGIS leaves such a plugin out of its lists until Show also Experimental Plugins is ticked (Settings tab). Measured in a new profile with the repository added (2026-11-27): QGIS 4.2 does not list 0.11.0 at all without the tick, and lists it with it. 0.12.0 is experimental=False: the Python backend is the default since 0.9.0, every mode is drawn by it, and three rounds of releases went through the update path; plugins.xml takes the flag from metadata.txt (make_zip.py --plugins-xml), so the first release of 0.12.0 lists it as a stable plugin and the tick is no longer needed.
- On 0.11.0 or earlier, tick it to see the plugin in QGIS 4: Settings tab, Show also Experimental Plugins. QGIS 3.44 and 4.2 keep it under
plugin-manager/allow-experimentalin the profile's ini ([plugin-manager],allow-experimental=true); the key of older QGIS versions,app/plugin_installer/allowExperimental, is no longer read by either. - A user on 0.11.0 with the tick off was offered 0.12.0 all the same: a stable version in a repository is always counted. 0.12.1 is offered to nobody as an upgrade (another folder); 0.12.2 is offered to a user on 0.12.1 (the same folder).
The plugin's folder: iconem_terrain_viewer since 0.12.1
Found on 2026-11-27: plugins.qgis.org lists an unrelated plugin also named Terrain Viewer (by LiDARgeek, a 3D DEM viewer, version 1.3.1, for QGIS 3.40 to 3.99) whose folder is terrain_viewer, the folder this plugin had up to 0.12.0. QGIS keys a plugin by its folder name across every repository (the part of file_name before the first dot; pyplugin_installer/installer_data.py, rebuild), so in QGIS 3.40 to 3.x with both repositories enabled the Plugin Manager showed one "Terrain Viewer" entry, with whichever repository's metadata it read last, and could offer the other plugin as an upgrade of this one. In a new QGIS 3.44 profile with both repositories, the entry shown was the other plugin's, and installing by that id from the Python console (installPlugin("terrain_viewer")) installed the other plugin. QGIS 4 was not concerned (that plugin stops at 3.99).
0.12.1 renames the folder to iconem_terrain_viewer: the zip (iconem_terrain_viewer-0.12.1.zip), the folder inside it, the key in plugins.xml and the Python package. Nothing else changes.
- The display name stays "Terrain Viewer". QGIS merges by folder name only: the name is one of the fields it copies, never the key (read in the installer's code of QGIS 3.44.11 and 4.2.0). In QGIS 3.40 to 3.x with both repositories, the Plugin Manager therefore lists two plugins called Terrain Viewer: tell them apart by the author (Iconem; version 0.x).
- The QGIS settings, the custom properties of layers and groups, the project's entries and the data folder in the profile keep the
terrain_viewerprefix, so nothing set or frozen with an earlier version is lost. The other plugin (1.3.1, its source read on 2026-11-27) stores no QGIS setting, no layer property, no project entry and no file in the profile: nothing collides. - No migration: an install of 0.12.0 or earlier is uninstalled by hand (the two steps). Left in place in QGIS 3.40 to 3.x, it can still be offered the other plugin as an upgrade: one more reason to uninstall it.
- The panel's own Update button reads this project's
plugins.xmlalone, where it looks for its own folder name: an 0.12.0 panel finds no entry and offers nothing. - In QGIS 3, if the list shows the other plugin, install from the zip (below) and update from the panel.
How QGIS plugins ship native programs
What the plugin downloads is a Node runtime (the official nodejs.org build, checked against its SHASUMS256.txt when the bundle is made), the tile service's JavaScript (tile-server/*.mjs and the app's code bundled into generated/), and its production node_modules, among them sharp's prebuilt native libraries (libvips) for that platform. It then runs it as a local HTTP service on 127.0.0.1, which QGIS reads as XYZ and GDAL layers like any web service. Other plugins that need native code have done it three ways:
- Download on demand. The classic WhiteboxTools for QGIS plugin does not include the WhiteboxTools binary: the user downloads it from whiteboxgeo.com or the project's GitHub releases and sets its path in Settings > Options > Processing > Providers > WhiteboxTools (its manual); the
whiteboxpackages for Python and R download it themselves on first use. Terrain Viewer's Install is the second form inside QGIS: one click, a pinned version and a checked hash instead of a manual download and a path to type. - Installed with QGIS, the plugin only pointing at it. GRASS ships with QGIS's Windows and macOS installers and OSGeo4W (a separate package on Linux), and its Processing provider is part of QGIS. SAGA has been a separate plugin since QGIS 3.30 (Processing Saga NextGen Provider): SAGA itself comes from OSGeo4W or SAGA's own downloads, and the plugin is told its folder. The Orfeo ToolBox provider likewise needs OTB installed apart and its folder set in the Processing options. None of these plugins carries the program.
- Bundled in the plugin. Rare, because the zip becomes one per platform and large, and a binary in a plugin cannot be reviewed as source. Terrain Viewer 0.3 and 0.4 did it (48 to 60 MB zips, one per platform); 0.5 moved to the download.
What is less common is the form: a local HTTP service rather than a command-line program called per run. It suits tiles, which QGIS already knows how to ask for, cache and cancel; a Processing provider over the same service (one algorithm per mode, writing a GeoTIFF) would be the WhiteboxTools-like form for batch work.
From the repository:
cd qgis-plugin
python make_assets.py [http://localhost:3400] # iconem_terrain_viewer/assets/: ramp and matcap previews, the catalog snapshot (a tile service running)
python make_assets.py --sources-only [http://localhost:3400] # the snapshot's terrain sources alone (the app's Library changed)
python make_app_defaults.py # iconem_terrain_viewer/assets/app_defaults.json: the app's URL parameter defaults and built-in basemaps (Open link)
python make_zip.py # dist/iconem_terrain_viewer-0.12.2.zip and dist/send2map_app-0.5.1.zip
python make_zip.py --plugins-xml <release-tag> # dist/plugins.xml: the QGIS plugin repository of that release (after the zips)
python make_zip.py --service-bundle windows-x64 # dist/terrain-viewer-tile-service-windows-x64.zip (any platform from any host; none named: all four)
python make_zip.py --pins <tile-service-tag> dist # iconem_terrain_viewer/service_pins.json from the bundles in dist/ (before the plain zip)
python make_zip.py --check-pins <assets.json> # fails unless the pinned release (gh release view <it> --json assets) holds every pinned bundle at its size
python make_zip.py --server-dir windows-x64 <folder> # the service unzipped, as the desktop app ships it
python -I smoke_bundled.py dist/terrain-viewer-tile-service-windows-x64.zip # starts it as the plugin does, asks a tile, stops it (no QGIS)
# Through the panel, in headless QGIS, from a temporary plugins folder: Install (the bundle served from this machine and
# pinned, a tampered one refused), Connect, processes, a slope layer, a tile, the unresponsive warnings, Remove
QT_QPA_PLATFORM=offscreen python-qgis test_service_paths.py installed dist/iconem_terrain_viewer-0.12.2.zip dist/terrain-viewer-tile-service-windows-x64.zip
QT_QPA_PLATFORM=offscreen python-qgis test_service_paths.py installed dist/iconem_terrain_viewer-0.12.2.zip # the real download from the pinned release
QT_QPA_PLATFORM=offscreen python-qgis test_service_paths.py external dist/iconem_terrain_viewer-0.12.2.zip http://localhost:3400 [--stop "<command>"]
QT_QPA_PLATFORM=offscreen python-qgis test_panel_units.py # no service, no network: slider ranges, links, the Python mapping, the assets, the light pad, the panel's order, the Historical mode (a recorded Esri Wayback session, 0.12.4: a source unticked mid-listing, listings stopped and their requests cut, the axis zoom, 0.12.5: the Google Earth banner under the Python backend and its button, the temporal navigation and its steps, the week default and its frame line, the backend control moving to the Historical page, the notices, Planet, HLS, Google Earth from a recorded answer, the toolbar buttons, a layer's symbology), plugins.xml and an update, the building shadows' buildings (a PMTiles archive written by the test, the "Buildings from" choice, a polygon layer written and burnt), a setup kept (0.12.0: Freeze's parameters on the copies, the panel as a link, Save setup and its layers.qlr, Load setup) and the Vector library (0.12.0: which layer each entry becomes, its categories as rules, its attribution, the panel's select)
TERRAIN_VIEWER_SERVICE=http://localhost:3400 QT_QPA_PLATFORM=offscreen python-qgis test_sources.py # network: NRCan's COG, IGN's WMS, a WCS and an ArcGIS service read by the Python backend, the raw inputs, Esri Wayback's dates and tiles, an HLS tile, Google Earth's dates and tiles through that tile service (PLANET_API_KEY: Planet too)
TERRAIN_VIEWER_SERVICE=http://localhost:3400 QT_QPA_PLATFORM=offscreen python-qgis test_temporal_live.py # network: the Temporal Controller under the default week step, Esri Wayback and (with a tile service) Google Earth historical connected from the Historical page: the capture named and drawn at a sample of frames
TERRAIN_VIEWER_SERVICE=http://localhost:3400 QT_QPA_PLATFORM=offscreen python-qgis test_buildings_live.py # network: the building shadows' buildings under both backends (OpenFreeMap, Overture's PMTiles, an address, a polygon layer of the project), compared tile by tile
TERRAIN_VIEWER_SERVICE=http://localhost:3400 QT_QPA_PLATFORM=offscreen python-qgis test_setup_live.py # network (0.12.0): a setup of the Python backend frozen, saved with its GeoTIFFs, its layers.qlr reopened in another project, loaded back; 0.12.2: the same GeoTIFFs under the remote tile server (that address) and the packaged one (when a bundle is installed in the profile, or TV_SERVICE_DIR names one)
QT_QPA_PLATFORM=offscreen python-qgis test_overlays_live.py # network (0.12.0): every entry of the Vector library added through the panel and drawn at its sample place (--no-gdal-pmtiles: the archives through the plugin's own server, as with a GDAL before 3.8)
QT_QPA_PLATFORM=offscreen TV_APP_TEST_OUT=out/app-window.json qgis --noplugins --profiles-path <an empty folder> --code test_app_window.py # inside the application: the toolbar buttons, the Temporal Controller button (Windows: see the file's header)
QT_QPA_PLATFORM=offscreen python-qgis test_plugin.py http://localhost:3400 out/ # the panel against a service: forms, cleanup, both shadows, light, symmetric, previews, links, Freeze--service-bundle needs the root install and tile-server's (tile-server/build.mjs bundles the app's code into generated/ first). It takes Node 22.22.3 from nodejs.org, checked against its SHASUMS256.txt, and installs tile-server's production dependencies flat (node-linker=hoisted: a zip keeps no symlinks) with pnpm's supportedArchitectures set to the platform, so the right @img/sharp-* binaries land; source maps, type declarations and playwright-core are left out. The QGIS plugins workflow (.github/workflows/qgis-plugins.yml, on demand) has two inputs. With service_release_tag (a tile-service-<date> release) it builds each platform's bundle on its own runner, starts it there with smoke_bundled.py, and attaches the five bundles to that release with service_pins.json (their hashes and sizes) and SHA256SUMS; the pins file is then committed back, so the plugin pins the released bundles. With release_tag (a qgis-plugins-<date> release) it builds no bundle: it checks the committed service_pins.json against the release it names (--check-pins), builds the plain zips with those pins inside and attaches them with SHA256SUMS, service_pins.json and plugins.xml (also copied to the fixed release qgis-plugins-repository, updates). Both in one run: the bundles first, then the zips with the new pins. Neither: the bundles are built and started, kept as run artifacts. The service gets a release only when tile-server/ or what the bundle holds changed, so a plugin update usually installs no new service:
# The tile service changed (tile-server/, the app code it bundles, its lockfile, NODE_VERSION in make_zip.py)
gh release create tile-service-<date> -R Iconem/terrain-viewer --prerelease --latest=false \
--title "QGIS: tile service <date>" --notes "The local tile service bundles the QGIS plugin installs"
gh workflow run qgis-plugins.yml -R Iconem/terrain-viewer -f service_release_tag=tile-service-<date>
gh release download tile-service-<date> -R Iconem/terrain-viewer -p service_pins.json \
-D qgis-plugin/iconem_terrain_viewer --clobber # then commit it
# A plugin version (bump metadata.txt first; the committed pins are reused)
gh release create qgis-plugins-<date> -R Iconem/terrain-viewer --prerelease --latest=false --title "QGIS: plugins <date>"
gh workflow run qgis-plugins.yml -R Iconem/terrain-viewer -f release_tag=qgis-plugins-<date>
# Both at once: -f service_release_tag=tile-service-<date> -f release_tag=qgis-plugins-<date>, then commit the pinsThe tests' crash at exit on QGIS 3.44
Up to 0.12.1, test_setup_live.py and test_live.py printed their OK and then ended with an access violation (exit code 0xC0000005, 139 from a POSIX shell) on QGIS 3.44.11, never on 4.2. Found for 0.12.2: the scripts' own teardown, not the plugin.
- Where it died. After
exitQgis()and after Python's exit functions, insidePy_FinalizeEx, on the main thread: a call to address 0 fromgdal313.dll(read with a vectored exception handler that walks the faulting thread's stack). Intest_setup_live.pythe chain isQgsMapCanvas::~QgsMapCanvas›cancelJobs›QgsMapRendererCustomPainterJob::cancel›cleanupJobs›QgsRasterLayerRenderer::~QgsRasterLayerRenderer›QgsRasterPipe::~QgsRasterPipe› GDAL: the script's canvas, deleted by Python as the interpreter ended, still held a render job with a raster layer. Intest_live.pyit is a module's names being cleared ›_gdal.pyd› GDAL: a dataset ofosgeofreed. Both afterexitQgis()had destroyed GDAL's drivers. Whether the canvas still had a job is a matter of timing, hence some runs only. - Why the application cannot do this (QGIS 3.44's source).
QgisApp::~QgisAppdeletes every map canvas and its panels first and ends onQgsApplication::exitQgis(), under the comment "This function MUST be the last one called, as it destroys in particular GDAL". And QGIS never ends the interpreter:QgsPythonUtilsImpl::exitPythonreads// causes segfault! //Py_Finalize();. A Python object a plugin still holds when QGIS quits is never deleted. Before that, closing QGIS unloads the plugins (saveWindowState›unloadAll), which stops the plugin's server and its pools. - The fix is in the tests:
test_teardown.leave(app, code, dock, bridge, canvas)deletes the script's widgets while GDAL is there, callsexitQgis(), runs Python's exit functions and ends the process without finalizing the interpreter, as QGIS does. Everytest_*.pyends through it.TV_TEARDOWN=oldbrings the former ending back. - Measured (2026-11-28, QGIS 3.44.11):
test_setup_live.pywith the former ending (TV_TEARDOWN=old) crashed 2 runs of 10 after its OK, with the new one 0 of 10;test_live.pycrashed 6 of 6 with the former ending, 0 of 6 with the new one. Every run printed its OK. - One thing tightened in the plugin all the same (0.12.2): when the Python backend's server stops (the plugin unloading, QGIS closing), it now also waits, up to 2 s, for the tile requests being answered, after dropping the queued downloads. A building shadows tile is computed with GDAL in the request's thread; before, such a thread could still be working while QGIS tore GDAL down. No crash was seen from it; it is the one place where the plugin's own work could have outlived GDAL.
QGIS 4.2 ending at quit (2026-12-01)
Reported: QGIS 4.2 "ended unexpectedly". Windows' Application log held six crashes of the user's sessions (2026-11-30 15:54 twice, 17:27, 23:07; 2026-12-01 00:16, 01:30), each a session of one to five hours ending a second or two before a new QGIS started, so at quit, when QGIS was restarted to load a plugin just reinstalled. All six were 0xc0000409 in ucrtbase.dll, parameter 7 (FAST_FAIL_FATAL_APP_EXIT: abort()), with an empty %TEMP%\qgis-python-crash-info-<pid> and no minidump kept. A seventh (2026-11-30 13:32, 0xc0000005 in QtCore.pyd) was an agent's headless script, as were the three access violations of 2026-12-01 11:12 to 11:17 (a screenshot script ending on QgsApplication.exit(0): QGIS's own crash in QgisApp::layerTreeInsertionPoint while it removes the project's layers after its layer tree view, nothing of the plugin's).
- What the signature says. QGIS enables faulthandler on that file at start, and faulthandler writes there on a SIGABRT (
Fatal Python error: Aborted). An empty file with anabort()means faulthandler had been turned off first, which is whatPy_FatalErrordoes before it aborts. In QGIS 4.2, PyQt6 callsPy_FatalError("Unhandled Python exception")(inQtCore.pyd) when a Python slot or callback raises whilesys.excepthookis Python's own; QGIS installs its hook at start (errors go to the message log) and puts Python's back when it quits (qgis.utils.uninstallErrorHook, fromQgsPythonUtilsImpl::exitPython). - The order at quit (QGIS 4.2, logged from a throwaway profile): the project cleared, the plugins'
unload(),aboutToQuit, the panel deleted, then Python's excepthook back, then the canvas, the project cleared again, the main window; Python itself is never finalized (atexitnever runs). - What of the plugin ran after that, up to 0.12.6: a profiler set on every thread once the excepthook was back showed the Historical listing's threads (
terrain-viewer-historicaland itsThreadPoolExecutorworkers) still running Python when QGIS was quit mid-listing:unload()aborted the listing but never waited for it. And two kinds of callbacks could still be called: the panel's requests (/healthevery 15 s,plugins.xml), whosefinishedclosures Qt keeps connected after the panel is gone, and the canvas'srenderStartingandmapCanvasRefreshed, never disconnected; the Buildings from row never disconnected its project signals. - Not reproduced. Thirty-odd quits and reloads (Python backend and packaged tile server, Esri Wayback with Google Earth mid-listing or listed, the plugin's files replaced by another version while QGIS ran,
qgis.utils.reloadPlugin) all ended cleanly, so the cause is the likeliest one, not a proven one. The same sessions ran other plugins (QuickMapServices, qgis_leafmap and its update-checker thread, the MapTiler plugin, QDuckDB, qpip, OSMInfo), any of which could raise in that window too. - What changed (2026-12-01).
unload()cleans the panel up first: the listing stopped and its threads waited for (3 s at most:HistoricalPanel.join_workers,STOP_WAIT_S; a request still connecting is not cut by itsAbortand ends at its timeout, in plain Python), the requests still out disconnected and aborted, a tile service download cancelled, the canvas's and the project's signals disconnected (the panel's and the Buildings from row's); then the local tile service and the Python backend's server stop; then the buttons, their signals disconnected and the actions deleted (a reload used to leave the old ones in the main window). Checked bypanel_teardown_checks.py, run last bytest_panel_units.py: a listing whose request is answered half a second intocleanup()and a/healthrequest to a server that never answers, both gone whencleanup()returns (both checks fail on 0.12.6's code). In QGIS itself, quitting mid-listing, the profiler sees no plugin code after the excepthook is back.
Design history
Before the plugins, QGIS got the app's modes only through the tile service's /qgis.qgz: a project with every mode as an XYZ layer, configured as a view was. A layer's settings lived in its address, and QGIS has no control bound to an XYZ address's parameters, so changing a ramp or a radius meant editing the layer's source URL. A plugin was the way to have controls. The plan (2026-11-23) had two steps, the first cheap:
- A panel that writes tile service layers: written on 2026-11-23; Freeze came in 0.2.0, the "Terrain Viewer (live)" group in 0.2.1, and 0.2.2, the first release (2026-11-24), requires
/processes. 0.3.0 (2026-11-25) shipped the tile service inside four platform zips of 48 to 60 MB, 0.4.0 made it off by default and dropped the browser engine, and 0.5.0 (the same day) went back to one plain 50 KB zip with the service downloaded by the Install button. - The modes computed in QGIS, with no tile service: the experimental local compute (0.5.0, 16 modes since 0.6.0), below.
Step 2 as planned
The plan for step 2, kept for reference; what was built and measured is on QGIS Live Compute.
- Reading: GDAL reads the tiles and nothing else. A Terrarium or Terrain-RGB pyramid through GDAL's WMS/TMS driver (the XML of
gdalTileSourceinlib/terrain-tile-spec.ts), a COG or VRT directly, a raw WMS through GDAL's WMS driver. Decoding the RGB packing into metres is numpy (the formulas oflib/elevation-encoding.ts). The sources only the app's protocols read (LERC, quantized mesh, GEM-15's cells, a difference) need their own reader or stay on step 1. - Computing: numpy, not
gdaldem: the app's modes are its own (LRM, sky view factor, openness, matcap, Phong, the mound detector, the eigen-based ones), and the point is that QGIS shows what the app shows. Eachlib/*-protocol.tsis a kernel over an elevation grid with a margin, which ports to numpy array code: slope, aspect, curvature, TPI, TRI and roughness in a few lines each; sky view factor and openness as the app's ray sweeps (vectorised per direction); matcap and Phong as the shaders' formulas per pixel; the color ramps fromlib/color-ramps.ts. - Delivery: a QGIS raster layer per mode, computed for the canvas extent at the canvas resolution and recomputed on pan and zoom (debounced, in a background task), or written to a GeoTIFF on request. Optionally a Processing provider, so each mode is also an algorithm for models and batch runs.
- Checking: the port is checked against the app tile by tile, as
tile-server/compare-engines.mjschecks the direct engine against the browser: same tiles, a table of differences. - Keeping in step: two implementations of each mode drift. The comparison above runs in CI on a fixed set of tiles, so a change to a protocol that the Python port does not follow fails a check.
Where it stands (0.7.0: the Python backend is one of the panel's three, under the same modes tree): reading through GDAL, the numpy kernels, delivery as Float32 values GDAL reads (so QGIS's own color ramps apply) or as colored tiles, and the tile-by-tile check are done for 16 modes, Phong and matcap included, plus contour lines as a vector layer per view (qgis-plugin/test_live.py, against the app's kernels in Node, the tile service and gdaldem). Not done: the comparison in CI, the Processing provider, and the modes that need a whole view (the mound detector, local dominance, the eigen-based ones); for those, the tile service layers stay the way in.
QGIS Live Compute
Terrain modes computed inside QGIS with numpy, no tile service - all 25 of the app's modes, the mound detector included, colored as the tile service colors them (the app's ramps and every ramp, hillshade, Phong and contour setting), from any elevation GDAL opens (a QGIS raster layer, a local COG or VRT, /vsicurl/, WCS) or a tile pyramid; checked against the app's kernels, the tile service and gdaldem; how QGIS picks tile zooms and resamples; numpy, numba, cupy and the tile service compared.
Tile service
What the app draws, served as XYZ tiles and as pictures of a viewport over HTTP, from a Docker image; its addresses and parameters browsed with Scalar