Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions crates/engine/src/cmd/share.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,14 @@ pub(crate) fn saying_shadows<T>(s: &mut Session, what: &str, draw: impl FnOnce(&
}

/// What frames said of their cast shadows, as warnings about `what`: layers drawn without them,
/// and, drawn on the interface's thread (which doesn't wait for them), that some were still
/// being worked out. What was drawn is written all the same.
/// and, drawn on the interface's thread (which doesn't wait for them: an image, a print, or a
/// file exported there, by a script or while a style's view loads), that some were still being
/// worked out. What was drawn is written all the same.
pub(crate) fn shadow_warnings(what: &str, said: &rustgis_render::ShadowsSaid) -> Vec<String> {
let mut out: Vec<String> = said.notices.iter().map(|e| format!("{what}: {e}")).collect();
if said.to_come {
out.push(format!(
"{what}: some layers are drawn without their cast shadows, still being worked out: draw it again once the map shows them"
"{what}: made without the cast shadows still being worked out, as the window doesn't wait for them: once the map shows them, draw or export it again"
));
}
out
Expand Down
27 changes: 23 additions & 4 deletions crates/engine/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3201,9 +3201,16 @@ fn every_drawing_of_the_map_says_a_layer_drawn_without_its_cast_shadows() {
r.overview = Some((800, 600));
rl.data = Some(std::sync::Arc::new(r));
let said = |s: &Session| s.notices.iter().filter(|n| n.text.contains("scene: its cast shadows aren't drawn")).count();
let dir = std::env::temp_dir().join(format!("rustgis-cast-every-{}", std::process::id()));
std::fs::create_dir_all(&dir).unwrap();
let path = |name: &str| dir.join(name).display().to_string();
/// Removed however the test ends.
struct Dir(std::path::PathBuf);
impl Drop for Dir {
fn drop(&mut self) {
std::fs::remove_dir_all(&self.0).ok();
}
}
let dir = Dir(std::env::temp_dir().join(format!("rustgis-cast-every-{}", std::process::id())));
std::fs::create_dir_all(&dir.0).unwrap();
let path = |name: &str| dir.0.join(name).display().to_string();
let draws: Vec<(&str, Box<dyn Fn(&mut Session)>)> = vec![
("map image", Box::new(|s| drop(crate::cmd::share::map_png(s, Some(200.0), Some(150.0), None).unwrap()))),
("map PDF", Box::new(|s| drop(crate::cmd::share::map_pdf(s, 72.0).unwrap()))),
Expand All @@ -3227,18 +3234,30 @@ fn every_drawing_of_the_map_says_a_layer_drawn_without_its_cast_shadows() {
draw(&mut s);
assert!(said(&s) > 0, "{what}: {:?}", s.notices.iter().map(|n| &n.text).collect::<Vec<_>>());
}
std::fs::remove_dir_all(&dir).ok();
// On the interface's thread a new sun's shadows aren't waited for: the image says so.
let mut s = with_raster();
s.run("layer.zoomTo", &json!({"layer": "scene"})).unwrap();
s.run("raster.symbology", &json!({"type": "shadedRelief", "azimuth": 123, "shadow": 1})).unwrap();
crate::render::on_the_interface_thread();
// Held before they trace, the shadows are still to come whatever the computer's speed.
let hold = crate::map::raster::hold_cast_shadows();
crate::cmd::share::map_png(&mut s, Some(200.0), Some(150.0), None).unwrap();
assert!(
s.notices.iter().any(|n| n.text.contains("still being worked out")),
"{:?}",
s.notices.iter().map(|n| &n.text).collect::<Vec<_>>()
);
// A file exported there (a script's, or while a style's view loads) says it was written
// without them, a GeoTIFF too.
for (azimuth, name) in [(124, "here.png"), (125, "here.tif")] {
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
s.run("raster.symbology", &json!({"type": "shadedRelief", "azimuth": azimuth, "shadow": 1})).unwrap();
s.notices.clear();
let path = path(name);
s.run("share.exportMap", &json!({"path": path, "width": 200, "height": 150})).unwrap();
let texts: Vec<&String> = s.notices.iter().map(|n| &n.text).collect();
assert!(texts.iter().any(|t| t.starts_with(&path) && t.contains("still being worked out")), "{name}: {texts:?}");
}
drop(hold);
}

#[test]
Expand Down
27 changes: 19 additions & 8 deletions crates/map/src/raster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -966,8 +966,19 @@ const KEPT_LIGHTS: usize = 3;

/// Works out a light grid: natively on a thread of its own (here if the system refuses one),
/// in the browser here.
/// Held by [`hold_cast_shadows`]: light work waits for it before it traces.
static LIGHT_HOLD: std::sync::RwLock<()> = std::sync::RwLock::new(());

/// Holds every light grid's work before it traces, until the guard is dropped: for tests of what
/// is drawn, and said, while cast shadows are still to come, whatever the computer's speed.
#[doc(hidden)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quality / robustness (confidence ~60%): a test hook is now public production API, and it is process-wide.

hold_cast_shadows is pub in rustgis_map and LIGHT_HOLD is one static for the whole process, so every light grid in every thread waits while a guard lives. Three consequences:

  • Any caller can stall all cast-shadow work. A leaked guard (mem::forget, or a cycle that keeps it alive) blocks every export that waits for shadows until the process ends.
  • Other tests in the same binary that start light work block until the guard drops. That is latency, not a deadlock, but it couples unrelated tests.
  • In the spawn-refused fallback (start_light runs run on the calling thread), run takes LIGHT_HOLD.read() on the thread that already holds the write guard. Per the RwLock docs that may deadlock. It only happens when the OS refuses a thread while a hold is active, so it is a test-only risk, but it would hang rather than fail.

A cfg gate is not available across crates here (the render and engine tests call it). Options: a test-hooks feature enabled only by the dev-dependencies, or keep the hold per-map/per-owner rather than global. Worth a short note in the doc comment at least: "a guard must not outlive the test".

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is hidden with #[doc(hidden)]. It has to be pub because the engine tests that use it are in another crate, where cfg(test) doesn't reach. It only holds a lock that production work takes uncontended.

pub fn hold_cast_shadows() -> std::sync::RwLockWriteGuard<'static, ()> {
LIGHT_HOLD.write().unwrap_or_else(|e| e.into_inner())
}

fn start_light(r: Arc<Raster>, key: LightKey, work: Arc<LightWork>) {
Comment on lines 967 to 979

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Quality (confidence ~95%): the doc comment for start_light is now attached to the new static.

The "Works out a light grid…" comment was above fn start_light. The new LIGHT_HOLD static and hold_cast_shadows were inserted between that comment and the function, so start_light has no doc and LIGHT_HOLD gets the wrong one. The static's own doc also appears twice in spirit: it says "Held by…" while the function doc describes a different function.

Suggested fix: move the start_light doc back onto the function, after the hold helper.

Suggested change
/// Works out a light grid: natively on a thread of its own (here if the system refuses one),
/// in the browser here.
/// Held by [`hold_cast_shadows`]: light work waits for it before it traces.
static LIGHT_HOLD: std::sync::RwLock<()> = std::sync::RwLock::new(());
/// Holds every light grid's work before it traces, until the guard is dropped: for tests of what
/// is drawn, and said, while cast shadows are still to come, whatever the computer's speed.
#[doc(hidden)]
pub fn hold_cast_shadows() -> std::sync::RwLockWriteGuard<'static, ()> {
LIGHT_HOLD.write().unwrap_or_else(|e| e.into_inner())
}
fn start_light(r: Arc<Raster>, key: LightKey, work: Arc<LightWork>) {
/// Held by [`hold_cast_shadows`]: light work waits for it before it traces.
static LIGHT_HOLD: std::sync::RwLock<()> = std::sync::RwLock::new(());
/// Holds every light grid's work before it traces, until the guard is dropped: for tests of what
/// is drawn, and said, while cast shadows are still to come, whatever the computer's speed.
#[doc(hidden)]
pub fn hold_cast_shadows() -> std::sync::RwLockWriteGuard<'static, ()> {
LIGHT_HOLD.write().unwrap_or_else(|e| e.into_inner())
}
/// Works out a light grid: natively on a thread of its own (here if the system refuses one),
/// in the browser here.
fn start_light(r: Arc<Raster>, key: LightKey, work: Arc<LightWork>) {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

#1823 merged before this could go in. Fixed in follow-up #1830: the doc comment is back on start_light.

let run = move || {
drop(LIGHT_HOLD.read().unwrap_or_else(|e| e.into_inner()));
let threads = rustgis_data::threads::max();
let traced = std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| {
crate::shadow::light(&r, key.band, &key.mask, key.azimuth, key.altitude, key.z_factor, threads, &work.stop)
Expand Down Expand Up @@ -2496,16 +2507,16 @@ mod tests {
let _ = tx.send(who);
}
};
// Joined while under way (held before it traces), both are told.
let hold = hold_cast_shadows();
let first = rl.cast_shadows(false, (0, 1), told("starter"));
let joined = rl.cast_shadows(false, (5, 1), told("joiner"));
// Joined while under way (it traces far under a 3° sun), both are told; done already, the
// joiner has the grid and needs no call.
if first == CastShadows::Pending && joined == CastShadows::Pending {
let mut heard = vec![landings.recv_timeout(std::time::Duration::from_secs(120)).unwrap()];
heard.push(landings.recv_timeout(std::time::Duration::from_secs(120)).unwrap());
heard.sort_unstable();
assert_eq!(heard, ["joiner", "starter"]);
}
drop(hold);
assert!(first == CastShadows::Pending && joined == CastShadows::Pending, "joined while under way");
let mut heard = vec![landings.recv_timeout(std::time::Duration::from_secs(120)).unwrap()];
heard.push(landings.recv_timeout(std::time::Duration::from_secs(120)).unwrap());
heard.sort_unstable();
assert_eq!(heard, ["joiner", "starter"]);
assert!(matches!(rl.cast_shadows(true, (0, 1), || {}), CastShadows::Ready(_)));
}

Expand Down
111 changes: 100 additions & 11 deletions crates/render/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2107,6 +2107,16 @@ fn render_any(map: &mut Map, view: &View, full_res_rasters: bool, backend: Backe
revisions.current([&*map]).then_some(output).flatten()
}

/// The scales a frame of `view` from `camera` (normalised) draws layers at: its centre's, and each
/// tilt band's when it is tilted (not on a globe). A layer drawn at any of them is drawn.
fn drawn_scales(map: &Map, camera: &Camera, view: &View) -> Vec<f64> {
let mut scales = vec![map.ground_res_at(camera) / rustgis_geom::PIXEL_M];
if camera.pitch != 0.0 && !map.projection.is_globe() {
scales.extend(camera.tilt_bands(view.width, view.height).iter().map(|b| map.ground_res_at(&b.camera) / rustgis_geom::PIXEL_M));
}
scales
}

/// One entire pass, including all bands and backend fallbacks, under `render_any`'s guard.
fn render_pass(map: &mut Map, view: &View, full_res_rasters: bool, backend: Backend, record: bool) -> Option<RenderOutput> {
// A bearing or pitch set directly on the camera may be unnormalised (or no number, which
Expand All @@ -2117,10 +2127,7 @@ fn render_pass(map: &mut Map, view: &View, full_res_rasters: bool, backend: Back
// A persisted Shapefile has no chunk handle until it opens. Preflight required local
// sources in every view so an open failure cannot become a successful incomplete export.
let complete_layers: std::collections::HashSet<u32> = {
let mut scales = vec![map.ground_res_at(&camera) / rustgis_geom::PIXEL_M];
if camera.pitch != 0.0 && !map.projection.is_globe() {
scales.extend(camera.tilt_bands(view.width, view.height).iter().map(|b| map.ground_res_at(&b.camera) / rustgis_geom::PIXEL_M));
}
let scales = drawn_scales(map, &camera, view);
map.layers
.iter()
.filter(|l| scales.iter().any(|scale| map.draws_at(l, *scale)))
Expand Down Expand Up @@ -6420,10 +6427,16 @@ pub(crate) fn frame_with_shadows_to_come<T>(f: impl FnOnce() -> T) -> (T, bool)
(out, to_come)
}

/// Waits for the cast shadows of the map's visible Shaded Relief layers, as an export does (it
/// runs off the interface's thread); the wait gives up when the run is cancelled.
fn wait_for_cast_shadows(map: &Map) {
for layer in map.layers.iter().filter(|l| l.visible) {
/// Waits for the cast shadows of the map's Shaded Relief layers drawn in `view` (visible, in
/// their and their groups' scale range at the view's centre or, tilted, at one of its bands, as
/// `render_pass` draws them), as an export does (it runs off the interface's thread); the wait
/// gives up when the run is cancelled.
fn wait_for_cast_shadows(map: &Map, view: &View) {
let mut camera = view.camera;
camera.bearing = rustgis_map::camera::normalize_bearing(camera.bearing);
camera.pitch = rustgis_map::camera::normalize_pitch(camera.pitch);
let scales = drawn_scales(map, &camera, view);
for layer in map.layers.iter().filter(|l| scales.iter().any(|s| map.draws_at(l, *s))) {
if let Some(rl) = &layer.raster {
rl.cast_shadows(true, (map.instance_id(), layer.instance_id()), shadows_landed);
}
Expand Down Expand Up @@ -6453,8 +6466,18 @@ fn complete(map: &mut Map, view: &View, record: bool) -> Option<Rendered> {
// Cast shadows still being worked out are waited for first, unless this draws on the
// interface's thread (see `on_the_interface_thread`).
if !NO_SHADOW_WAIT.with(std::cell::Cell::get) {
wait_for_cast_shadows(map);
wait_for_cast_shadows(map, view);
}
// Whether cast shadows were still to come is the last pass's to say (an earlier one's may
// have been drawn again with them); what frames before it said is kept (see `shadows_said`).
let before = SHADOWS_TO_COME.with(|c| c.replace(false));
let r = complete_passes(map, view, record);
SHADOWS_TO_COME.with(|c| c.set(before || c.get()));
r
}

/// [`complete`]'s passes, each saying afresh whether cast shadows were still to come.
fn complete_passes(map: &mut Map, view: &View, record: bool) -> Option<Rendered> {
// What had come when it drew: what lands meanwhile is news to the wait.
let mut drawn_at = rustgis_tiles::cache::generation();
let mut r = render_cpu(map, view, true, record)?;
Expand All @@ -6476,6 +6499,7 @@ fn complete(map: &mut Map, view: &View, record: bool) -> Option<Rendered> {
idle += 1;
}
drawn_at = now;
SHADOWS_TO_COME.with(|c| c.set(false));

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Possible bug (confidence ~35%): notices from an earlier pass survive a later pass that drew the layer.

complete_passes resets SHADOWS_TO_COME before each re-render, so the "still to come" flag is per pass. SHADOW_NOTICES is not reset, so a notice pushed in pass 1 (for example "its cast shadows were stopped", or "…aren't drawn: …") stays in shadows for the export. If pass 2 draws the layer with its shadows, the file still says they were missing. This is the same false-positive the PR fixes for the flag, left in place for the notices.

I have not confirmed it can be reached: it needs a grid that stops or fails in pass 1 and succeeds on a retry within the same export. If that is impossible, a comment saying so would settle it. If it is possible, the notices from a pass that was drawn again should be dropped in the same way (keep only the last pass's, or keep them only when that pass still lacks the layer's shadows).

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Confirmed in code. #1823 merged first, so it's fixed in follow-up #1830: complete now clears the notices before each pass, as it does the flag, and says only its last pass's, keeping what frames before it said.

r = render_cpu(map, view, true, record)?;
}
Some(r)
Expand Down Expand Up @@ -6544,13 +6568,19 @@ pub fn render_placed(map: &mut Map, view: &View) -> Result<Placed, String> {
let revisions = archive_revisions([&*map]);
// Layers drawn without their cast shadows are said as gaps, not as tile layers that failed;
// what frames before it said is kept for `shadows_said`.
let before = take_shadow_notices();
let (before, before_come) = (take_shadow_notices(), SHADOWS_TO_COME.with(|c| c.replace(false)));
let r = render_exported(map, view);
let shadows = take_shadow_notices();
let (shadows, to_come) = (take_shadow_notices(), SHADOWS_TO_COME.with(|c| c.replace(before_come)));
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
SHADOW_NOTICES.with(|n| *n.borrow_mut() = before);
let r = r?;
let tile_errors: Vec<&String> = r.tile_errors.iter().filter(|e| !shadows.contains(e)).collect();
let mut gaps = shadows;
if to_come {
gaps.push(
"made without the cast shadows still being worked out, as the window doesn't wait for them: once the map shows them, draw or export it again"
.to_string(),
);
}
if r.tiles_pending {
gaps.push("some tiles were still on their way when the export stopped waiting, so parts of tile layers are empty: export again once the map has drawn them".to_string());
}
Expand Down Expand Up @@ -8634,6 +8664,65 @@ mod tests {
assert_ne!(plain.pixmap.data(), shaded.pixmap.data(), "drawn with its shadows");
}

/// A tilted export waits for the cast shadows of a layer drawn only in one of its far bands,
/// outside its scale range at the view's centre.
#[test]
fn a_tilted_export_waits_for_the_cast_shadows_its_bands_draw() {
let mut m = hill_map();
let id = m.layers.iter().find(|l| l.raster.is_some()).map(|l| l.id).unwrap();
let camera = Camera { center: lonlat_to_merc(Coord::new(0.0, 0.0)), res: 1200.0, bearing: 0.0, pitch: 60.0 };
let view = View { width: 200.0, height: 200.0, pixels_per_point: 1.0, camera, sky: false };
let scales = drawn_scales(&m, &camera, &view);
let (centre, farthest) = (scales[0], scales.iter().copied().fold(0.0, f64::max));
assert!(farthest > centre * 1.01, "a far band is drawn at a smaller scale: {scales:?}");
let l = m.layer_mut(id).unwrap();
l.visible = true;
l.raster.as_mut().unwrap().style.renderer =
rustgis_map::RasterRenderer::ShadedRelief { band: 0, ramp: None, azimuth: 210.0, altitude: 5.0, z_factor: 1.0, shadow: 1.0 };
// Drawn only zoomed out past a scale between the centre's and the far band's.
l.max_scale = Some((centre + farthest) / 2.0);
render_complete(&mut m, &view).unwrap();
let rl = m.layer(id).and_then(|l| l.raster.as_ref()).unwrap();
assert!(matches!(rl.cast_shadows(false, (0, 0), || {}), rustgis_map::raster::CastShadows::Ready(_)), "waited for");
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
}

/// An export doesn't wait for, nor start, the cast shadows of a layer it doesn't draw: one
/// outside its scale range, or held by a group.
#[test]
fn an_export_waits_only_for_the_cast_shadows_it_draws() {
let camera = Camera { center: lonlat_to_merc(Coord::new(0.0, 0.0)), res: 1200.0, bearing: 0.0, pitch: 0.0 };
let view = View { width: 200.0, height: 200.0, pixels_per_point: 1.0, camera, sky: false };
for grouped in [false, true] {
let mut m = hill_map();
let id = m.layers.iter().find(|l| l.raster.is_some()).map(|l| l.id).unwrap();
let l = m.layer_mut(id).unwrap();
l.visible = true;
l.raster.as_mut().unwrap().style.renderer = rustgis_map::RasterRenderer::ShadedRelief {
band: 0,
ramp: None,
azimuth: 200.0,
altitude: 5.0,
z_factor: 1.0,
shadow: 1.0,
};
// Drawn only zoomed in past 1:1: or in a group drawn only there.
if grouped {
let mut g = rustgis_map::LayerGroup::new("Relief");
g.children = vec![id];
g.min_scale = Some(1.0);
m.add_group(g);
} else {
l.min_scale = Some(1.0);
}
render_complete(&mut m, &view).unwrap();
let rl = m.layer(id).and_then(|l| l.raster.as_ref()).unwrap();
assert!(
matches!(rl.cast_shadows(false, (0, 0), || {}), rustgis_map::raster::CastShadows::Pending),
"grouped {grouped}: nothing was worked out for it"
);
}
}

#[test]
fn a_raster_at_the_closest_zoom_is_drawn_where_it_is() {
// At the deepest zoom (#902) the raster's far corners lie billions of pixels from the
Expand Down
3 changes: 2 additions & 1 deletion crates/ui-egui/src/docpanes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,7 @@ fn preview(app: &mut RustGisApp, ui: &mut Ui, i: usize, t: &Tokens) {
let key = format!("{i}#{}#{}", app.docs.page, app.session.revision);
if app.docs.preview.as_ref().is_none_or(|p| !crate::layoutview::preview_current(&p.0, &key)) {
let (s, page) = (&mut app.session, app.docs.page);
let drawn_at = rustgis_engine::render::rustgis_tiles::cache::generation();
let (drawn, said) = rustgis_engine::render::shadows_said(|| {
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| rustgis_engine::cmd::presentation::draw_page(s, i, page, 30.0)))
.unwrap_or_else(|_| Err("the preview failed unexpectedly".into()))
Expand All @@ -286,7 +287,7 @@ fn preview(app: &mut RustGisApp, ui: &mut Ui, i: usize, t: &Tokens) {
let img = egui::ColorImage::from_rgba_premultiplied([pm.width() as usize, pm.height() as usize], pm.data());
ui.ctx().load_texture("presentation_preview", img, egui::TextureOptions::LINEAR)
});
app.docs.preview = Some((crate::layoutview::preview_key(&key, &said), tex));
app.docs.preview = Some((crate::layoutview::preview_key(&key, &said, drawn_at), tex));
}
if app.docs.preview.as_ref().is_some_and(|p| crate::layoutview::preview_waits(&p.0)) {
ui.ctx().request_repaint_after(std::time::Duration::from_millis(250));
Expand Down
11 changes: 6 additions & 5 deletions crates/ui-egui/src/layoutview.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,11 +66,12 @@ pub(crate) fn say_frame_shadows(app: &mut RustGisApp, said: &rustgis_engine::ren
}
}

/// The key a preview drawn for `base` is kept under: with the tile cache's generation when its
/// frames drew without cast shadows still being worked out (on the interface's thread, which
/// doesn't wait for them), so it is drawn again as they land (see [`preview_current`]).
pub(crate) fn preview_key(base: &str, said: &rustgis_engine::render::ShadowsSaid) -> String {
if said.to_come { format!("{base}#shadows@{}", rustgis_engine::render::rustgis_tiles::cache::generation()) } else { base.to_string() }
/// The key a preview drawn for `base` is kept under: with the tile cache's generation read before
/// it was drawn (`drawn_at`) when its frames drew without cast shadows still being worked out (on
/// the interface's thread, which doesn't wait for them), so it is drawn again as they land, even
/// while it was drawn (see [`preview_current`]).
pub(crate) fn preview_key(base: &str, said: &rustgis_engine::render::ShadowsSaid, drawn_at: u64) -> String {
if said.to_come { format!("{base}#shadows@{drawn_at}") } else { base.to_string() }
}

/// Whether a preview kept under `kept` (see [`preview_key`]) is still the one `base` asks for:
Expand Down
3 changes: 2 additions & 1 deletion crates/ui-egui/src/reportpane.rs
Original file line number Diff line number Diff line change
Expand Up @@ -328,6 +328,7 @@ fn preview(app: &mut RustGisApp, ui: &mut Ui, i: usize, t: &Tokens) {
None => return,
};
let (s, page) = (&mut app.session, app.reports.page);
let drawn_at = rustgis_engine::render::rustgis_tiles::cache::generation();
let (drawn, said) = rustgis_engine::render::shadows_said(|| {
std::panic::catch_unwind(std::panic::AssertUnwindSafe(|| -> Result<_, String> {
let page = page.min(pages.len().saturating_sub(1));
Expand All @@ -344,7 +345,7 @@ fn preview(app: &mut RustGisApp, ui: &mut Ui, i: usize, t: &Tokens) {
let img = egui::ColorImage::from_rgba_premultiplied([pm.width() as usize, pm.height() as usize], pm.data());
let tex = ui.ctx().load_texture("report_preview", img, egui::TextureOptions::LINEAR);
let key = format!("{i}#{page}#{}", app.session.revision);
app.reports.preview = Some((crate::layoutview::preview_key(&key, &said), tex, total));
app.reports.preview = Some((crate::layoutview::preview_key(&key, &said, drawn_at), tex, total));
}
Err(e) => {
ui.label(egui::RichText::new(e).small().color(Color32::from_rgb(0xC0, 0x30, 0x30)));
Expand Down
Loading