fix hang when margin is not a multiple of DPI rounding quantum (#5841) #6012
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.
Addresses #4834
This is a port of a servicing fix in .NET 4.7-4.8.
Description
This hang arises when UseLayoutRounding is set, and the container's top margin is not a multiple of the rounding quantum. VSP uses two offsets from the viewport to the container, one that includes the margin and one that doesn't. It was computing the second and subtracting the margin to obtain the first, but that can give the wrong answer in the situation above. This can lead to infinite re-measures in anchored scrolls.
Fixed by computing the first offset directly from layout information. The two offsets will differ by an amount that is close to the margin size, and rounded to a quantum, but there's no way to know which of the nearby candidates is the right one.
Customer Impact
Hang while scrolling an ItemsControl.
Regression
no
Testing
Ad-hoc around customer scenario.
Standard regression testing.
Risk
Low. Port of a .NETFx servicing fix released earlier this year.