From 5c179822d9c076443ade930d85aa4647abcde033 Mon Sep 17 00:00:00 2001 From: SofiaAFigueredo Date: Sun, 25 Oct 2026 18:53:05 -0300 Subject: [PATCH 1/3] fix(show): start a slide transition's clock after its first frame is rendered (#1385) The clock started at the key press, but the new slide (and, for Pan, Reveal and similar transitions, four more pictures) is rendered on the UI thread before the first transition frame. When that took longer than the transition's duration, the first drawn frame was already past the end and the next slide appeared with no transition. The first frame now renders the slide and the pictures while showing the start of the transition, and the clock starts on the frame after it. Co-Authored-By: Claude Sonnet 5.5 --- crates/ui-egui/src/show.rs | 55 +++++++++++++++++++++++++++++++++++--- 1 file changed, 51 insertions(+), 4 deletions(-) diff --git a/crates/ui-egui/src/show.rs b/crates/ui-egui/src/show.rs index 7055f9b2f..0b9cd22aa 100644 --- a/crates/ui-egui/src/show.rs +++ b/crates/ui-egui/src/show.rs @@ -271,12 +271,37 @@ struct Transition { /// moves contents over backgrounds (Pan, Ferris Wheel, Reveal…): old back, old content, new /// back, new content. parts: Option<[Option; 4]>, + /// When the transition's clock started. `apply` sets it to the time of the key press; the + /// first frames of the transition re-anchor it (see `progress`), because rendering the new + /// slide and the transition's pictures can take longer than the whole transition (#1385). start: f64, + /// The first frame of the transition has been drawn: the new slide and the pictures the + /// transition needs exist, so the time they took is not part of the transition. + primed: bool, + /// `start` was moved to the frame after the first one. + anchored: bool, kind: String, option: String, dur: f64, } +impl Transition { + /// How far the transition has come at frame time `now`, from 0 to 1. The first frame is the + /// one that renders the new slide and the transition's pictures and the second one starts the + /// clock, so a slow render never eats the transition's duration (#1385). + fn progress(&mut self, now: f64) -> f64 { + if !self.primed { + self.primed = true; + return 0.0; + } + if !self.anchored { + self.anchored = true; + self.start = now; + } + ((now - self.start) / self.dur.max(0.01)).clamp(0.0, 1.0) + } +} + /// A copy of the show's clock origins for regressions that must not depend on wall time. #[cfg(test)] #[derive(Clone, Copy, Debug, PartialEq)] @@ -583,7 +608,7 @@ impl Show { self.last_viewed = from; } self.trans = if kind != "none" && dur > 0.0 && !doc.show.without_animation { - Some(Transition { old, from, morph: None, parts: None, start: now, kind, option, dur }) + Some(Transition { old, from, morph: None, parts: None, start: now, primed: false, anchored: false, kind, option, dur }) } else { None }; @@ -1091,11 +1116,12 @@ pub fn ui(app: &mut SlideApp, ui: &mut Ui) { } } let mut drew = false; - let morphing = show.trans.as_ref().is_some_and(|tr| tr.kind == "morph" && tr.from.is_some() && now - tr.start < tr.dur); + let progress = show.trans.as_mut().map(|tr| tr.progress(now)); + let morphing = show.trans.as_ref().is_some_and(|tr| tr.kind == "morph" && tr.from.is_some()) && progress.is_some_and(|p| p < 1.0); let tl = if morphing { Some(show.timeline(&doc).clone()) } else { None }; let morph = match (&show.trans, tl) { (Some(tr), Some(tl)) => { - let p = ((now - tr.start) / tr.dur.max(0.01)).clamp(0.0, 1.0); + let p = progress.unwrap_or(1.0); let hidden_b = |id: ShapeId| { let st = state_for(&tl, id, 0, 0.0, &[], &[]); !st.visible || st.opacity <= 0.0 || hidden.contains(&id) @@ -1137,7 +1163,7 @@ pub fn ui(app: &mut SlideApp, ui: &mut Ui) { drew = true; ctx.request_repaint(); } else if let (Some(tr), Some(new)) = (show.trans.as_mut(), &tex) { - let p = ((now - tr.start) / tr.dur.max(0.01)).clamp(0.0, 1.0); + let p = progress.unwrap_or(1.0); if p < 1.0 { // Slides split into background and content are rendered once per transition; // every frame only composites cached textures. @@ -2795,6 +2821,27 @@ mod tests { assert!(show.tex.is_none(), "the new slide gets a texture of its own instead of overwriting the old one"); } + #[test] + fn a_slow_first_frame_does_not_use_up_the_transition() { + // #1385: the clock started at the key press, so rendering the new slide for longer than the + // transition's duration showed the next slide with no transition at all. + let mut s = deckcraft_engine::Session::with_new(); + s.execute("slide.new", &json!({})).unwrap(); + s.execute("transition.set", &json!({"kind": "fade", "index": 1, "duration": 500})).unwrap(); + let doc = s.active().unwrap().doc.clone(); + let mut show = Show::new(&doc, 0, false, false); + assert!(show.apply(ShowAction::Slide(1), &doc, 10.0)); + let tr = show.trans.as_mut().expect("the fade plays"); + assert!((tr.dur - 0.5).abs() < 1e-9); + // The first frame renders for two seconds; it still shows the start of the transition. + assert_eq!(tr.progress(10.0), 0.0); + // The frame after it starts the clock. + assert_eq!(tr.progress(12.0), 0.0); + assert!((tr.progress(12.25) - 0.5).abs() < 1e-9); + assert_eq!(tr.progress(12.5), 1.0); + assert_eq!(tr.progress(20.0), 1.0); + } + #[test] fn media_in_the_click_sequence_plays_with_its_step() { // #116: media set to play in the click sequence never started; only a click on it did. From b697455ea71100407fac63cfab686dc9593547e3 Mon Sep 17 00:00:00 2001 From: SofiaAFigueredo Date: Sun, 25 Oct 2026 18:57:15 -0300 Subject: [PATCH 2/3] docs(contributors): credit SofiaAFigueredo by real name (#1385) Co-Authored-By: Claude Sonnet 5.5 --- contributors/people.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/contributors/people.toml b/contributors/people.toml index 20fed3bcc..31dccab20 100644 --- a/contributors/people.toml +++ b/contributors/people.toml @@ -65,3 +65,6 @@ sync_github_name = true [people.Katacc] sync_github_name = true + +[people.SofiaAFigueredo] +real_name = "Sofia Alves Figueredo" From 877e6db673f7a5a9fd5b182abb8103d684411afa Mon Sep 17 00:00:00 2001 From: SofiaAFigueredo Date: Sun, 25 Oct 2026 19:05:43 -0300 Subject: [PATCH 3/3] fix(show): a hidden show expires a transition from the key press (#1385) Re-anchoring `start` for the drawn transition delayed the hidden show's expiration by the time between the press and the second frame. The press time stays in `start`; the drawn clock is its own field. Co-Authored-By: Claude Sonnet 5.5 --- crates/ui-egui/src/show.rs | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/crates/ui-egui/src/show.rs b/crates/ui-egui/src/show.rs index 0b9cd22aa..449d63558 100644 --- a/crates/ui-egui/src/show.rs +++ b/crates/ui-egui/src/show.rs @@ -271,15 +271,16 @@ struct Transition { /// moves contents over backgrounds (Pan, Ferris Wheel, Reveal…): old back, old content, new /// back, new content. parts: Option<[Option; 4]>, - /// When the transition's clock started. `apply` sets it to the time of the key press; the - /// first frames of the transition re-anchor it (see `progress`), because rendering the new - /// slide and the transition's pictures can take longer than the whole transition (#1385). + /// The time of the key press. A hidden show, which draws nothing, expires the transition + /// from it. start: f64, + /// Where the drawn transition's clock starts: the frame after the first one (see `progress`), + /// because rendering the new slide and the transition's pictures can take longer than the + /// whole transition (#1385). `None` until then. + clock: Option, /// The first frame of the transition has been drawn: the new slide and the pictures the /// transition needs exist, so the time they took is not part of the transition. primed: bool, - /// `start` was moved to the frame after the first one. - anchored: bool, kind: String, option: String, dur: f64, @@ -294,11 +295,8 @@ impl Transition { self.primed = true; return 0.0; } - if !self.anchored { - self.anchored = true; - self.start = now; - } - ((now - self.start) / self.dur.max(0.01)).clamp(0.0, 1.0) + let clock = *self.clock.get_or_insert(now); + ((now - clock) / self.dur.max(0.01)).clamp(0.0, 1.0) } } @@ -608,7 +606,7 @@ impl Show { self.last_viewed = from; } self.trans = if kind != "none" && dur > 0.0 && !doc.show.without_animation { - Some(Transition { old, from, morph: None, parts: None, start: now, primed: false, anchored: false, kind, option, dur }) + Some(Transition { old, from, morph: None, parts: None, start: now, clock: None, primed: false, kind, option, dur }) } else { None }; @@ -2840,6 +2838,8 @@ mod tests { assert!((tr.progress(12.25) - 0.5).abs() < 1e-9); assert_eq!(tr.progress(12.5), 1.0); assert_eq!(tr.progress(20.0), 1.0); + // A hidden show still expires it from the key press. + assert_eq!(tr.start, 10.0); } #[test]