Pre-compute Grid star values when possible#12912
Merged
mattleibow merged 1 commit intomainfrom Jan 28, 2023
Merged
Conversation
mattleibow
approved these changes
Jan 28, 2023
Contributor
|
Please guys, can we have these Layout measuring and positioning PR's landing on the next Service Release of .NET 7 rather than .NET 8? I'm still suffering a lot to get my layouts measured and positioned correctly on .NET MAUI. |
Contributor
Author
|
/backport to net7.0 |
Contributor
|
Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/4195741934 |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Description of Change
The current Grid measurement algorithm measures cells in Auto rows/columns more than is strictly necessary; a side-effect of the extra measure at the final Auto row/column size on Windows is that the underlying platform is confused about control size changes and does not report them correctly to the containing controls (thus, the non-update issue reported in #12103).
One of the reasons for the extra measurements stems from updating the sizes of Star rows/columns after all of the Auto values have been determined. The algorithm assumes the need for this any time a cell intersects an Auto row or column in any direction. However, in many cases either the row or column is entirely pre-computable, because the Grid is constrained in that direction and there are no Auto values. In those situations, we can compute the value for Star in that direction up front, and avoid multiple measurements. Pre-computing also means that we have final values for width/height to use with controls where the measurements are interdependent (e.g., with Images where the aspect ratio affects the measurement results, like in #7388).
Pre-computing also means that we can avoid the duplicate measure scenarios originally addressed by #12660, so we no longer need to cache the first measurement values.
These changes pre-compute all cell sizes where possible and avoid secondary measures of Auto values. They also add a benchmark for the GridLayoutManager so we can verify that future fixes don't adversely impact performance.
The benchmark is limited to the performance of the GridLayoutManager specifically; it does not speak to the performance of the Grid on any actual platform.
Benchmarks before these changes:
After these changes:
Issues Fixed
Fixes #12103
Fixes #7388
Fixes #7363
Fixes #11453
Fixes #10799
Fixes #9078
Fixes #5363