-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Change iOS SetNeedsLayout propagation mechanism #26629
Change iOS SetNeedsLayout propagation mechanism #26629
Conversation
src/Controls/tests/DeviceTests/Elements/CarouselView/CarouselViewTests.cs
Show resolved
Hide resolved
2ad0ab2
to
5b5e4b9
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HeaderAndFooterRender failing with CollectionView2 https://dev.azure.com/xamarin/public/_build/results?buildId=130764&view=ms.vss-test-web.build-test-results-tab&runId=3507758&resultId=100038&paneView=debug
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 8 out of 23 changed files in this pull request and generated 1 comment.
Files not reviewed (15)
- src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt: Language not supported
- src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt: Language not supported
- src/Controls/tests/TestCases.HostApp/Issues/Issue24996.xaml: Language not supported
- src/Core/src/Platform/iOS/LayoutView.cs: Evaluated as low risk
- src/Controls/src/Core/Compatibility/Handlers/iOS/FrameRenderer.cs: Evaluated as low risk
- src/Controls/tests/DeviceTests/Elements/CarouselView/CarouselViewTests.cs: Evaluated as low risk
- src/Core/src/Platform/iOS/PageViewController.cs: Evaluated as low risk
- src/Core/src/Platform/iOS/MauiView.cs: Evaluated as low risk
- src/Core/src/Handlers/Layout/LayoutHandler.iOS.cs: Evaluated as low risk
- src/Controls/src/Core/Compatibility/Handlers/iOS/VisualElementRenderer.cs: Evaluated as low risk
- src/Core/src/Platform/iOS/MauiScrollView.cs: Evaluated as low risk
- src/Controls/src/Core/Handlers/Items/iOS/MauiCollectionView.cs: Evaluated as low risk
- src/Core/src/Handlers/ScrollView/ScrollViewHandler.iOS.cs: Evaluated as low risk
- src/Core/src/Platform/iOS/IMauiPlatformView.cs: Evaluated as low risk
- src/Core/src/Platform/iOS/PageView.cs: Evaluated as low risk
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Copilot reviewed 8 out of 23 changed files in this pull request and generated no comments.
Files not reviewed (15)
- src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt: Language not supported
- src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt: Language not supported
- src/Controls/tests/TestCases.HostApp/Issues/Issue24996.xaml: Language not supported
- src/Core/src/Platform/iOS/LayoutView.cs: Evaluated as low risk
- src/Controls/tests/DeviceTests/Elements/CarouselView/CarouselViewTests.cs: Evaluated as low risk
- src/Controls/src/Core/Compatibility/Handlers/iOS/FrameRenderer.cs: Evaluated as low risk
- src/Core/src/Platform/iOS/PageViewController.cs: Evaluated as low risk
- src/Core/src/Platform/iOS/MauiView.cs: Evaluated as low risk
- src/Core/src/Handlers/Layout/LayoutHandler.iOS.cs: Evaluated as low risk
- src/Controls/src/Core/Compatibility/Handlers/iOS/VisualElementRenderer.cs: Evaluated as low risk
- src/Core/src/Platform/iOS/MauiScrollView.cs: Evaluated as low risk
- src/Controls/src/Core/Handlers/Items/iOS/MauiCollectionView.cs: Evaluated as low risk
- src/Core/src/Handlers/ScrollView/ScrollViewHandler.iOS.cs: Evaluated as low risk
- src/Core/src/Platform/iOS/PageView.cs: Evaluated as low risk
- src/Core/src/Platform/iOS/IMauiPlatformView.cs: Evaluated as low risk
Comments suppressed due to low confidence (3)
src/Controls/tests/TestCases.HostApp/Issues/Issue26629.cs:22
- [nitpick] The variable name 'i' is ambiguous. It should be renamed to 'labelCounter'.
var i = 0;
src/Core/src/Platform/iOS/ViewExtensions.cs:288
- Ensure that the new behavior introduced by the InvalidateMeasure method is covered by tests.
public static void InvalidateMeasure(this UIView platformView, IView view)
src/Core/src/Platform/iOS/ViewExtensions.cs:308
- Ensure that the new behavior introduced by the InvalidateAncestorsMeasures method is covered by tests.
internal static void InvalidateAncestorsMeasures(this UIView child)
21dd5bf
to
e861dc4
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
1967ec8
to
ce2cc4b
Compare
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
@mattleibow this is the Windows one, so it looked correct to me. The image has no height, true, but it also has |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
-
For the PageView type can we just do something possibly a little silly until we address the "potential improvement" comment? Like, just add an internal property on
MauiView
that can be used to do the same thing? My worry here is that in some cases users are probably inheriting fromContentView
and providing their own type for the PageHandler. So, if we just set something inside theSetVirtualView
part of the PageHandler that enables the same short circuiting that won't break anyone. If we're going to change the type here, we'd probably want to do that through a new handler. -
I wonder if we can just get rid of the
InvalidateMeasure
on IPlatformMeasureInvalidationController- AFAICT the only types that benefits from this are ScrollView/CollectionView. Everyone else just calls SetNeedsLayout from this
- for ScrollView can the code that's in there just move to an override of
SetNeedsLayout
? - For collectionView we could just special case it inside "InvalidateAncestorsMeasures" for now since it is the only outlier. I would just be curious as we implement the code for optimizing propagation if this also becomes somewhat unnecessary. We're already special casing UIScrollView inside
InvalidateAncestorsMeasures
so once we evolve this solution a bit then we can hopefully shed these special cases a bit?
aef3942
to
28e4710
Compare
As per our conversation, this has been implemented through a new
I don't think we can do this, let me explain.
This made me think, so I've looked again at |
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added 2 questions.
double widthRatio = constrainedWidth / contentWidth; | ||
double heightRatio = constrainedHeight / contentHeight; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To confirm what I am thinking, this is the size used to determine the size of the control, so you are including the padding in here because iOS does not have a [padding concept?
But, as @PureWeen mentioned - should it be used in the aspect ratio calculations? Maybe it should be added on after the size calculations? For example, if I have a landscape image, but massive padding on top/bottom that makes it become a portrait scale. Will it cause issues with stretch?
Maybe I am thinking wrong here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good call, I've updated the algorithm as follows:
- Remove padding from constraints
- Compute desired size on reduced constraints
- Add padding back
/azp run |
Azure Pipelines successfully started running 3 pipeline(s). |
Description of Change
I've been asked to split #25664 into separate PR.
This is the first piece which aims to change the way we propagate
SetNeedsLayout
by doing that only when MAUI commands.SetNeedsLayout
is being invoked by iOSSetNeedsLayout
and don't care about propagation anymoreThis also enables us to receive a
SetNeedsLayout
inTemplatedCell
which will allow us to resize the cell without relaying onMeasureInvalidated
cross platform event propagation.There will be a follow-up PR to tackle this.
Issues Fixed
Fixes #24996