Skip to content

Zooming over a projected raster stutters: mid-motion frames on the UI thread, single-threaded upscale and reprojection grid #1792

Closed

Description

@pick2510

The problem

Zooming in and out over a projected raster stutters on the desktop app. It shows from about zoom 17, where the raster fills the view, and is worse on HiDPI screens.

To reproduce: load one swissALTI3D tile (swissalti3d_2026_2696-1261_0.5_2056_5728.tif) and zoom in and out between zoom 15 and 20. The tile is:

  • a 2000 × 2000 Float32 COG (128-pixel tiles, LZW, 8 overviews);
  • in EPSG:2056, so it is reprojected to Web Mercator;
  • 16 MB, held in memory, so nothing is read while zooming.

The test machine runs GNOME on Wayland at 150 % scaling, with 20 cores. The app is main at f22d9bb, which includes #1775.

Why

#1775 moved the frame drawn once the map settles off the UI thread. While the map moves, the view still redraws a frame inline on the UI thread (crates/ui-egui/src/mapview.rs, the motion frames). It does so every 10 % of zoom (MOTION_STRETCH), and at once to fill a gap when zooming out (GAP_SPAN).

With this raster, each such frame blocks the window for two or three display frames.

Measured

rustgis_render::render of the tile alone, in a 1600 × 1000 logical view at zoom 18 to 20:

Display scale Frame Raster draw Upscale to screen Reprojection grid Pass 1 + pass 2
1× ~20 ms ~18 ms none 6.6 ms ~9 ms
1.5× ~45 ms ~40 ms ~24 ms 6.6 ms ~9 ms
2× ~60 ms ~56 ms ~41 ms 6.6 ms ~9 ms
  • Upscale. On a screen of 1.5× or more, raster::draw_with computes the raster at logical resolution, then scales it up with tiny-skia's draw_pixmap (bilinear), which runs on one thread. That step is half to two thirds of the frame. At 1× a plain multi-threaded copy (blend_over) is used instead.
  • Reprojection grid. The exact source positions (one every 8 px, about 25,000 LV95 transforms) are computed on one thread. Passes 1 and 2 already use every core.
  • Device resolution. Computing at device resolution instead isn't faster: 46 ms at 1.5× and 75 ms at 2×, because the single-threaded grid grows with it.

Plan

  1. Scale the work image up on several threads (parallel helpers, the user's thread count), the same bilinear or nearest filter as now, so the output matches tiny-skia's to within rounding.
  2. Compute the reprojection grid's rows on several threads, giving the same positions as one thread.
  3. Draw the frames shown while the map moves on the worker UI: draw a flat map's settled frame off the UI thread (#1750) #1775 uses, keeping the stretched frame on screen until the new one lands. This removes the hitch for any slow layer, not only rasters. Done in UI: draw a moving flat map's frames off the UI thread #1791 (part of Smooth panning and zooming with detailed layers: off-thread frames, shape-aware thinning, outline levels #1750), so it's no longer part of this issue.

Items 1 and 2 should bring this frame to about 15 ms at 1.5×.

Activity

  1. self-assigned this
    on Nov 11, 2026
  2. pick2510 commented on Nov 11, 2026

    @pick2510
    ContributorAuthor

    I'm working on this: items 1 and 2 first (a draft pull request soon), then 3.

  3. pick2510 commented on Nov 11, 2026

    @pick2510
    ContributorAuthor

    Item 3 is #1791 (draws a moving flat map's frames off the UI thread), so this issue now covers items 1 and 2: the multi-threaded upscale and reprojection grid. With #1791 they make the worker's frames for such a raster land in about a third of the time, and the settled frame and exports benefit too.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions