Skip to content

Commit

Permalink
Bug fix: always show latest data in follow-mode (#7425)
Browse files Browse the repository at this point in the history
### What
* Found while testing #7422

Always show the latest data in follow-mode, by advancing the time at the
start of the frame rather than at the end of it.

### Checklist
* [x] I have read and agree to [Contributor
Guide](https://github.com/rerun-io/rerun/blob/main/CONTRIBUTING.md) and
the [Code of
Conduct](https://github.com/rerun-io/rerun/blob/main/CODE_OF_CONDUCT.md)
* [x] I've included a screenshot or gif (if applicable)
* [x] I have tested the web demo (if applicable):
* Using examples from latest `main` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7425?manifest_url=https://app.rerun.io/version/main/examples_manifest.json)
* Using full set of examples from `nightly` build:
[rerun.io/viewer](https://rerun.io/viewer/pr/7425?manifest_url=https://app.rerun.io/version/nightly/examples_manifest.json)
* [x] The PR title and labels are set such as to maximize their
usefulness for the next release's CHANGELOG
* [x] If applicable, add a new check to the [release
checklist](https://github.com/rerun-io/rerun/blob/main/tests/python/release_checklist)!
* [x] If have noted any breaking changes to the log API in
`CHANGELOG.md` and the migration guide

- [PR Build Summary](https://build.rerun.io/pr/7425)
- [Recent benchmark results](https://build.rerun.io/graphs/crates.html)
- [Wasm size tracking](https://build.rerun.io/graphs/sizes.html)

To run all checks from `main`, comment on the PR with `@rerun-bot
full-check`.
  • Loading branch information
emilk authored Sep 16, 2024
1 parent 46c970e commit 17fb079
Showing 1 changed file with 37 additions and 35 deletions.
72 changes: 37 additions & 35 deletions crates/viewer/re_viewer/src/app_state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ impl AppState {
focused_item,
};

// We move the time at the very start of the frame,
// so that we always show the latest data when we're in "follow" mode.
move_time(&ctx, recording, rx);

// Update the viewport. May spawn new views and handle queued requests (like screenshots).
viewport.on_frame_start(&ctx);

Expand Down Expand Up @@ -466,41 +470,6 @@ impl AppState {
// Process deferred layout operations and apply updates back to blueprint
viewport.update_and_sync_tile_tree_to_blueprint(&ctx);

{
// We move the time at the very end of the frame,
// so we have one frame to see the first data before we move the time.
let dt = ui.ctx().input(|i| i.stable_dt);

// Are we still connected to the data source for the current store?
let more_data_is_coming = if let Some(store_source) = &recording.data_source {
rx.sources().iter().any(|s| s.as_ref() == store_source)
} else {
false
};

let recording_needs_repaint = ctx.rec_cfg.time_ctrl.write().update(
recording.times_per_timeline(),
dt,
more_data_is_coming,
);

let blueprint_needs_repaint = if ctx.app_options.inspect_blueprint_timeline {
ctx.blueprint_cfg.time_ctrl.write().update(
ctx.store_context.blueprint.times_per_timeline(),
dt,
more_data_is_coming,
)
} else {
re_viewer_context::NeedsRepaint::No
};

if recording_needs_repaint == re_viewer_context::NeedsRepaint::Yes
|| blueprint_needs_repaint == re_viewer_context::NeedsRepaint::Yes
{
ui.ctx().request_repaint();
}
}

if WATERMARK {
ui.ctx().paint_watermark();
}
Expand Down Expand Up @@ -537,6 +506,39 @@ impl AppState {
}
}

fn move_time(ctx: &ViewerContext<'_>, recording: &EntityDb, rx: &ReceiveSet<LogMsg>) {
let dt = ctx.egui_ctx.input(|i| i.stable_dt);

// Are we still connected to the data source for the current store?
let more_data_is_coming = if let Some(store_source) = &recording.data_source {
rx.sources().iter().any(|s| s.as_ref() == store_source)
} else {
false
};

let recording_needs_repaint = ctx.rec_cfg.time_ctrl.write().update(
recording.times_per_timeline(),
dt,
more_data_is_coming,
);

let blueprint_needs_repaint = if ctx.app_options.inspect_blueprint_timeline {
ctx.blueprint_cfg.time_ctrl.write().update(
ctx.store_context.blueprint.times_per_timeline(),
dt,
more_data_is_coming,
)
} else {
re_viewer_context::NeedsRepaint::No
};

if recording_needs_repaint == re_viewer_context::NeedsRepaint::Yes
|| blueprint_needs_repaint == re_viewer_context::NeedsRepaint::Yes
{
ctx.egui_ctx.request_repaint();
}
}

fn recording_config_entry<'cfgs>(
configs: &'cfgs mut HashMap<StoreId, RecordingConfig>,
id: StoreId,
Expand Down

0 comments on commit 17fb079

Please sign in to comment.