forge
Explore
Log in

Don't you dare go Hollow

Caption flag resets match the engine's reseek exactly

Browse files at this commit

cda6d0eb7cda9bbff1487112cb7cf3e068d4e44bAhmet Kaan GümüşParent: 25855e8
  • fix
    • caption flag resets match the engine's reseek exactly
Show full message
🐛 fix(timeline): caption flag resets match the engine's reseek exactly

The app gated its grouped-caption drag and trim flag resets on the
caption carrying any link at all, while the engine reseeks only when
the group holds clips: a caption grouped only with another caption
(ctrl-click two captions, Group) latched the seek wait with no frame
ever delivered -- an unbounded repaint loop while paused.

PlaybackSession::caption_grouped_with_clips is now the one public
answer, asked before the edit moves indices, and both reset gates read
it: drag from the press's lane and live index, trim from the trim's
own lane and index. The two sides can no longer disagree.
crates/app/src/player/timeline_edit.rsmodified+23 -8
@@ -455,6 +455,15 @@ impl Player {
455 let Some(idx) = self.dragged_sub(drag) else {455 let Some(idx) = self.dragged_sub(drag) else {
456 return;456 return;
457 };457 };
458+ // Asked before the edit, on the indices the press captured: the
459+ // engine's own grouped-with-clips answer, which is exactly when its
460+ // move reseeks -- a caption grouped only with other captions moves no
461+ // media, and a flag reset without a delivered frame would latch the
462+ // seek wait forever.
463+ let grouped = self
464+ .session
465+ .as_ref()
466+ .is_some_and(|session| session.caption_grouped_with_clips(drag.lane, idx));
458 let start = self.sub_drop_frame(drag.sub, x).0;467 let start = self.sub_drop_frame(drag.sub, x).0;
459 match self468 match self
460 .session469 .session
@@ -474,9 +483,9 @@ impl Player {
474 // A lane holds its captions in start order, so the drop moved the483 // A lane holds its captions in start order, so the drop moved the
475 // mark as well as the box: it is re-read off where the caption484 // mark as well as the box: it is re-read off where the caption
476 // landed rather than left on the index it had, which after the move485 // landed rather than left on the index it had, which after the move
477- // is a neighbour's. A grouped caption dragged its clips with it --486+ // is a neighbour's. A grouped-with-clips caption dragged media with
478- // the engine reseeks itself, and this owes the flag reset a clip's487+ // it -- the engine reseeks itself, and this owes the flag reset a
479- // drop pays at the same moment.488+ // clip's drop pays at the same moment.
480 Some(Ok(())) => {489 Some(Ok(())) => {
481 let mark = self490 let mark = self
482 .session491 .session
@@ -491,7 +500,7 @@ impl Player {
491 }500 }
492 None => Selection::new(),501 None => Selection::new(),
493 };502 };
494- if drag.sub.link.is_some() {503+ if grouped {
495 self.reset_after_reseek();504 self.reset_after_reseek();
496 }505 }
497 }506 }
@@ -1125,17 +1134,23 @@ impl Player {
1125 // timeline's rate. An `Ok` is *not* "something changed" -- an edge that1134 // timeline's rate. An `Ok` is *not* "something changed" -- an edge that
1126 // stopped at a wall it already stood against is `Ok` with no undo step1135 // stopped at a wall it already stood against is `Ok` with no undo step
1127 // ([`Project::trim_sub`]) -- so only the refusal is ever said out loud.1136 // ([`Project::trim_sub`]) -- so only the refusal is ever said out loud.
1128- // A lone caption's trim moves nothing that plays, and nothing reseeks;1137+ // A lone caption's trim -- and one grouped only with other captions --
1129- // a grouped one trimmed its clips with it, and owes the same flag1138+ // moves nothing that plays and reseeks nothing; a caption grouped with
1130- // reset a clip's trim pays.1139+ // clips trimmed them with it and owes the flag reset a clip's trim
1140+ // pays. The grouped question is asked before the edit moves indices,
1141+ // in the engine's own words, so the two answers can never disagree.
1131 if trim.lane.kind == LaneKind::Subtitle {1142 if trim.lane.kind == LaneKind::Subtitle {
1143+ let grouped = self
1144+ .session
1145+ .as_ref()
1146+ .is_some_and(|session| session.caption_grouped_with_clips(trim.lane, trim.idx));
1132 let trimmed = self1147 let trimmed = self
1133 .session1148 .session
1134 .as_mut()1149 .as_mut()
1135 .map(|session| session.trim_sub(trim.lane, trim.idx, trim.edge, trim.to));1150 .map(|session| session.trim_sub(trim.lane, trim.idx, trim.edge, trim.to));
1136 match trimmed {1151 match trimmed {
1137 Some(Err(e)) => self.notify_user(format!("NOT TRIMMED — {e}").into()),1152 Some(Err(e)) => self.notify_user(format!("NOT TRIMMED — {e}").into()),
1138- Some(Ok(())) if trim.link.is_some() => self.reset_after_reseek(),1153+ Some(Ok(())) if grouped => self.reset_after_reseek(),
1139 _ => {}1154 _ => {}
1140 }1155 }
1141 cx.notify();1156 cx.notify();
crates/engine/src/playback.rsmodified+4 -2
@@ -1866,8 +1866,10 @@ impl PlaybackSession {
1866 1866
1867 /// Whether the caption at `idx` of `lane` is grouped with clips on other1867 /// Whether the caption at `idx` of `lane` is grouped with clips on other
1868 /// lanes: the one question every caption edit that can move media has to1868 /// lanes: the one question every caption edit that can move media has to
1869- // ask first, because the answer is whether the edit owes a reseek.1869+ /// ask first, because the answer is whether the edit owes a reseek -- and
1870- fn caption_grouped_with_clips(&self, lane: Lane, idx: usize) -> bool {1870+ /// the front-end owes the same answer, asked before the edit moves the
1871+ /// indices, so its flag reset matches the engine's reseek exactly.
1872+ pub fn caption_grouped_with_clips(&self, lane: Lane, idx: usize) -> bool {
1871 self.project1873 self.project
1872 .sub_lane(lane)1874 .sub_lane(lane)
1873 .get(idx)1875 .get(idx)