Skip to content
Open
Show file tree
Hide file tree
Changes from 1 commit
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
28 changes: 27 additions & 1 deletion crates/ui-egui/src/headless/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4839,7 +4839,7 @@ fn the_loupe_says_rendering_while_an_edit_renders() {
}

/// View Options' Show message when loading or rendering photos (on by default): turned off in
/// the window, the loupe does not say "Rendering…" while an edit renders; `view.viewOptions
/// the window, the loupe does not say "Rendering…" for the first moments of an edit's render (only one that stays slow says so: see the next test); `view.viewOptions
/// {loupeMessages}` turns it back on for an agent (refusing a value that is not true or false).
#[test]
fn view_options_turn_the_rendering_message_off() {
Expand Down Expand Up @@ -4877,6 +4877,32 @@ fn view_options_turn_the_rendering_message_off() {
assert!(h.step_until(SETTLE, |h| !pill(h)), "gone once the render lands");
}

/// With the message off, a render that is still on its way after a long wait (several seconds, not the
/// half second the message waits) says "Rendering…" anyway: the old photo on screen with no sign of work
/// looks like a frozen app. A short wait stays quiet, as the setting asks.
#[test]
fn a_render_that_stays_slow_says_so_even_with_the_message_off() {
use crate::render::Slot;
use std::{cell::Cell, rc::Rc};
let pill = |h: &Headless| h.app.widgets.iter().any(|(w, _)| w == "loupe:rendering");
let mut h = demo([1000.0, 700.0]);
let t = Duration::from_secs(10);
h.request("ui.set", json!({"view": "detail", "right": "none"}), t);
h.settle(SETTLE);
h.app.ui.settings.loupe_messages = false;
let open = Rc::new(Cell::new(false));
h.app.renderer.set_offload(Box::new(super::RenderGate::new(open.clone())));
h.request("engine.execute", json!({"command": "develop.set", "params": {"control": "light.exposure", "value": 0.5}}), t);
for _ in 0..45 {
h.step();
}
assert!(h.app.renderer.is_pending(Slot::Main), "the edit's render is held");
assert!(!pill(&h), "a short wait stays quiet with the message off");
assert!(h.step_until(SETTLE, pill), "a long wait says so");
open.set(true);
assert!(h.step_until(SETTLE, |h| !pill(h)), "gone once the render lands");
}

/// With nothing to show yet, the loupe says "Rendering…" in its middle only while View Options'
/// Show message when loading or rendering photos is on.
#[test]
Expand Down
2 changes: 1 addition & 1 deletion crates/ui-egui/src/panels/compare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ fn photo_tile(app: &mut LightcraftApp, ui: &mut egui::Ui, id: PhotoId, slot: Slo
if *photo != id {
(*photo, *wait) = (id, None);
}
super::detail::rendering_overdue(wait, keys, coming, now)
super::detail::rendering_overdue(wait, keys, coming, now, super::detail::RENDERING_AFTER_SECS)
});
let failed = (!rendering && mine(slot).is_none() && (!r.is_pending(slot) || r.retrying(slot))).then(|| r.failure_of(slot, id)).flatten();
let over = display.intersect(img_area);
Expand Down
40 changes: 25 additions & 15 deletions crates/ui-egui/src/panels/detail.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,13 +39,11 @@ pub use geometry::CanvasMap;
pub(crate) use geometry::focus_box;
use geometry::{animated_rect, middle_pan};
pub(crate) use geometry::{fit_rect, fit_texture_rect, focus_pan, navigate_gesture, output_px, pan_image, snap_fit_rect, texture_side};
#[cfg(test)]
use info::RENDERING_AFTER_SECS;
use info::{
FILTER_PILL_HEIGHT, FILTER_PILL_INSET, brief_info, filter_pill, filter_pill_shown, info_overlay, info_overlay_extent, label_badge_rect,
preview_only_pill, quick_name,
};
pub(crate) use info::{draw_focus_point, failed_pill, loupe_pill, rendering_overdue};
pub(crate) use info::{RENDERING_AFTER_SECS, SLOW_RENDERING_AFTER_SECS, draw_focus_point, failed_pill, loupe_pill, rendering_overdue};
use masks::{RegionContext, RegionEdit, color_range_pick, mask_overlay, region_overlay};
use retouch::{eye_overlay, remove_overlay};
pub(crate) use window::overlay_supports_window;
Expand Down Expand Up @@ -341,7 +339,9 @@ pub fn show(app: &mut LightcraftApp, ui: &mut egui::Ui) {
let coming = render_coming(app, shown, &windows, ViewMode { split, show_before, split_view });
let keys =
[Slot::Main, Slot::Before, Slot::Region, Slot::RegionBefore].map(|s| app.renderer.textures.get(&s).filter(|t| t.photo == id).map(|t| t.key));
let rendering = ui.ctx().data_mut(|d| rendering_overdue(d.get_temp_mut_or(egui::Id::unique("loupe-rendering"), None), keys, coming, now));
let rendering = ui
.ctx()
.data_mut(|d| rendering_overdue(d.get_temp_mut_or(egui::Id::unique("loupe-rendering"), None), keys, coming, now, rendering_wait(app)));
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Resolved
// the render failed while a stand-in is up: what is on screen is all there will be (also while
// a library change retries it)
let failed = failed_render(app, id, !rendering && (!show_before || split), shown);
Expand Down Expand Up @@ -559,8 +559,14 @@ fn failed_render<'a>(app: &'a LightcraftApp, id: PhotoId, settled: bool, shown:
.flatten()
}

