PanAndZoom
PanAndZoom copied to clipboard
StackOverflow when zooming
Can't reproduce it, but when tried to zoom while scrolling it happen, hopefully the stack trace might help -
@adirh3 Did you get that exception again, I could not repro the issue.
@adirh3 Did you get that exception again, I could not repro the issue.
Yes, I did, I believe it happens when trying to scroll using the scroll bars with Pan disabled. It happens very rarely, will try to make a repro.
I am encountering this issue as well... I have a big image loaded within the zoom area (8255x5504) which makes the GUI kind of slow. From what I can tell, it appears like when the GUI freezes a bit while zooming in and I try to pan using the ScrollViewer bars, I get the StackOverflow at
public static void Main(string[] args) => BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
which makes it tricky to debug.
I happened twice but I am having a hard time trying to get it again. I remember inspecting the exception and the StackTrace was null.
I have the same error, I just used the scroll hard and I moved the scrollbar, it froze and I got that exception, I reproduced the error several times on Desktop
Do you know why this happens?
@adirh3 Did you get that exception again, I could not repro the issue.
@wieslawsoltes Take a look at this. I reproduced the problem. If you pan outside ScrollView and then scroll back using bars the exception is thrown.
I guess I know where the problem is. In the file "ZoomBorder.ILogicalScrollable.cs" at lines 90-91 in function CalculateScrollable variables "offsetX" and "offsetY" are set, The original code is:
var offsetX = ox < 0 ? Abs(ox) : 0;
var offsetY = oy < 0 ? Abs(oy) : 0;
I tried to change this code and after that all worked fine.
var offsetX = ox < 0 ? Abs(ox) - 0.001 : 0.001;
var offsetY = oy < 0 ? Abs(oy) - 0.001 : 0.001;
I know that it is not the right solution, but i hope this will help you fix the problem.
I guess I will just add this under line 91 instead:
if (offsetX == 0 && offsetY == 0)
{
offsetX = 0.001;
}
It should do the trick, right?
I guess I will just add this under line 91 instead:
if (offsetX == 0 && offsetY == 0) { offsetX = 0.001; }
It should do the trick, right?
No, it won't do the trick, because, as far as I'm concerned, the error occurs when offsetX == minValue || offsetX == maxValue || offsetY == minValue || offsetY == maxValue. So, the minValue is zero, because there is the Abs func. But I'm not sure how to consider the maxValue, so in my example I always subtract 0.001.
So in order not to have any exceptions, I suggest this code:
double delta = 0.001;
var offsetX = ox < 0 ? Abs(ox) - delta : delta;
var offsetY = oy < 0 ? Abs(oy) - delta : delta;
is the fix implemented in master branch?