Open matteopolak opened 1 year ago
I forked the branch and added a temporary fix that seems to display fine, I'm sure there's a more permanent fix to the issue though.
Replaced https://github.com/plotters-rs/plotters/blob/next-release-devel/plotters-backend/src/rasterizer/path.rs#L87 with:
if x != f64::INFINITY && y != f64::INFINITY {
buf.push((x.round() as i32, y.round() as i32));
}
I just came across this bug as well and can confirm that @matteopolak's fix works - thank you so much for finding it and saving me lots of debugging time! A slightly nicer version of the fix is:
if x.is_finite() && y.is_finite() {
buf.push((x.round() as i32, y.round() as i32));
}
Describe the bug Under a very specific set of parameters, the call to
draw_series
hangs while still consuming a decent chunk of CPU (14% with a Ryzen 9 6900HS). The scenario is extremely specific, changing the X axis range (out of a certain range), removing any of the three points, changing the stroke width to 1, and changing the dimensions of the plot all fix the issue.To Reproduce
Version Information Tested on nightly and stable
I'm using the
next-release-devel
branch at commit3fe48e3debf13cf053b04a9315e2749b428f4220
(latest at the time of writing), since the release branch crashes with an alignment issue.Edit: the (I presume) overflow is coming somewhere from here: https://github.com/plotters-rs/plotters/blob/next-release-devel/plotters-backend/src/rasterizer/path.rs#L147
Edit: The culprit is somewhere in these few lines: https://github.com/plotters-rs/plotters/blob/next-release-devel/plotters-backend/src/rasterizer/path.rs#L64-L65 .
x
andy
and set tof64::INFINITY
and all of the if statements are skipped, resulting inf64::INFINITY.round() as i32
, which is2147483647
.The following values are computed in
compute_polygon_vertex
:Which results in
(a0 * b1 - a1 * b0).abs()
being 0 (which is less thanf64::EPSILON
) anda_t.0 * b_t.1 - a_t.1 * b_t.0
being 0 (which is both not less than 0.0 and not greater than 0.0), skipping everything.I am not entirely sure what the purpose of this exactly is, but I would be more than happy to submit a PR for it once I figure it out.