Repository navigation
The vector tiles layer held in Rust: style, rules, tasks and restyle on one path for the page and the native app, its API generated - #656
Merged
Conversation
The style and its vector source's TileJSON are loaded by `isard_layers::maplibre_style::load` through the `Fetch` port, once for the page (the module function `loadVectorStyle`, reached through `engineBindings()`) and the native app (`loaded_style`), instead of the SDK's `loadStyle`/`resolveSource`/`fetchTileJson` and the native app's `TILEJSON`/`tile_template`. Archived sources (`pmtiles://`, `mbtiles://`) are still read by the page through the `Archives` callback until their slice. Checked against `tests/fixtures/vector-style-sources.json`, recorded on the TypeScript loader (`maplibre_style_load.rs`); the SDK's tests give `VectorTiles` their own loader. The style's JSON reader and writer take runs of plain text whole (parse 0.19 -> 0.10 ms, write 0.13 -> 0.05 ms for Positron, native, under load).
…cript sublayers tests/fixtures/vector-layer-rules.json: for each style layer vectors() draws in Positron, Liberty, PLAN IGN grey and the closed network's style, its kind, zoom range, visibility, opacity, patterns and glow, and at six zooms its caps, joins, miter limit, translation and dashes, as the SDK's sublayer (extracted from vectors() for it) gives them; recorded by scripts/test/vector-layer-rules-fixture.ts, which leaves with the TypeScript rules.
…step 2; the engine, the SDK and the native app not switched yet) isard_data::style::layer: LayerRule (kind, zoom range, visibility, opacity, caps, joins, miter limit, translation, patterns, glow, dashes; the values of the zoom as ZoomCurve) and LayerRule::at, a style layer's values at the frame's zoom. isard_layers::maplibre_style::rule reads a style layer's JSON into its rule, its expressions sampled at Expression::zoom_stops (interpolate and step stops, whole zooms between). Checked against tests/fixtures/vector-layer-rules.json (maplibre_style_rules.rs); the TypeScript sublayer, setVectorSublayers and the legacy Sublayer still draw.
…ow the frame's zoom, for the page and the native app The page hands the style layers it draws to the engine as they are (setVectorStyleLayers(id, layersJson, lit)), with whether the layer shows and is draped (setVectorLayerShown); the engine reads them into LayerRule (isard_layers::vector_tiles::rules, maplibre_style::rule) and evaluates them at each frame's zoom, so caps, joins, translations, dashes and a zoom-dependent opacity follow the camera instead of being sent again every tenth of a level. Which lines glow at night is the engine's (is_street, the default of `streets`); isStreet asks it. Deleted: setVectorSublayers and its eleven arrays, legacy Sublayer, SublayerArrays and parse (vector_layer.rs, its translation and range helpers moved to isard_graphic_engine::scene::sublayers), the TypeScript sublayer, dashes, lineCap, lineJoin, miterLimit, translation, followsZoom, ZOOM_STEP, followZoom, VectorSublayer and the rules fixture's generator. VectorLayer.layers gives the style layers drawn. The engine's wasm budget raised to 973 KB.
… the frame's budget, for the page and the native app The basemap worker packs the tile it prepared into one buffer (isard_layers::vector_tiles::packed), the page hands it over as it is (vectorTileArrived) and the engine installs the tiles waiting right after the frame opens its upload budget, one at least a frame, a tile whose source bytes were let go asked for again there; the native application's threads pack theirs and hand them over the same way. Deleted: the page's upload queue and its UPLOAD_MS, setVectorTileMesh, setVectorTileFeatures, setVectorTilePoints, the engine API's TileMesh, the worker's per-array layout (preparedVectorTileArrays) and the native MapTarget's mesh, styles and features methods.
… a restyle restyled once, React Native's methods regenerated
The page draws a frame only when asked: since the vector tiles are installed in the engine's frame, those left in its queue past the budget waited until something else asked for a frame, and the map could stop with tiles not drawn (vector-night: buildings and streets missing, labels behind them shown).
… style broadcast once to the workers and the native threads The engine starts each vector tile's task itself after the frame (isard-system ports::tasks: the page's basemap workers, native threads), the layer's style broadcast once per version and each task naming its tile and that version (isard_layers::vector_tiles::task, one function for the workers and the threads). The source tile's bytes travel inside the packed tile. Removes VectorTileLoader, setVectorTileLoader, send_vector_tile_work, take_vector_tile_work, hasVectorTileSource, the vectors renderer in the workers, VectorStyle, VectorTileAt, prepareVectorTile, styleVectorTile and the native application's own threads. Work in progress: the SDK tests of the vectors layer and of the worker's vectors job still drive the former loader.
…ir results installed from the next frame, a tile arriving during a restyle restyled once, docs and React Native's methods
… asks of the tiles, their styles evaluated again by tasks of the Tasks port, the page keeping neither its tiles nor their inputs
…its settings and style properties with their getters, its companions behind a class written by hand, a tile in flight during a restyle restyled on arrival The layer pattern of isard's targets (a class made by another object, without data): VectorsOptions, setFacades/getFacades, setDrape/getDrape, set/getPaintProperty and set/getLayoutProperty kept by the facade and replayed on a new engine; VectorLayerCompanionsApi (host) for the draped raster, the 3D buildings and the page's side of the tasks. getStyle(), getTileKeys(), getBuildings3d() replace layers, tileKeys and the buildings3d field; map.addVectorLayer gone.
…, read by the layers crate and generated as the SDK's constants
…yer: a basemap by name and the style layers its options keep, the layer read from the style, its threads running the workers' steps, the overzoom level once in the engine
…or the layer's style input, companions.ts, the vector fixtures in the layers crate's data, the style layers' anchoring in isard-layers, the READMEs and docs of the vector tiles layer
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Slice 5, part 4 of the migration (steps 1 to 6): the vector tiles layer held in Rust, its style loaded, its tiles asked for, prepared and restyled through one path on the page and in the native app, its API generated by wasm-facade.
isard-layers::maplibre_style::load, through theFetchport): the style, its TileJSON and raster sources loaded once for the page and the native app; the TS loader and the native app's hard-coded TileJSON gone. Characterization:crates/domain/layers/data/vector-style-sources.json, recorded from the old TS loader (12 cases).isard-data::style::layer,maplibre_style::rule): the engine reads the style layers once and evaluates them at each frame's zoom (caps, joins, translations, dashes, opacity by zoom); the page no longer resends eleven arrays every 0.1 zoom. Streets that glow at night found by thestreetsoption's default in Rust. Characterization:vector-layer-rules.json, recorded from the old TS rules (4 styles × 6 zooms).vector_tiles::packed): one wasm call per tile instead of four, read without a copy; queued tiles installed withinUPLOAD_MS, the engine asking for a frame while tiles wait.Tasksport (isard-system::ports::tasks,native::threads): the engine dispatches the tiles' preparation itself, to the page's workers or native threads, with one task function (vector_tiles::task) for both; the style broadcast once with a version (as MapLibre'ssetLayers). A task carries input bytes and an affinity key; it has no kind field: one host per kind of task and layer stands for it (a change to the 28 November wording, recorded intarget.md).vector_tiles::layer):setPaintProperty/setLayoutProperty(JSON values,nullback to the default, as MapLibre) decide whether rules, a cut or a restyle task is needed; a tile in flight is restyled on arrival.VectorLayerdeclared in Rust (vector_tiles/api.rs) and generated (TS, React, Python, React Native, web component); the known styles and credits in one data file (crates/domain/layers/data/vector-styles.json).vectors(), its own threads and TileJSON code gone.API changes (CHANGELOG, Changed):
layer.layers→layer.getStyle().layers,layer.tileKeys→layer.getTileKeys(),layer.buildings3d→layer.getBuildings3d();VectorSublayerandmap.addVectorLayerremoved;getPaintProperty,getLayoutPropertyadded;isStreetneeds a loaded engine.The wiring added to the legacy engine (
legacy/crates/engine/src/vector_tiles.rs: dispatch, restyle, install) moves to the renderer's frame steps andstreamingwith step 7 of this part, and toisard-mapwith slice 8. Step 7 (the tiles' GPU content in the graphic engine) follows in its own PR.Performance
bun run perf:mainon a quiet machine: no path slower. Two one-time costs accepted: a style load ~0.2 ms longer (read in Rust, written back, read by the page; one loader instead of two), the engine's wasm compile and instantiate ~3 ms longer (the style expression compiler linked into the engine; first image unchanged). Rule evaluation per frame: 0.5 µs (Positron) to 4.7 µs (PLAN IGN, 274 layers). Engine wasm 934.8 KB gzip (budget 894 → 973).