Spike: Galileo OSM basemap integration#273
Draft
frewsxcv wants to merge 3 commits into
Draft
Conversation
New workspace crate that renders an OpenStreetMap basemap via Galileo into an offscreen wgpu texture, then displays the RGBA bytes as a Bevy sprite that tracks the rgis Camera2d. Gated to native targets only since Galileo pulls tokio and a separate wgpu 29 runtime. Architecture: a dedicated OS worker thread owns both the tokio runtime and Galileo's WgpuRenderer for its entire lifetime, so the main Bevy thread never touches them. The plugin communicates with the worker via std::sync::mpsc request/response channels, coalescing backlog in the worker so rapid camera moves don't queue stale renders. The main thread drains responses non-blockingly each Update. Release-mode build is currently blocked by two pre-existing/ecosystem issues (geo-bevy trait-solver overflow on stable; pathfinder_simd 0.5.5 broken on recent nightly via galileo->font-kit). Debug mode works end-to-end.
- Patch pathfinder_simd to PaulWagener's fork that renames simd_fmin/ simd_fmax to the new intrinsic names (servo/pathfinder#584 / rust-lang#154043). - Replace Bevy image handle in-place via images.insert() instead of swapping to a fresh handle each render — handle swap races Bevy 0.18's asset extraction under release-mode parallelism, so the sprite never saw the new texture.
Removes pieces that were only there for spike validation, not the integration: - demo_jump_to_nyc system that teleported the camera between NYC and Paris - debug_dump_png side-output to /tmp and the image crate dep that fed it - src/main.rs standalone binary from before the plugin was wired into rgis - per-frame info! logging on the main thread and worker lifecycle logs
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.
Summary
rgis-basemap-spikethat renders an OpenStreetMap basemap via Galileo into an offscreen wgpu texture and displays the RGBA bytes as a Bevy sprite tracking the rgisCamera2d.#[cfg(not(target_arch = "wasm32"))]). wasm is deliberately out of scope for this spike.Architecture
WgpuRendererfor its entire lifetime. The main Bevy thread never touches either.std::sync::mpscrequest/response channels. The worker drains its request backlog before each render (coalescing rapid camera moves to only honor the newest).refresh_basemapsystem eachUpdate:RenderResponses withtry_recv(latest wins) and replaces the sprite'sImageasset in-place viaimages.insert(&handle, new_image). (An earlier version swapped to a fresh handle, which works in debug but races Bevy's asset extraction in release mode — keeping the handle identity stable fixes it.)Camera2dtransform; if it has zoomed pastSCALE_DELTAor panned pastPAN_DELTAof the last rendered texture's half-width, queues a new render request (respectingin_flight+REFRESH_DEBOUNCE).BASEMAP_Z = -0.05— just inside Bevy 2D's default visible z range ([-0.1, 1999.9]with the camera atz=999.9) so rgis layers atz≥0still draw on top.demo_jump_to_nycsystem teleports the camera to NYC on frame 1 and Paris on frame 240 so you can see the basemap swap in without needing to click anything. Remove before this graduates to real code.Release-mode fixes
Getting this working in release required two fixes landed in this branch:
geo-bevy(pre-existing in main; CI only builds desktop in debug so it's never been surfaced). Workaround: nightly withRUSTFLAGS="-Zinline-mir=no"(same workaround the WASM CI build already uses).pathfinder_simd 0.5.5(via galileo → font-kit) uses nightly intrinsicssimd_fmin/simd_fmaxthat were renamed in simd_fmin/fmax: make semantics and name consistent with scalar intrinsics rust-lang/rust#154043. Crate is dead with no newer version. Worked around with a[patch.crates-io]entry pointing at PaulWagener/pathfinder which renames the intrinsics. This is a temporary hack — upstream (simd_fmin/fmax renamed breaking ARM builds in the future servo/pathfinder#584) needs a real fix.Build command:
RUSTFLAGS="-Zinline-mir=no" cargo +nightly build -p rgis --releaseKnown limitations / TBD
get_image()→ RGBA bytes → BevyImage) which works but is wasteful.RasterTileLayeris reconstructed on every render inside the worker. A real integration should keep it alive and just update theMapView.demo_jump_to_nycshould be deleted before merging.pathfinder_simdpatch is a temporary hack pending an upstream fix.Test plan
cargo build -p rgisRUSTFLAGS="-Zinline-mir=no" cargo +nightly build -p rgis --release/tmp/rgis-basemap-latest.pnggets written on every render for visual verification