Skip to content

Commit

Permalink
Fix play/pause toggle annoyance (#1066)
Browse files Browse the repository at this point in the history
* Fix play/pause toggle annoyance

* wording
  • Loading branch information
emilk committed Feb 3, 2023
1 parent bff1550 commit 5582f61
Showing 1 changed file with 35 additions and 1 deletion.
36 changes: 35 additions & 1 deletion crates/re_viewer/src/misc/time_control.rs
Original file line number Diff line number Diff line change
Expand Up @@ -217,7 +217,7 @@ impl TimeControl {
// Start from beginning if we are at the end:
if let Some(time_points) = times_per_timeline.get(&self.timeline) {
if let Some(state) = self.states.get_mut(&self.timeline) {
if state.time >= max(time_points) {
if max(time_points) <= state.time {
state.time = min(time_points).into();
}
} else {
Expand Down Expand Up @@ -286,6 +286,40 @@ impl TimeControl {
if self.playing {
self.pause();
} else {
// If we are in follow-mode (but paused), what should toggling play/pause do?
//
// There are two cases to consider:
// * We are looking at a file
// * We are following a stream
//
// If we are watching a stream, it makes sense to keep following:
// you paused to look at something, now you're done, so keep following.
//
// If you are watching a file: if the file has finished loading, then
// it can still make sense to go to the end of it.
// But if you're already at the end, then staying at "follow" makes little sense,
// as repeated toggling will just go between paused and follow at the latest data.
// This is made worse by Follow being our default mode (even for files).
//
// As of writing (2023-02) we don't know if we are watching a file or a stream
// (after all, files are also streamed).
//
// So we use a heuristic:
// If we are at the end of the file and unpause, we always start from
// the beginning in play mode.

// Start from beginning if we are at the end:
if let Some(time_points) = times_per_timeline.get(&self.timeline) {
if let Some(state) = self.states.get_mut(&self.timeline) {
if max(time_points) <= state.time {
state.time = min(time_points).into();
self.playing = true;
self.following = false;
return;
}
}
}

if self.following {
self.set_play_state(times_per_timeline, PlayState::Following);
} else {
Expand Down

1 comment on commit 5582f61

@github-actions
Copy link

Choose a reason for hiding this comment

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

Rust Benchmark

Benchmark suite Current: 5582f61 Previous: 46d013c Ratio
datastore/insert/batch/rects/insert 584163 ns/iter (± 1568) 579344 ns/iter (± 2056) 1.01
datastore/latest_at/batch/rects/query 1825 ns/iter (± 1) 1787 ns/iter (± 3) 1.02
datastore/latest_at/missing_components/primary 306 ns/iter (± 0) 307 ns/iter (± 0) 1.00
datastore/latest_at/missing_components/secondaries 379 ns/iter (± 3) 380 ns/iter (± 0) 1.00
datastore/range/batch/rects/query 159056 ns/iter (± 319) 156435 ns/iter (± 359) 1.02
mono_points_arrow/generate_message_bundles 47317708 ns/iter (± 679919) 51703254 ns/iter (± 1008837) 0.92
mono_points_arrow/generate_messages 126372902 ns/iter (± 1124587) 137278741 ns/iter (± 1353090) 0.92
mono_points_arrow/encode_log_msg 150826371 ns/iter (± 1740895) 163394606 ns/iter (± 1438190) 0.92
mono_points_arrow/encode_total 325818904 ns/iter (± 2608865) 353613785 ns/iter (± 1852939) 0.92
mono_points_arrow/decode_log_msg 175345725 ns/iter (± 1747879) 189159518 ns/iter (± 1045564) 0.93
mono_points_arrow/decode_message_bundles 64001123 ns/iter (± 812057) 74387643 ns/iter (± 907705) 0.86
mono_points_arrow/decode_total 239225342 ns/iter (± 1644029) 259352770 ns/iter (± 1988845) 0.92
batch_points_arrow/generate_message_bundles 328146 ns/iter (± 651) 328508 ns/iter (± 2943) 1.00
batch_points_arrow/generate_messages 6136 ns/iter (± 13) 6048 ns/iter (± 17) 1.01
batch_points_arrow/encode_log_msg 358590 ns/iter (± 1482) 361736 ns/iter (± 1400) 0.99
batch_points_arrow/encode_total 720742 ns/iter (± 1644) 725175 ns/iter (± 4081) 0.99
batch_points_arrow/decode_log_msg 351975 ns/iter (± 886) 345237 ns/iter (± 1036) 1.02
batch_points_arrow/decode_message_bundles 2032 ns/iter (± 7) 2044 ns/iter (± 12) 0.99
batch_points_arrow/decode_total 356710 ns/iter (± 1150) 351360 ns/iter (± 1401) 1.02
arrow_mono_points/insert 6115703113 ns/iter (± 16586211) 7078540703 ns/iter (± 19828410) 0.86
arrow_mono_points/query 1719127 ns/iter (± 19335) 1764278 ns/iter (± 7099) 0.97
arrow_batch_points/insert 2604588 ns/iter (± 11742) 2666525 ns/iter (± 19836) 0.98
arrow_batch_points/query 17383 ns/iter (± 84) 17247 ns/iter (± 51) 1.01
tuid/Tuid::random 34 ns/iter (± 0) 34 ns/iter (± 0) 1

This comment was automatically generated by workflow using github-action-benchmark.

Please sign in to comment.