Skip to content

Commit

Permalink
Fix crash on negative radii by instead warning (#1654)
Browse files Browse the repository at this point in the history
* Fix crash on negative radii by instead warning

* Name the offending entity
  • Loading branch information
emilk authored Mar 21, 2023
1 parent 68a2fe2 commit 94d0145
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions crates/re_viewer/src/ui/view_spatial/scene/scene_part/points3d.rs
Original file line number Diff line number Diff line change
Expand Up @@ -93,12 +93,27 @@ impl Points3DPart {
Ok(colors)
}

fn process_radii(
entity_view: &EntityView<Point3D>,
) -> Result<impl Iterator<Item = Size> + '_, QueryError> {
Ok(entity_view
.iter_component::<Radius>()?
.map(|radius| radius.map_or(Size::AUTO, |r| Size::new_scene(r.0))))
fn process_radii<'view>(
ent_path: &EntityPath,
entity_view: &'view EntityView<Point3D>,
) -> Result<impl Iterator<Item = Size> + 'view, QueryError> {
let ent_path = ent_path.clone();
Ok(entity_view.iter_component::<Radius>()?.map(move |radius| {
radius.map_or(Size::AUTO, |r| {
if 0.0 <= r.0 && r.0.is_finite() {
Size::new_scene(r.0)
} else {
if r.0 < 0.0 {
re_log::warn_once!("Found point with negative radius in entity {ent_path}");
} else if r.0.is_infinite() {
re_log::warn_once!("Found point with infinite radius in entity {ent_path}");
} else {
re_log::warn_once!("Found point with NaN radius in entity {ent_path}");
}
Size::AUTO
}
})
}))
}

fn process_labels<'a>(
Expand Down Expand Up @@ -178,7 +193,7 @@ impl Points3DPart {
};

let colors = Self::process_colors(entity_view, ent_path, &annotation_infos)?;
let radii = Self::process_radii(entity_view)?;
let radii = Self::process_radii(ent_path, entity_view)?;

if show_labels && instance_path_hashes_for_picking.len() <= self.max_labels {
// Max labels is small enough that we can afford iterating on the colors again.
Expand Down

1 comment on commit 94d0145

@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: 94d0145 Previous: 1daccc1 Ratio
datastore/insert/batch/rects/insert 566562 ns/iter (± 7478) 562453 ns/iter (± 2003) 1.01
datastore/latest_at/batch/rects/query 1831 ns/iter (± 8) 1837 ns/iter (± 59) 1.00
datastore/latest_at/missing_components/primary 288 ns/iter (± 1) 286 ns/iter (± 0) 1.01
datastore/latest_at/missing_components/secondaries 436 ns/iter (± 3) 437 ns/iter (± 0) 1.00
datastore/range/batch/rects/query 150550 ns/iter (± 951) 150325 ns/iter (± 173) 1.00
mono_points_arrow/generate_message_bundles 47150224 ns/iter (± 1548787) 47067557 ns/iter (± 1364902) 1.00
mono_points_arrow/generate_messages 130906805 ns/iter (± 3817084) 138154484 ns/iter (± 1379507) 0.95
mono_points_arrow/encode_log_msg 162965124 ns/iter (± 2493172) 165975611 ns/iter (± 745353) 0.98
mono_points_arrow/encode_total 343179549 ns/iter (± 4702808) 356463179 ns/iter (± 1818683) 0.96
mono_points_arrow/decode_log_msg 181744000 ns/iter (± 1916321) 187424099 ns/iter (± 1141287) 0.97
mono_points_arrow/decode_message_bundles 66929024 ns/iter (± 1066630) 74078728 ns/iter (± 1154499) 0.90
mono_points_arrow/decode_total 246404122 ns/iter (± 5461051) 256947321 ns/iter (± 1984180) 0.96
batch_points_arrow/generate_message_bundles 327367 ns/iter (± 3518) 327643 ns/iter (± 382) 1.00
batch_points_arrow/generate_messages 6410 ns/iter (± 86) 6528 ns/iter (± 18) 0.98
batch_points_arrow/encode_log_msg 354210 ns/iter (± 2611) 353650 ns/iter (± 1416) 1.00
batch_points_arrow/encode_total 709849 ns/iter (± 4008) 705276 ns/iter (± 2144) 1.01
batch_points_arrow/decode_log_msg 351622 ns/iter (± 2421) 346701 ns/iter (± 582) 1.01
batch_points_arrow/decode_message_bundles 2069 ns/iter (± 21) 2053 ns/iter (± 10) 1.01
batch_points_arrow/decode_total 354317 ns/iter (± 2234) 350877 ns/iter (± 585) 1.01
arrow_mono_points/insert 6292242598 ns/iter (± 44991763) 6964766015 ns/iter (± 99535929) 0.90
arrow_mono_points/query 1766027 ns/iter (± 37805) 1756383 ns/iter (± 9886) 1.01
arrow_batch_points/insert 2630768 ns/iter (± 53625) 2716339 ns/iter (± 52869) 0.97
arrow_batch_points/query 16171 ns/iter (± 86) 16138 ns/iter (± 18) 1.00
arrow_batch_vecs/insert 43427 ns/iter (± 317) 42719 ns/iter (± 93) 1.02
arrow_batch_vecs/query 389035 ns/iter (± 3632) 389272 ns/iter (± 853) 1.00
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.