You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a case where I got a stackoverflow exception when scrolling down.
The exception is raised in VirtualizingWrapPanel.MeasureOverride call stack.
After investigation, I found out that in some cases, this line may be always true:
line 167: GetY(ScrollOffset) + GetHeight(ViewportSize) > GetHeight(Extent)
This leads to endlessly and recursively call MeasureOverride:
if(ItemsOwner is not IHierarchicalVirtualizationAndScrollInfo&& GetY(ScrollOffset)!=0&& GetY(ScrollOffset)+ GetHeight(ViewportSize)> GetHeight(Extent)){ScrollOffset= CreatePoint(GetX(ScrollOffset), Math.Max(0, GetHeight(Extent)- GetHeight(ViewportSize)));
ScrollOwner?.InvalidateScrollInfo();return MeasureOverride(availableSize);// repeat measure with correct ScrollOffset}
In my case, when crashing, I had:
GetY(ScrollOffset) = 1 231.52314426031
GetHeight(ViewportSize) = 639.4
GetHeight(ViewPortSize) = 1 870.92314426031
With these numbers, the comparison should return false, but it doesn't on my machine, because of double imprecision.
I would suggest to replace: GetY(ScrollOffset) + GetHeight(ViewportSize) > GetHeight(Extent)
by something like: GetY(ScrollOffset) + GetHeight(ViewportSize) - GetHeight(Extent) > SOME_EPSILON
Below is the xaml I am using. Note that the crash happens with a specific set of data (I mean, depending on the set of data the VirtualizingItemsControl is populated with, it may crash or not):
(Setting AllowDifferentSizedItems to True or False doesn't change the bug.)
I don't know how much this tolerance is considered big or not in the context, but if you would prefer to lower it, setting 1e-6 instead of 1e-3 should also work. The bug happens here because of the ~15 digits values that are at the bounds of the double precision.
I have a case where I got a stackoverflow exception when scrolling down.
The exception is raised in VirtualizingWrapPanel.MeasureOverride call stack.
After investigation, I found out that in some cases, this line may be always true:
line 167:
GetY(ScrollOffset) + GetHeight(ViewportSize) > GetHeight(Extent)
This leads to endlessly and recursively call MeasureOverride:
In my case, when crashing, I had:
With these numbers, the comparison should return false, but it doesn't on my machine, because of double imprecision.
I would suggest to replace:
GetY(ScrollOffset) + GetHeight(ViewportSize) > GetHeight(Extent)
by something like:
GetY(ScrollOffset) + GetHeight(ViewportSize) - GetHeight(Extent) > SOME_EPSILON
Below is the xaml I am using. Note that the crash happens with a specific set of data (I mean, depending on the set of data the VirtualizingItemsControl is populated with, it may crash or not):
(Setting AllowDifferentSizedItems to True or False doesn't change the bug.)
Version Info
Package Version: 2.0.10
.NET Version: .NET Framework 4.6.2
OS Version: Windows 11 Business Build 22631.4249
The text was updated successfully, but these errors were encountered: