Repository navigation
Description
Panning and zooming a map with a detailed polygon layer feels laggy in the desktop app. Found with the 1:10m worldview borders in #1748 (548k vertices, against 10.6k for the built-in 1:110m countries); QGIS and ArcGIS Pro stay smooth with data that size. This issue tracks three changes, smallest first, each its own PR.
What's measured
The World Atlas sample with the default worldview at the Original detail (#1748), rendered on the CPU path at 1480×900 and 1× pixel density, caches warm, panning a little between frames:
| View | Simplified (1:110m) | Original (1:10m) |
|---|---|---|
| World | 16 ms | 101 ms |
| Europe | 9 ms | 52 ms |
| City | 2 ms | 10 ms |
At world zoom the Original frame splits about evenly: the basemap's world outline about 53 ms, the Countries layer about 47 ms (fills ~25, strokes ~15, labels ~8).
Why it lags
- The exact frame is drawn on the UI thread.
crates/ui-egui/src/mapview.rsalready shows the last frame shifted and scaled during a pan or zoom, but about 0.18 s after the motion stops it draws the exact frame synchronously (rustgis_engine::render::render), so the window freezes for the whole render. Scroll-wheel zooming stops and starts often, so it hits that freeze repeatedly. On a 2× display the frame has four times the pixels. - Thinning keeps too much of a detailed coastline.
crates/map/src/lod.rskeeps a vertex once it's about a device pixel from the last one kept (distance thinning, [Feature]: Thin geometry to about a pixel, before projecting it #1066). On 1:10m borders that keeps 194k of 548k vertices at world zoom and 373k for Europe. Douglas–Peucker at the same tolerance keeps 26k and 92k (measured with Shapely on the same data). - The basemap's world outline has no levels of detail. Every basemap draws the land outline (
world()incrates/render/src/lib.rs) from the full countries geometry each frame. It's culled per country only, so Russia's whole outline is walked even zoomed in on Europe. With a detailed worldview, the outline alone costs as much as the Countries layer.
How QGIS and ArcGIS Pro avoid it
- Drawing off the UI thread: QGIS renders in cancellable background jobs (
QgsMapRendererParallelJob), shows the previous image while one runs, and keeps a per-layer image cache. ArcGIS Pro draws asynchronously and multi-threaded, with a local display cache. - Simplifying for display: QGIS simplifies on the fly by default (1 px threshold; distance, snap-to-grid or Visvalingam). ArcGIS Pro and feature services generalize per zoom (quantization, maximum allowable offset).
- GPU drawing: ArcGIS Pro keeps features on the GPU, so panning moves the camera instead of redrawing. RustGIS's GPU backend (beta) works this way but isn't the default path.
- Pre-generalized basemaps: both use tiles simplified per zoom level, never raw 1:10m borders at world zoom.
Plan
- Basemap outline levels. (Render: draw a detailed world outline from levels of detail (#1750) #1769) Build the world outline at zoom-dependent levels, simplified with Douglas–Peucker, once per worldview off the UI thread, and draw the level for the view. Scoped to the worldview work in feat(map): download any of Natural Earth's 31 worldviews when chosen #1748. Expected: about half the Original frame at world zoom.
- Shape-aware display thinning. (Map: thin detailed layers with Douglas–Peucker (#1750) #1774) Replace (or add beside) the distance thinning in
crates/map/src/lod.rswith Douglas–Peucker or Visvalingam, keeping the error under a device pixel. Speeds up every detailed layer. [Feature]: Thin geometry to about a pixel, before projecting it #1066's alternatives section weighed this against distance thinning on cost per vertex; a render-comparison test (thinned against full, at several zooms) and the [Feature]: Draw the outlines of tiny polygons cheaply, or skip them #1064 benchmark should decide. - Draw the exact frame off the UI thread. (UI: draw a flat map's settled frame off the UI thread (#1750) #1775) Render the settled frame on a background thread, cancellable when the camera moves again, keep showing the shifted last frame meanwhile, and swap the new frame in when it lands. Needs a decision on how the map view and the session share the map while a render runs (a snapshot of the
Map, or a read lock), and the browser (one thread) keeps rendering inline. This is the change that keeps the window smooth whatever the data; [Feature]: Draw a heavy layer on several CPU cores #1067 (several cores per layer) builds on it.
Related: #1066 (1 px distance thinning), #1067 (drawing a heavy layer on several cores), #1748 (worldviews at original detail).
Activity
fix(render): review fixes for the world outline levels (#1750)
fix(render): read the worldview once a frame for the outline (#1750)
perf(map): time the cold frame only where it builds the level (#1750)
perf(render): build the outline levels on several threads (#1750)
perf(map): thin detailed layers with Douglas-Peucker (#1750)
perf(map): time the first frame at each zoom in worldview_bench (#1750)
perf(map): time the cold frame only where it builds the level (#1750)
fix(map): a ring with no area keeps four vertices, not all (#1750)
fix(render): stop a frame between streamed chunks, before its labels (#…
fix(render): outline level review notes (#1750)
docs(map): reflow simplify's doc (#1750)
test(render): a simplified outline part keeps its extent exactly (#1750)
fix(ui): a frame is cancelled only if it came back without a picture (#…
test(map): cover the triangle floor's growth from two extremes (#1750)
fix(ui, render): stop tilted frames between bands; draw a failed flat…
Render: draw a detailed world outline from levels of detail (#1769)
fix(render, ui): look at a stop by vertices too; after a tilted frame…
docs(map): a ring with no area keeps two vertices, one repeated (#1750)
docs(map): rewrap simplify's doc (#1750)
Map: thin detailed layers with Douglas–Peucker (#1774)
fix(render): skip a stopped chunk's labels; stop after the GPU band l…
UI: draw a flat map's settled frame off the UI thread (#1775)
giswqs commentedon Nov 11, 2026
Done in three PRs: #1769 (world outline levels of detail, the 1:10m outline at world zoom 52 to 17 ms), #1774 (Douglas–Peucker display thinning, the 1:10m Countries layer 48 to 27 ms at world zoom), #1775 (a flat map's settled frame drawn on a worker and stopped when the map moves again; the longest UI frame after a pan went from 30 to 51 ms to under 2.5 ms). With the 1:10m worldview the whole world frame is 43 ms against 102 ms before (CPU, 1480×900).
perf(ui): hold a slow map's mid-motion frames on the UI thread; revie…
UI: draw a moving flat map's frames off the UI thread (#1791)
perf(canvas): on a software rasterizer a frame drawn mid-motion costs…