/// How long a render may be on its way before the loupe says "Rendering…": View Options' Show message when loading or
/// rendering photos on, half a second; off, only a render that stays slow says so.
fn rendering_wait(app: &LightcraftApp) -> f64 {
if app.ui.settings.loupe_messages { RENDERING_AFTER_SECS } else { SLOW_RENDERING_AFTER_SECS }
}

/// The pill over the photo (the After in two views; in the crop tool's wide margin, under it): the
/// failure, or View Options' "Show message when loading or rendering photos".
/// failure, or "Rendering…" (the caller shows it once [`rendering_overdue`] says it is due).
fn status_pill(
ui: &egui::Ui,
app: &LightcraftApp,
Expand All @@ -571,10 +577,9 @@ fn status_pill(
) {
match failed {
Some(e) => failed_pill(ui, app, photo, canvas, over, nav, "loupe:renderFailed", e),
None if app.ui.settings.loupe_messages => {
None => {
loupe_pill(ui, canvas, over, nav, "loupe:rendering", crate::i18n::tr("Rendering…"), false);
}
None => {}
}
}

Expand Down Expand Up @@ -1178,20 +1183,25 @@ mod tests {
/// a moment with nothing new on screen, and doesn't blink while slow drafts arrive.
#[test]
fn the_loupe_says_rendering_when_the_screen_falls_behind() {
use super::{RENDERING_AFTER_SECS as WAIT, rendering_overdue};
use super::{RENDERING_AFTER_SECS as WAIT, SLOW_RENDERING_AFTER_SECS as SLOW, rendering_overdue};
let key = |k| [Some(k), None, None, None];
let mut wait = None;
assert!(!rendering_overdue(&mut wait, key(1), false, 0.0), "nothing coming");
assert!(!rendering_overdue(&mut wait, key(1), false, 0.0, WAIT), "nothing coming");
// an edit after an idle spell: the wait starts now, not at the last frame drawn
assert!(!rendering_overdue(&mut wait, key(1), true, 30.0), "a render just asked for");
assert!(!rendering_overdue(&mut wait, key(1), true, 30.0 + WAIT * 0.8), "a quick render never shows it");
assert!(rendering_overdue(&mut wait, key(1), true, 30.0 + WAIT * 1.2), "nothing new for the wait");
assert!(rendering_overdue(&mut wait, key(2), true, 31.0 + WAIT), "once up, a slow draft doesn't blink it");
assert!(!rendering_overdue(&mut wait, key(3), false, 32.0), "done");
assert!(!rendering_overdue(&mut wait, key(1), true, 30.0, WAIT), "a render just asked for");
assert!(!rendering_overdue(&mut wait, key(1), true, 30.0 + WAIT * 0.8, WAIT), "a quick render never shows it");
assert!(rendering_overdue(&mut wait, key(1), true, 30.0 + WAIT * 1.2, WAIT), "nothing new for the wait");
assert!(rendering_overdue(&mut wait, key(2), true, 31.0 + WAIT, WAIT), "once up, a slow draft doesn't blink it");
assert!(!rendering_overdue(&mut wait, key(3), false, 32.0, WAIT), "done");
// a drag whose drafts keep up: always something coming, a new draft every 0.1 s
for i in 1..30u32 {
assert!(!rendering_overdue(&mut wait, key(u64::from(i)), true, 40.0 + f64::from(i) * 0.1), "draft {i}");
assert!(!rendering_overdue(&mut wait, key(u64::from(i)), true, 40.0 + f64::from(i) * 0.1, WAIT), "draft {i}");
}
// with the message off the same logic waits for the longer time
let mut wait = None;
assert!(!rendering_overdue(&mut wait, key(1), true, 50.0, SLOW));
assert!(!rendering_overdue(&mut wait, key(1), true, 50.0 + SLOW * 0.8, SLOW), "a render that is only a little slow stays quiet");
assert!(rendering_overdue(&mut wait, key(1), true, 50.0 + SLOW * 1.2, SLOW), "one that stays slow says so");
}

/// Issue #652: a native host reports the GPU's texture limit in the first frame's input only.
Expand Down
19 changes: 12 additions & 7 deletions crates/ui-egui/src/panels/detail/info.rs
Original file line number Diff line number Diff line change
Expand Up @@ -258,17 +258,22 @@ fn pretty_date(iso: &str) -> String {

/// How long a render may be on its way, with nothing new on screen, before the loupe says
/// "Rendering…" (s): as long as the activity stack waits before it shows a task.
pub(super) const RENDERING_AFTER_SECS: f64 = 0.5;
pub(crate) const RENDERING_AFTER_SECS: f64 = 0.5;

/// The same wait while View Options' Show message when loading or rendering photos is off: the
/// person asked not to be told about ordinary renders, but a photo that is still the old picture
/// after this long looks like a frozen app, so the loupe says so anyway (s).
pub(crate) const SLOW_RENDERING_AFTER_SECS: f64 = 3.0;

/// What [`rendering_overdue`] keeps between frames while a render is coming: the texture keys on
/// screen, since when, and whether the pill is up.
pub(crate) type RenderingWait = Option<([Option<u64>; 4], f64, bool)>;

/// Whether the loupe says "Rendering…": a render has been `coming` for [`RENDERING_AFTER_SECS`] with
/// no new texture `keys` on screen. The wait starts when the render starts coming (an idle app draws
/// no frames, so the last one may be long ago), and once up the pill stays until nothing is coming:
/// drafts slower than the wait don't make it blink.
pub(crate) fn rendering_overdue(wait: &mut RenderingWait, keys: [Option<u64>; 4], coming: bool, now: f64) -> bool {
/// Whether the loupe says "Rendering…": a render has been `coming` for `after` seconds (the
/// constants above) with no new texture `keys` on screen. The wait starts when the render starts
/// coming (an idle app draws no frames, so the last one may be long ago), and once up the pill stays
/// until nothing is coming: drafts slower than the wait don't make it blink.
pub(crate) fn rendering_overdue(wait: &mut RenderingWait, keys: [Option<u64>; 4], coming: bool, now: f64, after: f64) -> bool {
if !coming {
*wait = None;
return false;
Expand All @@ -277,7 +282,7 @@ pub(crate) fn rendering_overdue(wait: &mut RenderingWait, keys: [Option<u64>; 4]
if !*up && *seen != keys {
(*seen, *since) = (keys, now);
}
*up |= now - *since > RENDERING_AFTER_SECS;
*up |= now - *since > after;
*up
}

Expand Down
2 changes: 1 addition & 1 deletion crates/ui-egui/src/state/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ pub struct AppSettings {
/// Grid: when to show the rating / flag / edited badges.
pub grid_badges: GridBadges,
/// View ▸ View Options ▸ Show message when loading or rendering photos: the loupe says
/// "Rendering…" while the photo it shows is not the finished render.
/// "Rendering…" after half a second while the photo it shows is not the finished render; off, only after 3 s.
pub loupe_messages: bool,
/// Shortcuts the user changed (Help ▸ Keyboard Shortcuts): command id → shortcut, `""` = none.
pub keymap: crate::shortcuts::Keymap,
Expand Down
Loading
Loading