Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix incorrect caching of unconstrained measures #14373

Merged
merged 2 commits into from
Apr 4, 2023
Merged

Conversation

hartez
Copy link
Contributor

@hartez hartez commented Apr 3, 2023

Description of Change

The code to avoid re-measurement in the Layout and ContentView backing controls on iOS was treating re-measures with unconstrained height/width as being duplicate measures and not bothering to re-measure them. However, this is incompatible with the way ScollViews on iOS treat their content. This caused some combinations of layouts (mostly ScrollView at the root, with a Grid as the Content, though there may be others) to behave weirdly during resize operations (mostly visible on macOS/Catalyst when resizing the window).

This change treats re-measures at unconstrained height/width as being unequal to the previous measure, allowing the view to be measured again. It also consolidates the measure caching code from ContentView and LayoutView to reduce duplication.

This may technically re-introduce some unconstrained measurement calls which were avoided by #12627; we'll need to investigate further to see if some of those can be avoided in the future without breaking resizing situations.

Issues Fixed

Weird macOS resizing issues when hosting Grids inside of ScrollViews rooted at the Page level.

@Eilon Eilon added the area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter label Apr 3, 2023
@github-actions
Copy link
Contributor

github-actions bot commented Apr 3, 2023

Thank you for your pull request. We are auto-formatting your source code to follow our code guidelines.

@hartez hartez added the backport/suggested The PR author or issue review has suggested that the change should be backported. label Apr 4, 2023
@rmarinho rmarinho requested a review from mattleibow April 4, 2023 10:14
@mattleibow mattleibow merged commit 8ba6cda into main Apr 4, 2023
@mattleibow mattleibow deleted the fix-macos-resize branch April 4, 2023 16:30
@mattleibow
Copy link
Member

/backport to net7.0

@github-actions
Copy link
Contributor

github-actions bot commented Apr 4, 2023

Started backporting to net7.0: https://github.com/dotnet/maui/actions/runs/4610212525

@github-actions
Copy link
Contributor

github-actions bot commented Apr 4, 2023

@mattleibow backporting to net7.0 failed, the patch most likely resulted in conflicts:

$ git am --3way --ignore-whitespace --keep-non-patch changes.patch

Applying: Fix incorrect caching of unconstrained measures
.git/rebase-apply/patch:19: trailing whitespace.
	
.git/rebase-apply/patch:75: trailing whitespace.
		
.git/rebase-apply/patch:84: trailing whitespace.
			
warning: 3 lines add whitespace errors.
Using index info to reconstruct a base tree...
M	src/Core/src/Platform/iOS/ContentView.cs
M	src/Core/src/Platform/iOS/LayoutView.cs
M	src/Core/src/Platform/iOS/MauiView.cs
M	src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
M	src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
Falling back to patching base and 3-way merge...
Auto-merging src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
CONFLICT (content): Merge conflict in src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt
Auto-merging src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
CONFLICT (content): Merge conflict in src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt
Auto-merging src/Core/src/Platform/iOS/MauiView.cs
CONFLICT (content): Merge conflict in src/Core/src/Platform/iOS/MauiView.cs
Auto-merging src/Core/src/Platform/iOS/LayoutView.cs
CONFLICT (content): Merge conflict in src/Core/src/Platform/iOS/LayoutView.cs
Auto-merging src/Core/src/Platform/iOS/ContentView.cs
CONFLICT (content): Merge conflict in src/Core/src/Platform/iOS/ContentView.cs
error: Failed to merge in the changes.
hint: Use 'git am --show-current-patch=diff' to see the failed patch
Patch failed at 0001 Fix incorrect caching of unconstrained measures
When you have resolved this problem, run "git am --continue".
If you prefer to skip this patch, run "git am --skip" instead.
To restore the original branch and stop patching, run "git am --abort".
Error: The process '/usr/bin/git' failed with exit code 128

Please backport manually!

@github-actions
Copy link
Contributor

github-actions bot commented Apr 4, 2023

@mattleibow an error occurred while backporting to net7.0, please check the run log for details!

Error: git am failed, most likely due to a merge conflict.

rmarinho pushed a commit that referenced this pull request Apr 5, 2023
…4389)

Co-authored-by: E.Z. Hart <hartez@users.noreply.github.com>
@hartez hartez added the backport/approved After some discussion or review, this PR or change was approved to be backported. label May 31, 2023
@github-actions github-actions bot locked and limited conversation to collaborators Dec 12, 2023
@samhouts samhouts added the fixed-in-8.0.0-preview.4.8333 Look for this fix in 8.0.0-preview.4.8333! label Aug 2, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-layout StackLayout, GridLayout, ContentView, AbsoluteLayout, FlexLayout, ContentPresenter backport/approved After some discussion or review, this PR or change was approved to be backported. backport/suggested The PR author or issue review has suggested that the change should be backported. fixed-in-8.0.0-preview.4.8333 Look for this fix in 8.0.0-preview.4.8333!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants