Fix ContentViewRespondsWhenViewRemoved test fails on Catalyst #32481
Merged
StephaneDelcroix merged 5 commits intodotnet:inflight/currentfrom Dec 2, 2025
Merged
Fix ContentViewRespondsWhenViewRemoved test fails on Catalyst #32481StephaneDelcroix merged 5 commits intodotnet:inflight/currentfrom
StephaneDelcroix merged 5 commits intodotnet:inflight/currentfrom
Conversation
Contributor
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
Contributor
There was a problem hiding this comment.
Pull Request Overview
This PR fixes a layout caching issue on iOS/Catalyst where ContentView would retain its cached size after its content was removed. The fix adds measure invalidation logic when content is set to null, ensuring the ContentView can properly resize to 0x0.
Key Changes:
- Added conditional invalidation logic when content is removed from ContentView (checks for non-zero cached bounds before invalidating)
- Re-enabled the previously skipped
ContentViewRespondsWhenViewRemovedtest that was failing due to this issue
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| src/Core/src/Handlers/ContentView/ContentViewHandler.iOS.cs | Adds an else block to UpdateContent that invalidates measures when content is removed and the ContentView has non-zero cached bounds |
| src/Controls/tests/DeviceTests/Elements/ContentView/ContentViewTests.iOS.cs | Removes the Skip attribute from ContentViewRespondsWhenViewRemoved test, re-enabling it now that the underlying issue is fixed |
StephaneDelcroix
approved these changes
Dec 2, 2025
Contributor
StephaneDelcroix
left a comment
There was a problem hiding this comment.
tested on iOS and catalyst
PureWeen
pushed a commit
that referenced
this pull request
Dec 3, 2025
* Update ContentViewHandler.iOS.cs * condition for null * Update ContentViewHandler.iOS.cs * Update ContentViewHandler.iOS.cs * Update ContentViewHandler.iOS.cs
PureWeen
pushed a commit
that referenced
this pull request
Dec 3, 2025
* Update ContentViewHandler.iOS.cs * condition for null * Update ContentViewHandler.iOS.cs * Update ContentViewHandler.iOS.cs * Update ContentViewHandler.iOS.cs
PureWeen
pushed a commit
that referenced
this pull request
Dec 3, 2025
* Update ContentViewHandler.iOS.cs * condition for null * Update ContentViewHandler.iOS.cs * Update ContentViewHandler.iOS.cs * Update ContentViewHandler.iOS.cs
PureWeen
pushed a commit
that referenced
this pull request
Dec 3, 2025
* Update ContentViewHandler.iOS.cs * condition for null * Update ContentViewHandler.iOS.cs * Update ContentViewHandler.iOS.cs * Update ContentViewHandler.iOS.cs
PureWeen
pushed a commit
that referenced
this pull request
Dec 3, 2025
* Update ContentViewHandler.iOS.cs * condition for null * Update ContentViewHandler.iOS.cs * Update ContentViewHandler.iOS.cs * Update ContentViewHandler.iOS.cs
github-actions bot
pushed a commit
that referenced
this pull request
Dec 5, 2025
* Update ContentViewHandler.iOS.cs * condition for null * Update ContentViewHandler.iOS.cs * Update ContentViewHandler.iOS.cs * Update ContentViewHandler.iOS.cs
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.
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!
Issue Description
When content is removed from a ContentView, its height remains cached, leading to layout inconsistencies.
Root Cause
To improve performance, measure caching was introduced in #31485, which reuses previously measured sizes to avoid redundant layout passes. However, when content is removed, the cached size isn’t automatically invalidated. This causes parent layouts to rely on stale measurements. While invalidation was already handled for content updates (#30991), it wasn’t addressed for content removal.
Description of Change
Added InvalidateMeasure calls for both ContentView and its parent when content is set to null and the cached size remains. This ensures proper re-measurement and layout refresh.
Regression PR
PR #31485
PR #30991
Issues Fixed
Fixes #32368
Tested the behaviour on the following platforms
Output Screenshot