Skip to content

Picking by ids on one path for the page and the native app, a picked feature's properties read from its tile - #653

Merged
graffkevin merged 12 commits into
mainfrom
vector-tiles-picking
Dec 4, 2026
Merged

graffkevin merged 12 commits into
mainfrom
vector-tiles-picking

Conversation

@graffkevin

Copy link
Copy Markdown
Collaborator

Slice 5, part 3 of the migration: picking by ids, one path for the page and the native app, on wgpu and Metal.

  • One picking path in isard-graphic-engine::renderer::picking: the block around the cursor (moved from the legacy core), at most 8 requests in flight, the pass begun through isard_rhi::encode::Commands and its pixels read back through the GPU's memory on both backends. Metal's own picking pass and its synchronous read-back are gone; wgpu's choice of layers, numbering and CPU fallback moved to isard_engine::map::Map, shared by both.
  • Fixed: a picked vector tile feature could be another one. The numbering of the features was computed again at each frame while the answer comes a frame or two later; a tile loaded or let go meanwhile shifted the numbers. Each request now keeps the numbering of the frame that drew it, and a hit is { layer, node, index }.
  • Properties read from the tile's own bytes, as MapLibre does (decided 29 November): the source tile's MVT bytes handed to the engine once per source tile, the touched feature read alone by the one MVT reader (isard-layers::vector_tiles::pick, mvt::decode_one_feature). The worker no longer copies a properties object per feature, the page no longer keeps them.
  • Native app: hover and click picking (apps/native/src/app/picking.rs), --pick X,Y with --screenshot for a scripted check; wgpu and Metal pick the same building at the same point.
  • Fills picked on the CPU in isard-graphic-engine::scene::shapes::pick, moved from the legacy core.
  • One scissor in isard-rhi (scissor_within), for a layer's columns and the picking block alike.
  • Contract: tests/fixtures/vector-pick.json, 30 points of vector-3d and vector with the feature pickFeature gives, recorded and checked against main's build; bun run test:pick runs it, in bun run check --visual and on the first visual runner of the CI.

The engine's picking API added to the legacy engine (set_vector_tile_features, has_vector_tile_source, pick_slots, pick_numbering, picked, vector_feature and their wasm exports) moves to the target with the next part of slice 5, the vector tiles layer declared in Rust.

Performance

bun run perf:main on a quiet machine: no path slower. Turning a hit into its feature, alternated on vector-3d (under load): 8.67 µs on main, 8.80 and 8.53 µs on the branch.

example metric main branch diff noise verdict
vector-3d fps 60 60 0 3 within noise
vector-3d frame p95 (ms) 16.8 16.7 -0.1 0.5 within noise
vector-3d worst frame (ms) 17 17 0 17 within noise
vector-3d long tasks 0 0 0 2 within noise
vector-3d long tasks time (ms) 0 0 0 100 within noise
vector-3d heap (MB) 40 39 -1 30 within noise
vector-3d draws/frame 632 632 0 10 within noise
vector-3d main thread (ms/frame) 1.6 1.6 0.0 0.5 within noise
vector-3d frames left alone 0 0 0 5 within noise
vector-night fps 60 60 0 3 within noise
vector-night frame p95 (ms) 16.8 16.7 -0.1 0.5 within noise
vector-night worst frame (ms) 17 25 +8 17 within noise
vector-night long tasks 0 0 0 2 within noise
vector-night long tasks time (ms) 0 0 0 100 within noise
vector-night heap (MB) 127 127 -1 30 within noise
vector-night draws/frame 1062 1063 +1 10 within noise
vector-night main thread (ms/frame) 3.5 3.5 0.0 0.5 within noise
vector-night frames left alone 0 0 0 5 within noise
react/vector-3d fps 60 60 0 3 within noise
react/vector-3d frame p95 (ms) 16.8 16.7 -0.1 0.5 within noise
react/vector-3d worst frame (ms) 17 17 0 17 within noise
react/vector-3d long tasks 0 0 0 2 within noise
react/vector-3d long tasks time (ms) 0 0 0 100 within noise
react/vector-3d heap (MB) 42 40 -2 30 within noise
react/vector-3d draws/frame 654 655 +1 10 within noise
react/vector-3d main thread (ms/frame) 1.6 1.6 0.0 0.5 within noise
react/vector-3d frames left alone 0 0 0 5 within noise
wind fps 60 60 0 3 within noise
wind frame p95 (ms) 16.7 16.8 +0.1 0.5 within noise
wind worst frame (ms) 17 17 0 17 within noise
wind long tasks 0 0 0 2 within noise
wind long tasks time (ms) 0 0 0 100 within noise
wind heap (MB) 15 15 0 30 within noise
wind draws/frame 5 5 0 10 within noise
wind main thread (ms/frame) 0.9 0.9 0.0 0.5 within noise
wind frames left alone 181 180 -1 5 within noise
wind-streets fps 60 60 0 3 within noise
wind-streets frame p95 (ms) 16.7 16.8 +0.1 0.5 within noise
wind-streets worst frame (ms) 17 17 0 17 within noise
wind-streets long tasks 0 0 0 2 within noise
wind-streets long tasks time (ms) 0 0 0 100 within noise
wind-streets heap (MB) 25 24 -1 30 within noise
wind-streets draws/frame 464 464 0 10 within noise
wind-streets main thread (ms/frame) 1.5 1.5 0.0 0.5 within noise
wind-streets frames left alone 181 181 0 5 within noise
wind-streets frames zoomed out 26 26 0 51 within noise

…mbered as the pass was drawn

The picking answer names the tile and the feature's index there, from the numbering kept with each request
(isard-graphic-engine renderer::picking, which now holds the block of pixels and the request queue). The engine keeps
each source tile's MVT bytes with its tiles and reads the picked feature with the Rust MVT reader; the workers no
longer copy a properties object per styled feature to the page. A characterization fixture of pickFeature on the
vector and vector-3d examples (tests/fixtures/vector-pick.json, scripts/test/vector-pick-fixture.ts) passes on main
and on this branch.
…ytes come once per source tile

The MVT reader reads one feature of one layer without decoding the others (decode_one_feature): turning a hit into
its feature costs what it did before the bytes were kept engine-side. The engine keeps a source tile by its level,
column and row; the page asks the workers for its bytes only while the engine does not keep them.
…, moved from the legacy core

prism_range takes the body's relief range rather than the body: the technique crate does not know isard-geodesy.
…rhi's Commands

isard-graphic-engine's renderer::picking makes the picking target (Target) and begins the pass into it, clipped to the
block around the cursor (draw_pass, RenderPass::clip); both backends then ask its pixels of the GPU's memory and take
them once read back. Metal's own pass and synchronous read back are gone; wgpu's legacy layers still draw their picking
on wgpu's own pass, reached through WgpuPass::raw (#501).
…the same picking pass

The native app asks what is under the pointer as the page does: the map asked at once, the answer read back a frame
or two later, the hovered feature printed when it changes and the clicked one on each click (--pick X,Y prints it
with --screenshot). Metal draws the pass after the next frame with that frame's lists. The buildings give the engine
their source tile's bytes once per source tile, which the picked feature's properties are read from. Which layers a
pass draws, their numbering and the fallback to the fills picked on the CPU move to isard-engine's Map, shared by both
backends; the styled features' column the picking reads is StyledTile::sources, shared with the vector tiles module.
… the picking contract checked in CI, the crates' READMEs naming picking
@graffkevin
graffkevin merged commit d8df347 into main Dec 4, 2026
9 checks passed
@graffkevin
graffkevin deleted the vector-tiles-picking branch December 4, 2026 19:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant