Repository navigation
fix(tiles): say when a tile layer's server has none of the tiles in view #3264
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
11c5719
e89ca6a
fad16c2
19da512
98ef483
a7d4abf
9d633ab
e00b23a
57f84fa
e632185
a3ab9c4
79e9e6f
538f680
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -912,6 +912,34 @@ mod tests { | |
| assert_eq!(opacities(&scene), vec![100], "the raster, the squares and the points in one picture"); | ||
| } | ||
|
|
||
| /// Drawing again gives no more of a tile layer whose server has none of its tiles in view, so a | ||
| /// frame with one is kept: restyling a layer over it draws that layer, and the layer is still said. | ||
| #[test] | ||
| fn a_frame_with_a_tile_layer_without_a_tile_in_view_is_kept() { | ||
| let (mut map, view, _, above) = map(); | ||
| crate::tiles::tests::serve(); | ||
| map.tiles.push(rustgis_map::TileLayer::new("Gone", rustgis_map::TileKind::Raster, "https://tiles.test/gone/kept/{z}/{x}/{y}.png")); | ||
| crate::render_complete(&mut map, &view).expect("drawn"); | ||
| // Another test's tiles landing meanwhile rightly draw the frame whole: a drag they fell | ||
| // in is done again. | ||
| let mut started = None; | ||
| for drag in 0..50u8 { | ||
| let before = rustgis_tiles::cache::generation(); | ||
| for step in 0..4u8 { | ||
| if let Some(l) = map.layer_mut(above) { | ||
| l.renderer = Renderer::Single(rustgis_map::Symbol { fill: Rgba::rgb(drag, 200, 30 + step), ..l.symbol(0) }); | ||
| } | ||
| started = draw(&mut map, &view); | ||
| } | ||
| if rustgis_tiles::cache::generation() == before { | ||
| break; | ||
| } | ||
| } | ||
| assert_eq!(started, Some(1), "a drag draws from the picture under the layer"); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Re-raising the earlier flakiness point on this assertion, because the code under it changed. The wait that answered it (79e9e6f) was removed in 538f680, so the loop again ends only on a drag that lands no tile. If other tests' tiles land during every drag (up to 50 drags of 4 draws), the last Category: quality
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Left for the release quality pass. CI runs each test in a process of its own, where no other test's tiles can land; under |
||
| let r = render(&mut map, &view).expect("drawn"); | ||
| assert!(r.tile_errors.iter().any(|e| e.starts_with("Gone: none of the tiles in view")), "{:?}", r.tile_errors); | ||
| } | ||
|
|
||
| #[test] | ||
| fn a_layer_with_no_look_draws_in_every_frame() { | ||
| let (mut map, view, below, _) = map(); | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -46,9 +46,11 @@ mod text; | |
| pub use text::CALLOUT_WIDTH; | ||
| mod frame_cache; | ||
| mod layer_meshes; | ||
| mod tile_errors; | ||
| pub mod tile_mesh; | ||
| mod tiles; | ||
| pub mod vector; | ||
| pub use tile_errors::{tile_error_kind, tile_error_notices}; | ||
| pub use tiles::{Live, live as live_tiles}; | ||
|
|
||
| pub use rustgis_tiles; | ||
|
|
@@ -558,11 +560,14 @@ pub struct Rendered { | |
| pub tiles_pending: bool, | ||
| /// Streamed layers are still reading the view: drawing again later shows them. | ||
| pub data_pending: bool, | ||
| /// Tile layers that couldn't be drawn, and why. | ||
| /// Layers that couldn't be drawn in full, or whose server has none of their tiles in view, and why. | ||
| pub tile_errors: Vec<String>, | ||
| /// Those of `tile_errors` that say a layer's server has none of its tiles in view: a view drawn | ||
| /// in parts says one only when every part does. | ||
| pub absent: Vec<String>, | ||
| /// Raster layers read in place drawn from less than the view needs (a coarser level, tiles | ||
| /// they couldn't read), by id, their errors among `tile_errors`: an export refuses them. | ||
| pub partial: Vec<u32>, | ||
| /// they couldn't read), by id, each with its error (also in `tile_errors`): an export refuses them. | ||
| pub partial: Vec<(u32, String)>, | ||
| /// Raster layers read in place whose tiles are still on their way, by id: drawn again as | ||
| /// they land; an export that can't wait refuses them. | ||
| pub pending_in_place: Vec<u32>, | ||
|
|
@@ -2903,7 +2908,8 @@ fn render_tilted( | |
| let mut kept: Vec<(View, (f64, f64), Pixmap)> = Vec::new(); | ||
| let last = bands_of.len().saturating_sub(1); | ||
| let (mut attribution, mut tiles_pending, mut tile_errors) = (Vec::<String>::new(), false, Vec::<String>::new()); | ||
| let (mut partial, mut pending_in_place) = (Vec::<u32>::new(), Vec::<u32>::new()); | ||
| let (mut partial, mut pending_in_place) = (Vec::<(u32, String)>::new(), Vec::<u32>::new()); | ||
| let mut absences = tile_errors::Bands::default(); | ||
| for (i, b) in bands_of.into_iter().enumerate() { | ||
| // A stopped frame (see `cancel`) draws no further band, nor its drape or warp. | ||
| if cancel::requested() { | ||
|
|
@@ -2932,21 +2938,23 @@ fn render_tilted( | |
| return None; | ||
| } | ||
| // Preserve the upstream best-effort band path for ordinary providers. | ||
| absences.unknown(); | ||
| continue; | ||
| }; | ||
| for a in r.attribution { | ||
| if !attribution.contains(&a) { | ||
| attribution.push(a); | ||
| } | ||
| } | ||
| for e in r.tile_errors { | ||
| absences.band(&r.absent); | ||
| for e in r.tile_errors.into_iter().filter(|e| !r.absent.contains(e)) { | ||
| if !tile_errors.contains(&e) { | ||
| tile_errors.push(e); | ||
| } | ||
| } | ||
| for id in r.partial { | ||
| if !partial.contains(&id) { | ||
| partial.push(id); | ||
| for (id, why) in r.partial { | ||
| if !partial.iter().any(|(had, _)| *had == id) { | ||
| partial.push((id, why)); | ||
| } | ||
| } | ||
| for id in r.pending_in_place { | ||
|
|
@@ -2989,6 +2997,8 @@ fn render_tilted( | |
| } | ||
| } | ||
| let unplaced = if map.label_display.show_unplaced { placed.unplaced } else { Vec::new() }; | ||
| let absent = absences.finish(); | ||
| tile_errors.extend(absent.iter().cloned()); | ||
| Some(Rendered { | ||
| pixmap: pm.into_pixmap(), | ||
| labels: placed.labels, | ||
|
|
@@ -2997,6 +3007,7 @@ fn render_tilted( | |
| tiles_pending, | ||
| data_pending, | ||
| tile_errors, | ||
| absent, | ||
| partial, | ||
| pending_in_place, | ||
| recorded: None, | ||
|
|
@@ -3453,7 +3464,10 @@ fn gpu_turned( | |
| let mut candidates = Vec::new(); | ||
| let (mut cmds, mut clips) = (Vec::new(), Vec::new()); | ||
| let (mut attribution, mut tiles_pending, mut tile_errors, mut clear) = (Vec::<String>::new(), false, Vec::<String>::new(), [0.0; 4]); | ||
| let (mut partial, mut pending_in_place) = (Vec::<u32>::new(), Vec::<u32>::new()); | ||
| let (mut partial, mut pending_in_place) = (Vec::<(u32, String)>::new(), Vec::<u32>::new()); | ||
| // No band says a layer has no tile in view: a map with tile layers isn't drawn here | ||
| // (`gpu_may_turn`). | ||
| let absent = Vec::new(); | ||
| let mut plain = true; | ||
| let last = bands.len().saturating_sub(1); | ||
| for (i, b) in bands.iter().enumerate() { | ||
|
|
@@ -3505,9 +3519,9 @@ fn gpu_turned( | |
| tile_errors.push(e); | ||
| } | ||
| } | ||
| for id in scene.partial { | ||
| if !partial.contains(&id) { | ||
| partial.push(id); | ||
| for (id, why) in scene.partial { | ||
| if !partial.iter().any(|(had, _)| *had == id) { | ||
| partial.push((id, why)); | ||
| } | ||
| } | ||
| for id in scene.pending_in_place { | ||
|
|
@@ -3562,6 +3576,7 @@ fn gpu_turned( | |
| tiles_pending, | ||
| data_pending, | ||
| tile_errors, | ||
| absent, | ||
| partial, | ||
| pending_in_place, | ||
| tilt, | ||
|
|
@@ -5326,10 +5341,10 @@ fn render_frame( | |
| Err(e) => { | ||
| let e = format!("{}: {e}", layer.name); | ||
| if !tile_out.errors.contains(&e) { | ||
| tile_out.errors.push(e); | ||
| tile_out.errors.push(e.clone()); | ||
| } | ||
| if !tile_out.partial.contains(&layer.id) { | ||
| tile_out.partial.push(layer.id); | ||
| if !tile_out.partial.iter().any(|(id, _)| *id == layer.id) { | ||
| tile_out.partial.push((layer.id, e)); | ||
| } | ||
| } | ||
| }, | ||
|
|
@@ -7144,7 +7159,8 @@ fn render_frame( | |
| } | ||
| let attribution = tile_out.attribution; | ||
| let tiles_pending = tile_out.pending; | ||
| let tile_errors = tile_out.errors; | ||
| let absent = tile_out.absent; | ||
| let tile_errors: Vec<String> = tile_out.errors.into_iter().chain(absent.iter().cloned()).collect(); | ||
| let partial = tile_out.partial; | ||
| let pending_in_place = tile_out.pending_in_place; | ||
| match backend { | ||
|
|
@@ -7161,6 +7177,7 @@ fn render_frame( | |
| tiles_pending, | ||
| data_pending, | ||
| tile_errors, | ||
| absent, | ||
| partial, | ||
| pending_in_place, | ||
| recorded, | ||
|
|
@@ -7190,6 +7207,7 @@ fn render_frame( | |
| tiles_pending, | ||
| data_pending, | ||
| tile_errors, | ||
| absent, | ||
| partial, | ||
| pending_in_place, | ||
| tilt: None, | ||
|
|
@@ -8800,7 +8818,7 @@ fn take_said() -> ShadowsSaid { | |
| let mut notices = take_shadow_notices(); | ||
| let mut keys = notices.clone(); | ||
| for (kind, e) in approximations::take_keyed(&[]) { | ||
| let key = format!("approximated\0{kind}"); | ||
| let key = notice_key(&kind); | ||
| if !keys.contains(&key) { | ||
| keys.push(key); | ||
| notices.push(e); | ||
|
|
@@ -8809,6 +8827,15 @@ fn take_said() -> ShadowsSaid { | |
| ShadowsSaid { notices, keys, to_come: SHADOWS_TO_COME.with(|c| c.replace(false)) } | ||
| } | ||
|
|
||
| /// Starts the kind of what an export or page says of a layer drawn from less than it needs; what | ||
| /// follows is the key the map view says that layer's error under ([`tile_error_notices`]). | ||
| const UNDRAWN: &str = "\0undrawn\0"; | ||
|
|
||
| /// The key a notice of `kind` is said once under, by the map view and the pages alike. | ||
| pub fn notice_key(kind: &str) -> String { | ||
| kind.strip_prefix(UNDRAWN).map_or_else(|| format!("approximated\0{kind}"), str::to_string) | ||
| } | ||
|
|
||
| /// What frames drawn on this thread approximated since the last call, and what map view frames | ||
| /// drawn on worker threads handed over to `relays` ([`ApproximationRelay::hand_over`]), each kind | ||
| /// once, as (kind, notice): what the map view says after each frame it shows, each kind once a | ||
|
|
@@ -8908,8 +8935,21 @@ fn complete(map: &mut Map, view: &View, record: bool, failed_source: &mut Option | |
| let before = (SHADOWS_TO_COME.with(|c| c.replace(false)), take_shadow_notices()); | ||
| let r = complete_passes(map, view, record, failed_source, env); | ||
| SHADOWS_TO_COME.with(|c| c.set(before.0 || c.get())); | ||
| let drawn = take_shadow_notices(); | ||
| // A layer drawn from less than it needs (a tile layer whose tiles failed, a raster read in | ||
| // place drawn from a coarser level) leaves its part empty or coarse, which in a finished | ||
| // picture passes for the map: whoever this draws for says it (see `shadows_said`), each layer | ||
| // and kind once. Cast shadows left out are said as such. | ||
| for e in r.iter().flat_map(|r| &r.tile_errors).filter(|e| !drawn.contains(e)) { | ||
| for (key, notice) in tile_error_notices(map, e) { | ||
| approximations::note( | ||
| format!("{UNDRAWN}{key}"), | ||
| format!("a layer couldn't be drawn in full, so parts of it may be empty or coarse: {notice}"), | ||
| ); | ||
| } | ||
| } | ||
| let mut notices = before.1; | ||
| for e in take_shadow_notices() { | ||
| for e in drawn { | ||
| if !notices.contains(&e) { | ||
| notices.push(e); | ||
| } | ||
|
|
@@ -9065,7 +9105,7 @@ pub fn render_placed(map: &mut Map, view: &View) -> Result<Placed, String> { | |
| let approximated = approximations::take(); | ||
| approximations::restore(approximated_before); | ||
| let r = r?; | ||
| let tile_errors: Vec<&String> = r.tile_errors.iter().filter(|e| !shadows.contains(e)).collect(); | ||
| // Tile layers that couldn't be drawn are among what it approximated (see `complete`). | ||
| let mut gaps = shadows; | ||
| gaps.extend(approximated); | ||
| if to_come { | ||
|
|
@@ -9083,14 +9123,6 @@ pub fn render_placed(map: &mut Map, view: &View) -> Result<Placed, String> { | |
| .to_string(), | ||
| ); | ||
| } | ||
| if let Some(first) = tile_errors.first() { | ||
| let n = tile_errors.len(); | ||
| gaps.push(if n == 1 { | ||
| format!("a tile layer couldn't be drawn, so its part is empty: {first}") | ||
| } else { | ||
| format!("{n} tile layers couldn't be drawn, so their parts are empty; the first: {first}") | ||
| }); | ||
| } | ||
| revisions.finish(map, None, Some(Placed { pixmap: r.pixmap, credits: r.attribution, gaps }), "could not draw the map") | ||
| } | ||
|
|
||
|
|
@@ -9108,12 +9140,7 @@ fn render_exported(map: &mut Map, view: &View) -> Result<Rendered, String> { | |
| if let Some(l) = r.pending_in_place.first().and_then(|id| map.layers.iter().find(|l| l.id == *id)) { | ||
| return Err(format!("{}: its tiles are still on their way: export again once the map has drawn it", l.name)); | ||
| } | ||
| if let Some(l) = r.partial.first().and_then(|id| map.layers.iter().find(|l| l.id == *id)) { | ||
| // Its own error, named by the layer, says why; else the general one. | ||
| let why = r.tile_errors.iter().find(|e| e.starts_with(&format!("{}: ", l.name))).cloned(); | ||
| let why = why.unwrap_or_else(|| { | ||
| format!("{}: drawn from less than the view needs (a coarser level, or tiles that couldn't be read)", l.name) | ||
| }); | ||
| if let Some((_, why)) = r.partial.first() { | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The map PDF's overflow fallback still refuses a raster read in place that is drawn from less than it needs. Either let the overflow picture draw the layer and say it through Category: quality
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The guide and the description say so since 538f680: a map PDF too large for vectors is drawn as a picture and refuses such a raster, as it does on |
||
| return Err(format!("{why}, so the image isn't written")); | ||
| } | ||
| Ok(r) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The loop stops at the first drag that lands no tile, so
startedis whatever the last draw returned. Under a parallel test run, another test's tiles can land during every drag. Then all 50 drags run, and the final draw may not be the one that draws from the picture, soassert_eq!(started, Some(1))can fail on timing alone. Waiting for the other fetches to finish before the drags (rustgis_tiles::cache::wait), or asserting on the draw that follows the last quiet drag, would tie the check to this frame only. I haven't run it, so the confidence is medium-low.Category: quality
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 79e9e6f: each drag first waits for the fetches under way, other tests' included.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The wait this added is out again in 538f680: under one process it waits on fetches other tests hold open on purpose. The retry on a moved generation stays, and CI runs each test in a process of its own.