SignalXY: Fix bug where extrapolated pixel location could be infinity and crash GDI#1806
Merged
swharden merged 5 commits intoScottPlot:mainfrom Apr 28, 2022
Merged
Conversation
This was referenced Apr 27, 2022
Overflows are commonly thrown by GDI (so they are typically ignored), but an overflow may result in a plottable not being rendered, so it is helpful to enable this exception during debugging. ScottPlot#1803 ScottPlot#1808
Member
|
@StendProg, thank you so much for figuring this out! I really appreciate your work on this PR.
I added an option to throw this exception, hopefully making debugging easier in the future. plt.GetSettings(false).IgnoreOverflowExceptionsDuringRender = false;Throwing exceptions while drawing lines with large pixel coordinate values seems like a GDI-specific issue, so a lot of this complexity may disappear when we switch to SkiaSharp and/or Maui.Graphics 🤞 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Purpose:
Fix for #1803
SignalXY in some cases, due to rounding errors when converting to
PointF, thePointBeforehas the same x coordinate as the first drawn point. As a result, interpolation between these points results in anOverflow Exception. Although ScottPlot catches this exception and continues to work, it becomes impossible to display SignalXY.Since interpolation between these points was introduced for only one reason - GDI does not correctly draw points with strongly negative coordinates. In our case, the error occurs when both points have a coordinate close to 0. Therefore, this fix simply skips interpolation if the x coordinates are equal, because it is definitely not needed in this case.
I decided to keep the test that I used to reproduce the error, but it can be safely removed, because it can only be useful for manual debugging.