Skip to content

Commit

Permalink
Fix problems importing maps. #1094
Browse files Browse the repository at this point in the history
1) Don't crash when we can't render text
2) Don't spend a long time trying to render very long lines of text in
   loading screens
3) Reduce the length of an info message
  • Loading branch information
dabreegster committed Aug 13, 2023
1 parent 574a9ac commit 8af5584
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 14 deletions.
8 changes: 7 additions & 1 deletion map_gui/src/tools/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,13 @@ impl<A: AppLike + 'static> State<A> for RunCommand<A> {
.small_heading(),
);
for line in &self.lines {
txt.add_line(line);
// Previously, map importing produced some very long lines, which slowed down
// rendering a bunch. The origin of the long output was fixed, but still skip very
// long lines generally -- this is just a loading screen showing command output, no
// need to display everything perfectly.
if line.len() < 300 {
txt.add_line(line);
}
}
self.panel = ctx.make_loading_screen(txt);
self.last_drawn = Instant::now();
Expand Down
4 changes: 2 additions & 2 deletions map_model/src/map.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,8 @@ pub fn turn_type_from_road_geom(
// turn_type_from_angles. Correct it based on relative ordering.
if turn_type != *expected_type {
warn!(
"Turn from {:?} to {:?} looks like {:?} by angle, but is {:?} by ordering",
r1, r2, turn_type, expected_type
"Turn from {} to {} looks like {:?} by angle, but is {:?} by ordering",
r1.orig_id, r2.orig_id, turn_type, expected_type
);
turn_type = *expected_type;
}
Expand Down
15 changes: 6 additions & 9 deletions widgetry/src/svg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -75,15 +75,12 @@ pub(crate) fn add_svg_inner(
if let Some(ref fill) = p.fill {
let color = convert_color(&fill.paint, fill.opacity.get());
let geom = mesh_per_color.mut_or_insert(color, VertexBuffers::new);
if fill_tess
.tessellate(
&convert_path(p),
&tessellation::FillOptions::tolerance(tolerance),
&mut simple_builder(geom),
)
.is_err()
{
return Err("Couldn't tessellate something".to_string());
if let Err(err) = fill_tess.tessellate(
&convert_path(p),
&tessellation::FillOptions::tolerance(tolerance),
&mut simple_builder(geom),
) {
return Err(format!("Couldn't tessellate something: {err}"));
}
}

Expand Down
11 changes: 9 additions & 2 deletions widgetry/src/text.rs
Original file line number Diff line number Diff line change
Expand Up @@ -515,7 +515,11 @@ fn render_line(spans: Vec<TextSpan>, tolerance: f32, assets: &Assets) -> GeomBat
let mut batch = GeomBatch::new();
match crate::svg::add_svg_inner(&mut batch, svg_tree, tolerance) {
Ok(_) => batch,
Err(err) => panic!("render_line({}): {}", contents, err),
Err(err) => {
error!("render_line({}): {}", contents, err);
// We'll just wind up with a blank line
batch
}
}
}

Expand Down Expand Up @@ -618,7 +622,10 @@ impl TextSpan {
let mut batch = GeomBatch::new();
match crate::svg::add_svg_inner(&mut batch, svg_tree, tolerance) {
Ok(_) => batch,
Err(err) => panic!("curvey({}): {}", self.text, err),
Err(err) => {
error!("render_curvey({}): {}", self.text, err);
batch
}
}
}
}

0 comments on commit 8af5584

Please sign in to comment.