Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash/freeze when zooming out too far in a plot #5737

Merged
merged 1 commit into from
Apr 2, 2024
Merged
Changes from all commits
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
17 changes: 13 additions & 4 deletions crates/re_space_view_time_series/src/space_view_class.rs
Original file line number Diff line number Diff line change
Expand Up @@ -400,15 +400,15 @@ It can greatly improve performance (and readability) in such situations as it pr
.x_axis_formatter(move |time, _, _| {
format_time(
time_type,
time.value as i64 + time_offset,
(time.value as i64).saturating_add(time_offset),
time_zone_for_timestamps,
)
})
.y_axis_width(3) // in digits
.label_formatter(move |name, value| {
let name = if name.is_empty() { "y" } else { name };
let label = time_type.format(
(value.x as i64 + time_offset).into(),
((value.x as i64).saturating_add(time_offset)).into(),
time_zone_for_timestamps,
);

Expand Down Expand Up @@ -803,7 +803,12 @@ fn ns_grid_spacer(

let mut small_spacing_ns = 1;
while width_ns / (next_grid_tick_magnitude_ns(small_spacing_ns) as f64) > max_medium_lines {
small_spacing_ns = next_grid_tick_magnitude_ns(small_spacing_ns);
let next_ns = next_grid_tick_magnitude_ns(small_spacing_ns);
if small_spacing_ns < next_ns {
small_spacing_ns = next_ns;
} else {
break; // we've reached the max
}
}
let medium_spacing_ns = next_grid_tick_magnitude_ns(small_spacing_ns);
let big_spacing_ns = next_grid_tick_magnitude_ns(medium_spacing_ns);
Expand All @@ -828,7 +833,11 @@ fn ns_grid_spacer(
step_size: step_size as f64,
});

current_ns += small_spacing_ns;
if let Some(new_ns) = current_ns.checked_add(small_spacing_ns) {
current_ns = new_ns;
} else {
break;
};
}

marks
Expand Down
Loading