Repository navigation
[iOS] Fix collapsed layouts staying unmeasured after becoming visible - #40894
Conversation
MauiView latches _measureInvalidatedPropagated to stop redundant measure invalidation propagation (dotnet#33459). The flag was left set in two cases where no later measure or layout pass resets it before the next real change: - A hidden (IsVisible=false) view is skipped by its parent's measure and arrange, so the flag set while hidden swallowed the invalidation raised when it became visible again. Don't latch the flag while hidden, and reset it when Hidden changes. - Measuring descendants in SizeThatFits can invalidate them again (for example when content is updated during measure), latching the flag while the new size is cached as valid. Reset it after caching the measure. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
🔵 Needs a closer look
The shared MauiView invalidation change needs platform-owner confirmation because runtime evidence comes from another branch, while target-branch and Mac Catalyst native layout behavior remain unverified.
No open issues 🎉
What changed in this PR
Fixes #40893, a regression from #33459 where collapsed layouts could remain at zero size after becoming visible on iOS and Mac Catalyst. The change adjusts MauiView’s measure-invalidation tracking so later size changes can reach ancestor views.
Changes:
- Avoid latching invalidation propagation while hidden, and reset it when visibility changes or measurement completes.
- Add a device regression test that reveals a collapsed layout during arrange inside a
ScrollView. - Record the
Hiddenoverride in both Apple-platform public API files.
| File | Description |
|---|---|
| src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt | Records the Hidden override for Mac Catalyst. |
| src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt | Records the Hidden override for iOS. |
| src/Core/src/Platform/iOS/MauiView.cs | Resets invalidation tracking after measurement and visibility changes; avoids latching while hidden. |
| src/Controls/tests/DeviceTests/Elements/Layout/LayoutTests.iOS.cs | Adds coverage for a collapsed layout becoming visible during arrange. |
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Expert Review — No findings
Reviewed commit 2c39636.
This comment has been minimized.
This comment has been minimized.
| // A hidden view is skipped by its parent's measure and arrange, so SizeThatFits and | ||
| // LayoutSubviews would never run to reset the flag. Don't latch it while hidden, | ||
| // or the invalidation raised when the view becomes visible again would be swallowed. | ||
| if (!Hidden) |
There was a problem hiding this comment.
[moderate] Performance-Critical Path Optimization - This disables invalidation coalescing for the entire time a view remains hidden. Changing Padding and Spacing repeatedly on an attached collapsed VerticalStackLayout now propagates every invalidation through its hidden, non-fixed-size ancestors: ViewExtensions.InvalidateAncestorsMeasures calls each ancestor's InvalidateMeasure, clearing its cache and calling SetNeedsLayout, until a visible ancestor can coalesce. Previously only the first invalidation traversed that chain. This restores repeated ancestor-walk work during binding updates to hidden panels, which #33459 avoided. Preserve coalescing while hidden and reset it on visibility transitions instead; the new Hidden override already provides that reset. Add coverage that repeated invalidations coalesce while hidden and propagate again after showing the view.
Selected Tests🧪 Test selection — click to expand
🧪 UI tests — the full suite on every platform❌ Could not queue GPT-6.2 Sol: Run all iOS and Mac Catalyst UI categories because the shared Apple MauiView measure invalidation path changed. 🧪 Running — 77 categories on Android, iOS, MacCatalyst, WindowsThe complete 🧪 Device tests —
|
| Platform | Categories |
|---|---|
| iOS | Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
| MacCatalyst | Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
⏭️ Skipped — what neither suite runs
Device tests — 3 categories, 2 platforms
Platforms not run: Android, Windows
Categories not run: Graphics, Essentials, BlazorWebView
Each skipped platform and project is listed as a maui-pr-devicetests (skipped) … status on this commit. Use /azp run maui-pr-devicetests for the full suite.
🤖 Why these tests — AI rationale (GPT-6.2 Sol + MAI Code 2)
UI tests
Each model chose independently; every test that runs was selected by at least one of them.
| Platform | GPT-6.2 Sol | MAI Code 2 |
|---|---|---|
| Android | — | all categories |
| iOS | Accessibility, ActionSheet, ActivityIndicator, Animation, Border, BoxView, Brush, Button, CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7, Cells, CheckBox, ContextActions, CustomRenderers, DatePicker, Dispatcher, DisplayAlert, DragAndDrop, Entry, Editor, FlyoutPage, Focus, Fonts, Frame, Gestures, GraphicsView, Image, ImageButton, IndicatorView, InputTransparent, IsEnabled, IsVisible, Label, Layout, Lifecycle, ManualReview, Maps, Navigation, Page, Performance, Picker, ProgressBar, RadioButton, RefreshView, SafeAreaEdges, Shadow, ScrollView, SearchBar, Shape, Slider, SoftInput, Stepper, Switch, SwipeView, Shell1, Shell2, TabbedPage, TableView, TimePicker, TitleView, ToolbarItem, Triggers, ViewBaseTests, VisualStateManager, Window, WebView |
all categories |
| MacCatalyst | Accessibility, ActionSheet, ActivityIndicator, Animation, Border, BoxView, Brush, Button, CarouselView, CollectionView1, CollectionView2, CollectionView3, CollectionView4, CollectionView5, CollectionView6, CollectionView7, Cells, CheckBox, ContextActions, CustomRenderers, DatePicker, Dispatcher, DisplayAlert, DragAndDrop, Entry, Editor, FlyoutPage, Focus, Fonts, Frame, Gestures, GraphicsView, Image, ImageButton, IndicatorView, InputTransparent, IsEnabled, IsVisible, Label, Layout, Lifecycle, ManualReview, Maps, Navigation, Page, Performance, Picker, ProgressBar, RadioButton, RefreshView, SafeAreaEdges, Shadow, ScrollView, SearchBar, Shape, Slider, SoftInput, Stepper, Switch, SwipeView, Shell1, Shell2, TabbedPage, TableView, TimePicker, TitleView, ToolbarItem, Triggers, ViewBaseTests, VisualStateManager, Window, WebView |
all categories |
| Windows | — | all categories |
GPT-6.2 Sol — Run all iOS and Mac Catalyst UI categories because the shared Apple MauiView measure invalidation path changed.
- MauiView changes visibility and measure invalidation for Apple view hierarchies, so run every enabled category on iOS and Mac Catalyst.
- Android and Windows do not compile this path; the PublicAPI files only record the override.
MAI Code 2 — iOS/MacCatalyst MauiView measure invalidation fix; run full UI coverage because it changes the shared platform measure pipeline.
MauiView.SizeThatFitsand invalidation propagation affect measurement for all views, so UI coverage must include the full iOS and Mac Catalyst suites.- The changed file is in
Platform/iOS; Android and Windows are deliberately excluded because they do not compile this implementation. - The fix targets hidden/collapsed views and invalidation during measure, making partial
LayoutorScrollViewcoverage too narrow.
Device tests
Each model chose independently; every test that runs was selected by at least one of them.
| Platform | GPT-6.2 Sol | MAI Code 2 |
|---|---|---|
| Android | — | — |
| iOS | Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
| MacCatalyst | Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
Controls.Accessibility, Controls.Animations, Controls.Application, Controls.Behavior, Controls.Border, Controls.BoxView, Controls.Button, Controls.CarouselView, Controls.CheckBox, Controls.CollectionView, Controls.Compatibility, Controls.ContentView, Controls.DatePicker, Controls.Dispatcher, Controls.Editor, Controls.Element, Controls.Entry, Controls.FlexLayout, Controls.FlyoutPage, Controls.Frame, Controls.Gesture, Controls.HybridWebView, Controls.Image, Controls.Label, Controls.Layout, Controls.Lifecycle, Controls.Map, Controls.Mapper, Controls.Memory, Controls.MenuFlyout, Controls.Modal, Controls.NavigationPage, Controls.Page, Controls.PageTransitions, Controls.Path, Controls.Picker, Controls.RadioButton, Controls.RefreshView, Controls.ScrollView, Controls.SearchBar, Controls.Shape, Controls.Shell, Controls.Slider, Controls.SwipeView, Controls.Switch, Controls.TabbedPage, Controls.TemplatedView, Controls.TextInput, Controls.Toolbar, Controls.View, Controls.VisualElement, Controls.VisualElementTree, Controls.WebView, Controls.Window, Controls.WindowOverlay, Controls.Xaml, Core.ActivityIndicator, Core.Animation, Core.Application, Core.Border, Core.BoxView, Core.Button, Core.CheckBox, Core.ContentView, Core.DatePicker, Core.Dispatcher, Core.Editor, Core.Element, Core.Entry, Core.FlowDirection, Core.FlyoutView, Core.Fonts, Core.Formatting, Core.Graphics, Core.GraphicsView, Core.Image, Core.ImageButton, Core.ImageSource, Core.IndicatorView, Core.Label, Core.Layout, Core.Lifecycle, Core.MauiContext, Core.Memory, Core.NavigationPage, Core.Page, Core.Picker, Core.ProgressBar, Core.RadioButton, Core.RefreshView, Core.ScrollView, Core.SearchBar, Core.ShapeView, Core.Slider, Core.Stepper, Core.SwipeView, Core.Switch, Core.TimePicker, Core.View, Core.WebView, Core.Window, Core.WindowOverlay |
| Windows | — | — |
GPT-6.2 Sol — Run Controls and Core device tests on iOS and Mac Catalyst for the MauiView measure change, including the new layout regression.
- MauiView changes how hidden views and invalidations during measure propagate to ancestors, affecting both Controls and Core on iOS and Mac Catalyst.
- Controls.Layout covers the new regression: a collapsed FlexLayout becomes visible during arrange inside a ScrollView.
- Android, Windows, and the standalone Graphics, Essentials, and BlazorWebView projects are not affected by this change.
MAI Code 2 — iOS/MacCatalyst MauiView layout-measure fix; run all Controls and Core device-test units, including the new Controls.Layout regression test.
MauiViewis base platform measurement and invalidation infrastructure, so the whole Controls and Core device suites are affected rather than only one control.- The changed
LayoutTests.iOS.cstest adds the requiredControls.Layoutcategory, which is covered byControls. - Android and Windows are excluded; the implementation change is specific to the iOS platform layer, with Mac Catalyst also compiling it.
- Graphics, Essentials, and BlazorWebView are omitted because they are not affected by this measure-invalidation change.
Generated by /review run-tests. A targeted run is a fast signal, not full-suite certification.
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
|
Resolved the iOS and Mac Catalyst API inventory conflicts with @dalexsoto stamp |
There was a problem hiding this comment.
🔵 Needs a closer look
The change affects invalidation behavior across all UIKit MauiView layouts, but runtime evidence comes from another branch and excludes Mac Catalyst, leaving current-revision layout correctness and repeated-invalidation behavior unverified.
No open issues 🎉
Review effort: Balanced
This comment has been minimized.
This comment has been minimized.
…oop (#40907) <!-- copilot-assessment:v1 --> ### Agent assessment Self-reported assessment, not an independent review. Assessed revision: `9b2c5d0dd5f7fd92922bd91a2c5b071353cd2474` | Dimension | Assessment | Rationale | |---|---|---| | Change confidence | 8.5/10 | ↑ Decision replayed on #40894's real test comment: stale error → re-run tests, repeated error → done with "Could not run".<br>↑ Workflow compiles.<br>↓ Live run pending merge (AzDO still not queueing builds, so it will exercise this path). | | Diagnosis confidence | 9.5/10 | ↑ #40894 and 5 contributor PRs stopped at `needs-maintainer-decision` only because dnceng-public queued no builds. | | Evidence fit | 9/10 | ↑ Matches the maintainer request: a missing test run should not block conflicts and earlier findings. | <!-- /copilot-assessment --> <!-- Please let the below note in for people that find this PR --> > [!NOTE] > Are you waiting for the changes in this PR to be merged? > It would be very helpful if you could [test the resulting artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from this PR and let us know in a comment if this change resolves your issue. Thank you! ### Description of Change When `/review run-tests` cannot complete (NOT QUEUED, error, canceled) during the loop, Autopilot stopped with "needs maintainer decision" (e.g. #40894). Conflicts, expert findings and review threads are already handled before the tests stage, so the test run should not block the outcome. Now, after the existing one retry, an incomplete test run finishes the loop as **Ready for maintainer review**, with the Tests row showing "⚠️ Could not run; re-run `/review run-tests` when CI is available". Docs table updated. Validation: replayed the stage decision against #40894's real test comment; `gh aw compile maui-expert-autopilot` succeeds. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
…40906) ### Description of Change On iOS, when a view inside a `Border` changes a child's `WidthRequest`/`HeightRequest` in its own `SizeChanged` handler, the child keeps its old bounds. The same code works outside a Border (as page content, in a Grid cell, in a ContentView) and on Android. What happens, traced on `net11`: 1. `Border.LayoutSubviews` arranges the host view. The host's `SizeChanged` sets the child's size requests. The invalidation clears the host's measure cache and marks the host and the Border for layout, then stops at the Border because the Border has a fixed size. Unlike ContentView, TemplatedView and Grid, Border doesn't override `ComputeConstraintForView`, so the host inside it isn't treated as fixed. 2. In the same pass, `host.LayoutSubviews` runs. Its superview is responsible for measuring it, so it doesn't measure, and it arranges the child with the stale desired size (46x90.5 in the repro). 3. On the next pass the Border measures the host again and gets the right size, but the host's frame doesn't change, so `host.LayoutSubviews` never runs again and the child stays small. When the host is fixed (the working cases), the invalidation stops at the host, which measures again in its own layout pass. With this PR, when `MauiView.SizeThatFits` has to measure because the cache was cleared, it also calls `SetNeedsLayout()`. After an invalidation, the invalidation's own `SetNeedsLayout` is normally still pending, so the extra call changes nothing. It only matters when the view's layout already ran with stale sizes, as in step 2. It can't loop, because `LayoutSubviews` measures through `CrossPlatformMeasure`, not `SizeThatFits`. With the fix the child is arranged at 46x90.5 and then at 360x360, the same two steps the issue shows on Android. About #40894: I applied its `MauiView` change on `net11` and it doesn't fix this case. Here `_measureInvalidatedPropagated` never blocks an invalidation. Both PRs touch `MauiView.SizeThatFits`, but not the same lines, and #40894's patch applies cleanly on top of this one. ### Tests `BorderTests.SizeRequestsSetInSizeChangedApplyInsideBorder` (Controls device tests, iOS and Mac Catalyst): a 200x300 Border holds a ContentView whose `SizeChanged` sets a centered Grid's size requests to the smaller of its width and height. The test waits up to 2 s for the Grid to reach that size. | iOS 26.5 simulator | Without the fix | With the fix | |---|---|---| | Border | 6 passed, 1 failed (`The square kept its old bounds instead of the size requests set in SizeChanged`) | 7 passed | | Layout | 34 passed, 1 skipped | 34 passed, 1 skipped | With the fix, the ContentView (4/4), ScrollView (14 passed, 1 skipped), Frame (25/25) and Page (5/5) categories pass as well. **Before / after** (Sandbox app, iPhone 17 simulator, iOS 26.5): the "keep it square" board from the AbsoluteLayout docs, inside a Border. | Before: the board keeps its first, tiny size | After: the board is square | |---|---| |  |  | Full clips: [before.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/40808-before.mp4) · [after.mp4](https://raw.githubusercontent.com/MykhailoDav/maui/media-pr-2026-11-12/40808-after.mp4) Not checked: Mac Catalyst (shared code; the test is compiled for it), Release/AOT builds, and performance. The extra `SetNeedsLayout` only has an effect in the stale-layout case above. ### Issues Fixed Fixes #40808 --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com> Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Co-authored-by: Jakub Florkowski <kubaflo123@gmail.com>
Agent assessment
Self-reported assessment, not an independent review.
Assessed revision:
2c39636936c735896d9c2e22795cf80134ec61fc↑ All 35 LayoutTests and the ScrollView category pass on the
net11.0branch.↓ Validated on
net11.0;mainbuilds need a .NET 12 SDK I did not have, though the touched code is identical.↓ Mac Catalyst not run separately.
_measureInvalidatedPropagatedflag on the affected views with logging in a real app.↑ Each part of the fix is needed: removing either one makes a repro fail.
Note
Are you waiting for the changes in this PR to be merged?
It would be very helpful if you could test the resulting artifacts from this PR and let us know in a comment if this change resolves your issue. Thank you!
Description of Change
#33459 made iOS
MauiViewskip repeated measure invalidation with the_measureInvalidatedPropagatedflag, which is reset when the view is measured (SizeThatFits) or laid out (LayoutSubviews). In two cases the flag stays set and a later, real invalidation stops at the view, so its ancestors never re-measure:Hidden, and reset it wheneverHiddenchanges.SizeThatFitsresets the flag before measuring descendants. If that measure invalidates a descendant again, the flag is latched while the fresh size is cached as valid.Adds
CollapsedLayoutMadeVisibleDuringArrangeIsMeasuredto the iOS layout device tests: a collapsedFlexLayoutmade visible fromOnSizeAllocatedinside aScrollView. It fails without this change and passes with it.Issues Fixed
Fixes #40893