[Android] Fix control size properties not available during Loaded event#31590
[Android] Fix control size properties not available during Loaded event#31590kubaflo merged 5 commits intodotnet:inflight/currentfrom
Conversation
|
Hey there @@Vignesh-SF3580! Thank you so much for your PR! Someone from the team will get assigned to your PR shortly and we'll get it reviewed. |
|
/azp run MAUI-UITests-public |
|
Azure Pipelines successfully started running 1 pipeline(s). |
There was a problem hiding this comment.
Pull Request Overview
This PR fixes an Android-specific issue where control size properties (Height and Width) were not available during the Loaded event because the event fired before the layout pass completed.
- Modified the OnLoaded method to use
view.Post()to defer action execution until after layout completion - Added comprehensive UI tests to validate the fix works correctly
- Ensures size properties are properly available when Loaded event handlers execute
Reviewed Changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/Core/src/Platform/Android/ViewExtensions.cs | Changed immediate action execution to deferred execution using view.Post() |
| src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue14364.cs | Added NUnit test to verify size properties are available during Loaded event |
| src/Controls/tests/TestCases.HostApp/Issues/Issue14364.cs | Added test page with Grid and Label to reproduce and validate the issue fix |
|
/rebase |
f985f00 to
c1b49c0
Compare
|
/azp run |
|
Azure Pipelines successfully started running 3 pipeline(s). |
a77c2be to
bddc900
Compare
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 31590Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 31590" |
🤖 AI Summary📊 Expand Full Review🔍 Pre-Flight — Context & Validation📝 Review Session — Update ViewExtensions.cs ·
|
| File:Line | Reviewer | Feedback | Status |
|---|---|---|---|
| ViewExtensions.cs:583 | jsuarezruiz | Add IsAttachedToWindow guard inside Post callback |
✅ Implemented |
Edge Cases
- View detached between
ViewAttachedToWindowandPost()— handled byIsAttachedToWindowcheck - Disposal race — mitigated by
localDisposablepattern (local reference before nulling field) - Action called after disposal — prevented by
localDisposable is not nullcheck + disposal after action() -
Loadedfires twice — guarded bylocalDisposable is not null
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| PR | PR #31590 | view.Post() with IsAttachedToWindow + localDisposable pattern |
⏳ PENDING (Gate) | ViewExtensions.cs (+10/-2) |
Current commit 58db172 |
🚦 Gate — Test Verification
📝 Review Session — Update ViewExtensions.cs · 58db172
Result: ✅ PASSED
Platform: android
Mode: Full Verification
- Tests FAIL without fix ✅
- Tests PASS with fix ✅
| Check | Expected | Actual | Result |
|---|---|---|---|
| Tests WITHOUT fix | FAIL | FAIL | ✅ |
| Tests WITH fix | PASS | PASS | ✅ |
Test: Issue14364.SizePropertiesAvailableDuringLoadedEvent
Conclusion: The tests properly validate the fix and catch the bug when it's present.
Platform Note: Android is the affected platform per the platform/android label and the fix in Platform/Android/ViewExtensions.cs. Testing on an unaffected platform would yield false positives.
🔧 Fix — Analysis & Comparison
📝 Review Session — Update ViewExtensions.cs · 58db172
Fix Candidates
| # | Source | Approach | Test Result | Files Changed | Notes |
|---|---|---|---|---|---|
| PR | PR #31590 | view.Post() with IsAttachedToWindow + localDisposable |
✅ PASS (Gate) | 1 file (+10/-2) | Simplest, most idiomatic Android pattern |
| 1 | try-fix (claude-sonnet-4.6) | ViewTreeObserver.IOnGlobalLayoutListener |
✅ PASS | 1 file (+71/-2) | Works but fires tree-wide, adds helper class |
| 2 | try-fix (claude-opus-4.6) | view.LayoutChange event (per-view listener) |
✅ PASS | 1 file (+14/-2) | Works, semantically precise, but adds event subscription complexity |
| 3 | try-fix (gpt-5.2) | Choreographer.IFrameCallback with IsLaidOut/dimension polling |
✅ PASS | 1 file (large) | Works but significantly more complex, adds polling class |
| 4 | try-fix (gpt-5.3-codex) | Handler(Looper.MainLooper) + PostDelayed readiness loop |
✅ PASS | 1 file (+45/-15) | Works but adds retry logic and timing delays |
| 5 | try-fix (gemini-3-pro-preview) | ViewTreeObserver.IOnPreDrawListener |
✅ PASS | 1 file (+35/-17) | Works but adds helper class, fires before every draw |
Cross-Pollination Summary
| Round | Model | Response |
|---|---|---|
| 2 | claude-sonnet-4.6 | NO NEW IDEAS |
| 2 | claude-opus-4.6 | NO NEW IDEAS |
| 2 | gpt-5.2 | NO NEW IDEAS |
| 2 | gpt-5.3-codex | NO NEW IDEAS |
| 2 | gemini-3-pro-preview | NO NEW IDEAS |
Exhausted: Yes — all 5 models confirmed no new ideas in Round 2. The fix space spans all practical Android layout-readiness mechanisms: message queue deferral, layout lifecycle callbacks, and frame pipeline hooks.
Selected Fix: PR's fix — view.Post() with IsAttachedToWindow guard and localDisposable pattern. All 5 alternatives also pass, but the PR's approach is:
- Fewest lines changed (+10/-2 vs +14 to +71 for alternatives)
- Most idiomatic Android pattern (
view.Post()is the canonical deferral mechanism) - No helper classes needed
- Easiest to understand and maintain
📋 Report — Final Recommendation
📝 Review Session — Update ViewExtensions.cs · 58db172
✅ Final Recommendation: APPROVE
PR Finalize Analysis
✅ Title: Good — No Change Needed
Current: [Android] Fix control size properties not available during Loaded event
The title is accurate, has the correct platform prefix, describes the behavior being fixed, and is searchable. No change recommended.
✅ Description: Good — Minor Enhancement Suggested
Quality assessment:
- NOTE block: ✅ Present at top
- Root cause: ✅ Clearly explained
- Description of change: ✅ Matches implementation (mentions
view.Post()) - Issues fixed: ✅ Both CollectionView on Android does not provide height, width, logical children once loaded, works fine on Windows #14364 and Control's Loaded event invokes before calling its measure override method. #14160 linked
- Platforms tested: ✅ All platforms listed
- Screenshots: ✅ Before/after screenshots included
- Agent context:
⚠️ MissinglocalDisposablepattern rationale and "What NOT to Do" notes
Suggested addition to "Description of Change" section:
Key detail:
view.Post()queues execution for the next Looper cycle (after the layout pass), ensuringWidthandHeightare valid when theLoadedhandler fires. ThelocalDisposablepattern captures the reference before nulling the field so disposal can happen correctly inside the callback, after callingaction(). TheIsAttachedToWindowguard prevents action from firing if the view was detached betweenViewAttachedToWindowand post execution.What NOT to Do (for future agents)
- ❌ Don't use
ViewTreeObserver.IOnGlobalLayoutListener— Works but fires tree-wide after any view layout, more verbose, requires a helper class- ❌ Don't use
view.LayoutChangeevent — Works but adds per-view listener lifecycle complexity for the same outcome- ❌ Don't use
Choreographer.IFrameCallback— Works but significantly more complex, adds polling class with retry logic- ❌ Don't use
Handler(Looper.MainLooper)+PostDelayed— Works but introduces timing delays and retry logic (45+ lines vs 10)- ❌ Don't use
ViewTreeObserver.IOnPreDrawListener— Works but adds helper class and fires before every draw frame
Code Review Findings
✅ Looks Good
- Minimal change: Only 10 lines changed in the fix file — the smallest change that correctly fixes the root cause
- Idiomatic Android pattern:
view.Post()is the canonical Android idiom for deferring work to after the current layout pass; confirmed by 5 independent model explorations localDisposablepattern is correct: Captures local reference before nulling field, disposes inside callback after callingaction()— correct lifecycle orderingIsAttachedToWindowguard: Addresses reviewer feedback from jsuarezruiz; prevents stale action execution if view detaches between event and callbacklocalDisposable is not nullguard: Prevents double-execution if somehow invoked twice- Test assertions:
Is.Not.EqualTo("Height: -1, Width: -1")correctly validates the broken state without hardcoding specific pixel values (fragile) [Category(UITestCategories.Layout)]: Appropriate category for a layout timing test- Both issues fixed: CollectionView on Android does not provide height, width, logical children once loaded, works fine on Windows #14364 and Control's Loaded event invokes before calling its measure override method. #14160 describe the same root cause; one fix/test covers both
🟡 Minor Observations
-
Missing newline at end of
TestCases.Shared.Tests/Tests/Issues/Issue14364.cs(\ No newline at end of filein diff). Minor style issue. -
Issue14364HostApp extendsShelldirectly instead ofTestShell. Per UITest guidelinesTestShellis preferred for Shell tests; however this implementation is functionally correct and the custom Shell setup is minimal and clear. -
Test asserts negative (
Not.EqualTo) rather than positive dimensions. This is appropriate for a regression test — asserting the bug state is gone without fragile pixel value assertions. Optional enhancement: addAssert.That(double.Parse(...), Is.GreaterThan(0)).
🔴 No Critical Issues Found
Summary of Findings
Phase Completion Status
| Phase | Status | Notes |
|---|---|---|
| ✅ Pre-Flight | Complete | PR context gathered, current commit 58db172 reviewed |
| ✅ Gate | PASSED | Tests FAIL without fix, PASS with fix (Android) |
| ✅ Fix | Complete | 5 alternatives explored (all pass), PR's fix is simplest |
| ✅ Report | Complete | This document |
Fix Validation Summary
| # | Source | Approach | Test Result |
|---|---|---|---|
| PR | PR #31590 | view.Post() + IsAttachedToWindow + localDisposable |
✅ PASS (Gate verified) |
| 1 | try-fix | ViewTreeObserver.IOnGlobalLayoutListener |
✅ PASS |
| 2 | try-fix | view.LayoutChange event |
✅ PASS |
| 3 | try-fix | Choreographer.IFrameCallback with dimension polling |
✅ PASS |
| 4 | try-fix | Handler(Looper.MainLooper) + PostDelayed retry loop |
✅ PASS |
| 5 | try-fix | ViewTreeObserver.IOnPreDrawListener |
✅ PASS |
Cross-pollination: Round 2 with all 5 models — unanimous "NO NEW IDEAS". Fix space exhausted.
Selected Fix: PR's fix — all 5 alternatives also pass, but view.Post() is the simplest, most idiomatic Android pattern with the fewest lines changed.
Final Recommendation
✅ APPROVE — The PR correctly fixes a real Android-specific timing bug:
- Root cause confirmed:
ViewAttachedToWindowfires before the layout pass completes on Android - Fix is correct and idiomatic:
view.Post()defers to the next Looper cycle (after layout) - Guards are appropriate:
IsAttachedToWindow+localDisposable is not null - Reviewer feedback from
jsuarezruizhas been fully incorporated - Tests properly validate the fix
- Five independently-generated alternatives all confirm the approach space is well-covered
- PR's implementation is the simplest of all valid alternatives
📋 Expand PR Finalization Review
Title: ✅ Good
Current: [Android] Fix control size properties not available during Loaded event
Description: ✅ Good
Description needs updates. See details below.
✨ Suggested PR Description
[!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!
Root Cause
On Android, the ViewAttachedToWindow event fires as soon as the view is attached to the window hierarchy, but before Android's layout pass completes. This means that at the moment the MAUI Loaded event was fired, Height, Width, DesiredSize, and LogicalChildren all reported stale/default values (e.g., -1 for dimensions).
Description of Change
Modified the routedEventHandler lambda inside OnLoaded in src/Core/src/Platform/Android/ViewExtensions.cs to defer the action via view.Post() instead of calling it immediately inline.
view.Post() enqueues work on Android's main message queue, so it runs after the current layout pass has completed. By the time the posted callback fires, all dimension properties are populated.
Key implementation detail: The existing disposable reference is captured into a localDisposable local variable before posting, then set to null. This allows the async callback to safely check whether the subscription was cancelled between the event firing and the callback running.
What changed and what didn't:
- ✅ Changed: The "normal" path in
routedEventHandler— where the view becomes attached and is already considered loaded — now defers viaview.Post() - ✅ Unchanged: The "fast path" where
OnLoadedis called on an already-loaded view (immediate call is still correct there; layout has already completed) - ✅ Unchanged: The
!view.IsLoaded()retry path that already usednew Handler(q).Post()
What NOT to Do (for future agents)
- ❌ Don't call
action()directly inViewAttachedToWindow— Android fires this event before the layout pass completes; dimensions will be-1or stale - ❌ Don't skip the
localDisposablepattern — Without capturingdisposablelocally before the async callback, settingdisposable = nullwould race with any caller trying to cancel the subscription
Issues Fixed
Tested the behavior in the following platforms
- Android
- Windows
- iOS
- Mac
Screenshots
| Before Issue Fix | After Issue Fix |
|---|---|
![]() |
![]() |
Code Review: ✅ Passed
Code Review — PR #31590
File changed: src/Core/src/Platform/Android/ViewExtensions.cs
Test files added: Issue14364.cs (HostApp + SharedTests)
🟡 Suggestions
1. localDisposable is not disposed when view detaches before the Post callback runs
File: src/Core/src/Platform/Android/ViewExtensions.cs (lines ~644–653)
Problem: The new code sets disposable = null and enqueues a view.Post() callback. Inside that callback, if view.IsAttachedToWindow is false (the view detached between the event firing and the callback running), neither action() is called nor localDisposable.Dispose() is invoked. localDisposable.Dispose() is what unsubscribes routedEventHandler from view.ViewAttachedToWindow. As a result, the event handler remains subscribed on the view.
If the view is later re-attached, routedEventHandler will fire a second time. At that point, disposable is null (it was set to null in the first invocation), so localDisposable = disposable captures null, and the action is skipped — this prevents a double-fire. However, the handler is never cleaned up, creating a long-lived unnecessary reference.
Code (current):
var localDisposable = disposable;
disposable = null;
view.Post(() =>
{
if (view.IsAttachedToWindow && localDisposable is not null)
{
action();
localDisposable.Dispose();
}
// ⚠️ Missing: else { localDisposable?.Dispose(); }
});Recommendation: Dispose the local disposable in all code paths inside the Post callback:
var localDisposable = disposable;
disposable = null;
view.Post(() =>
{
if (view.IsAttachedToWindow && localDisposable is not null)
{
action();
}
localDisposable?.Dispose();
});Severity: Minor — the handler itself is lightweight and the scenario (view detaching between attach event and next looper iteration) is rare. Not a blocker.
2. Missing newline at end of test file
File: src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue14364.cs
The diff shows \ No newline at end of file at the end of this file. Most editors and git tooling prefer a trailing newline.
Recommendation: Add a newline character at the end of the file.
Severity: Minor / style.
3. Test validates Label but issue #14364 reports CollectionView
File: src/Controls/tests/TestCases.HostApp/Issues/Issue14364.cs
Problem: Issue #14364 specifically reports that CollectionView height, width, and LogicalChildren are not available during Loaded. The test uses a Label inside a Grid with fixed HeightRequest/WidthRequest. While a Label is a simpler repro and exercises the same OnLoaded code path, it doesn't fully validate the CollectionView scenario. In particular, LogicalChildren.Count — which was explicitly listed as broken in the issue — is not tested.
Assessment: The core fix is in OnLoaded in ViewExtensions.cs, which is shared by all views including CollectionView. Testing with a Label does exercise the fix. This is a pragmatic tradeoff (simpler HostApp test, easier to make reliable). Not a blocker.
Recommendation (optional): Consider adding a comment in the test explaining why Label is used instead of CollectionView.
Severity: Minor / informational.
✅ Looks Good
- Core fix is sound:
view.Post()is the correct Android idiom for deferring work to after the layout pass. This is well-established practice. IsAttachedToWindowguard: Addingview.IsAttachedToWindowcheck inside the Post callback correctly handles the race where a view is detached before the callback runs. This was recommended by reviewer jsuarezruiz and was incorporated.localDisposablepattern: Capturingdisposableinto a local before setting it tonullis the right approach for allowing cancellation detection in async callbacks.- Both issues addressed: The fix correctly addresses both CollectionView on Android does not provide height, width, logical children once loaded, works fine on Windows #14364 (control sizes not available in
Loaded) and Control's Loaded event invokes before calling its measure override method. #14160 (Loaded fires beforeMeasureOverride). - Cross-platform safety: The change is scoped to the Android platform file (
Platform/Android/ViewExtensions.cs) and does not affect iOS/Windows/Mac paths. - Tests added: Both a HostApp page and a SharedTests NUnit test were added, following the correct two-project pattern.
- No breaking changes: The behavioral change (slight delay in Loaded event firing) is the intended fix and aligns with user expectations.
bddc900 to
2f3b470
Compare
I’ve updated the code to match the !view.IsLoaded() cancellation pattern by deferring disposal into the Post callback. Issues 14364 and 14160 cover the same scenario, so no separate test is needed for 14160. There are no major concerns with the remaining comments. |
|
/azp run maui-pr-uitests , maui-pr-devicetests |
|
Azure Pipelines successfully started running 2 pipeline(s). |
kubaflo
left a comment
There was a problem hiding this comment.
Looks like tests are failing. Could you verify if the failures are related to the changes?
@kubaflo The fix is Android-specific. I verified the failing Android UI test "LayoutShouldBeCorrectOnFirstNavigation", and it passed locally. The test failures are not related to this fix. |
…nt (#31590) <!-- 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! ### Issue Details On Android, controls do not provide valid size when the Loaded event fires. ### Root Cause On Android, the Loaded event fires before the layout pass completes, causing views to report incorrect dimensions. ### Description of Change Modified OnLoaded method to use view.Post() instead of immediate action execution, ensuring the Loaded event fires after the layout pass completes. ### Tested the behavior in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #14364 Fixes #14160 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/703766e7-c3e8-4b9d-bdc0-5a2b943cd060"> | <img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/3fa34f58-c3f1-49ca-b638-29028930d4fd"> |
…nt (#31590) <!-- 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! ### Issue Details On Android, controls do not provide valid size when the Loaded event fires. ### Root Cause On Android, the Loaded event fires before the layout pass completes, causing views to report incorrect dimensions. ### Description of Change Modified OnLoaded method to use view.Post() instead of immediate action execution, ensuring the Loaded event fires after the layout pass completes. ### Tested the behavior in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #14364 Fixes #14160 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/703766e7-c3e8-4b9d-bdc0-5a2b943cd060"> | <img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/3fa34f58-c3f1-49ca-b638-29028930d4fd"> |
…nt (#31590) <!-- 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! ### Issue Details On Android, controls do not provide valid size when the Loaded event fires. ### Root Cause On Android, the Loaded event fires before the layout pass completes, causing views to report incorrect dimensions. ### Description of Change Modified OnLoaded method to use view.Post() instead of immediate action execution, ensuring the Loaded event fires after the layout pass completes. ### Tested the behavior in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #14364 Fixes #14160 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/703766e7-c3e8-4b9d-bdc0-5a2b943cd060"> | <img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/3fa34f58-c3f1-49ca-b638-29028930d4fd"> |
…nt (#31590) <!-- 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! ### Issue Details On Android, controls do not provide valid size when the Loaded event fires. ### Root Cause On Android, the Loaded event fires before the layout pass completes, causing views to report incorrect dimensions. ### Description of Change Modified OnLoaded method to use view.Post() instead of immediate action execution, ensuring the Loaded event fires after the layout pass completes. ### Tested the behavior in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #14364 Fixes #14160 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/703766e7-c3e8-4b9d-bdc0-5a2b943cd060"> | <img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/3fa34f58-c3f1-49ca-b638-29028930d4fd"> |
…nt (#31590) <!-- 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! ### Issue Details On Android, controls do not provide valid size when the Loaded event fires. ### Root Cause On Android, the Loaded event fires before the layout pass completes, causing views to report incorrect dimensions. ### Description of Change Modified OnLoaded method to use view.Post() instead of immediate action execution, ensuring the Loaded event fires after the layout pass completes. ### Tested the behavior in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes #14364 Fixes #14160 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/703766e7-c3e8-4b9d-bdc0-5a2b943cd060"> | <img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/3fa34f58-c3f1-49ca-b638-29028930d4fd"> |
## What's Coming .NET MAUI inflight/candidate introduces significant improvements across all platforms with focus on quality, performance, and developer experience. This release includes 66 commits with various improvements, bug fixes, and enhancements. ## Activityindicator - [Android] Implemented material3 support for ActivityIndicator by @Dhivya-SF4094 in #33481 <details> <summary>🔧 Fixes</summary> - [Implement material3 support for ActivityIndicator](#33479) </details> - [iOS] Fix: ActivityIndicator IsRunning ignores IsVisible when set to true by @bhavanesh2001 in #28983 <details> <summary>🔧 Fixes</summary> - [[iOS] [ActivityIndicator] `IsRunning` ignores `IsVisible` when set to `true`](#28968) </details> ## Button - [iOS] Button RTL text and image overlap - fix by @kubaflo in #29041 ## Checkbox - [iOS/MacCatalyst] Fix CheckBox foreground color not resetting when set to null by @Ahamed-Ali in #34284 <details> <summary>🔧 Fixes</summary> - [[iOS] Color of the checkBox control is not properly worked on dynamic scenarios](#34278) </details> ## CollectionView - [iOS] Fix: CollectionView does not clear selection when SelectedItem is set to null by @Tamilarasan-Paranthaman in #30420 <details> <summary>🔧 Fixes</summary> - [CollectionView not being able to remove selected item highlight on iOS](#30363) - [[MAUI] Select items traces are preserved](#26187) </details> - [iOS] CV2 ItemsLayout update by @kubaflo in #28675 <details> <summary>🔧 Fixes</summary> - [CollectionView CollectionViewHandler2 doesnt change ItemsLayout on DataTrigger](#28656) - [iOS CollectionView doesn't respect a change to ItemsLayout when using Items2.CollectionViewHandler2](#31259) </details> - [iOS][CV2] Fix CollectionView renders large empty space at bottom of view by @devanathan-vaithiyanathan in #31215 <details> <summary>🔧 Fixes</summary> - [[iOS] [MacCatalyst] CollectionView renders large empty space at bottom of view](#17799) - [[iOS/Mac] CollectionView2 EmptyView takes up large horizontal space even when the content is small](#33201) </details> - [iOS] Fixed issue where group Header/Footer template was set to all items when IsGrouped was true for an ObservableCollection by @Tamilarasan-Paranthaman in #29144 <details> <summary>🔧 Fixes</summary> - [[iOS] Group Header/Footer Repeated for All Items When IsGrouped is True for ObservableCollection in CollectionView](#29141) </details> - [Android] Fix CollectionView selection crash with HeaderTemplate by @NirmalKumarYuvaraj in #34275 <details> <summary>🔧 Fixes</summary> - [[Bug] [Android] System.ArgumentOutOfRangeException: Index was out of range. Must be non-negative and less than the size of the collection. Parameter name: index](#34247) </details> ## DateTimePicker - [iOS] Fix TimePicker AM/PM frequently changes when the app is closed and reopened by @devanathan-vaithiyanathan in #31066 <details> <summary>🔧 Fixes</summary> - [[iOS] TimePicker AM/PM frequently changes when the app is closed and reopened](#30837) - [Maui 10 iOS TimePicker Strange Characters in place of AM/PM](#33722) </details> - Android TimePicker ignores 24 hour system setting when using Format Property - fix by @kubaflo in #28797 <details> <summary>🔧 Fixes</summary> - [Android TimePicker ignores 24 hour system setting when using Format Property](#28784) </details> ## Drawing - [iOS, Mac, Windows] GraphicsView: Fix Background/BackgroundColor not updating by @NirmalKumarYuvaraj in #31254 <details> <summary>🔧 Fixes</summary> - [[iOS, Mac, Windows] GraphicsView does not change the Background/BackgroundColor](#31239) </details> - [iOS] GraphicsView DrawString - fix by @kubaflo in #26304 <details> <summary>🔧 Fixes</summary> - [DrawString not rendering in iOS.](#24450) - [GraphicsView DrawString not rendering in iOS](#8486) - [DrawString doesn't work on maccatalyst](#4993) </details> - [Android] - Fix Shadow Rendering For Transparent Fill, Stroke (Lines), and Text on Shapes by @prakashKannanSf3972 in #29528 <details> <summary>🔧 Fixes</summary> - [Ellipse Transparency Not Rendered When Drawing Arc Inside the Ellipse Using GraphicsView on Android](#29394) </details> - Revert "[iOS, Mac, Windows] GraphicsView: Fix Background/BackgroundColor not updating (#31254)" by @Ahamed-Ali via @Copilot in #34508 ## Entry - [iOS 26] Fix Entry MaxLength not enforced due to new multi-range delegate by @kubaflo in #32045 <details> <summary>🔧 Fixes</summary> - [iOS 26 - The MaxLength property value is not respected on an Entry control.](#32016) - [.NET MAUI Entry Maximum Length not working on iOS and macOS](#33316) </details> - [iOS] Fixed Entry with IsPassword toggling loses previously entered text by @SubhikshaSf4851 in #30572 <details> <summary>🔧 Fixes</summary> - [Entry with IsPassword toggling loses previously entered text on iOS when IsPassword is re-enabled](#30085) </details> ## Essentials - Fix for FilePicker PickMultipleAsync nullable reference type by @SuthiYuvaraj in #33163 <details> <summary>🔧 Fixes</summary> - [FilePicker PickMultipleAsync nullable reference type](#33114) </details> - Replace deprecated NetworkReachability with NWPathMonitor on iOS/macOS by @jfversluis via @Copilot in #32354 <details> <summary>🔧 Fixes</summary> - [NetworkReachability is obsolete on iOS/maccatalyst 17.4+](#32312) - [Use NWPathMonitor on iOS for Essentials Connectivity](#2574) </details> ## Essentials Connectivity - Update Android Connectivity implementation to use modern APIs by @jfversluis via @Copilot in #30348 <details> <summary>🔧 Fixes</summary> - [Update the Android Connectivity implementation to user modern APIs](#30347) </details> ## Flyout - [iOS] Fixed Flyout icon not updating when root page changes using InsertPageBefore by @Vignesh-SF3580 in #29924 <details> <summary>🔧 Fixes</summary> - [[iOS] Flyout icon not replaced by back button when root page is changed using InsertPageBefore](#29921) </details> ## Flyoutpage - [iOS] Flyout Items Not Displayed in RightToLeft FlowDirection in Landscape - fix by @kubaflo in #26762 <details> <summary>🔧 Fixes</summary> - [Flyout Items Not Displayed in RightToLeft FlowDirection on iOS in Landscape Orientation and Hamburger Icon Positioned Incorrectly](#26726) </details> ## Image - [Android] Implemented Material3 support for Image by @Dhivya-SF4094 in #33661 <details> <summary>🔧 Fixes</summary> - [Implement Material3 support for Image](#33660) </details> ## Keyboard - [iOS] Fix gap at top of view after rotating device while Entry keyboard is visible by @praveenkumarkarunanithi in #34328 <details> <summary>🔧 Fixes</summary> - [Focusing and entering texts on entry control causes a gap at the top after rotating simulator.](#33407) </details> ## Label - [Android] Support for images inside HTML label by @kubaflo in #21679 <details> <summary>🔧 Fixes</summary> - [Label with HTML TextType does not display images on Android](#21044) </details> - [fix] ContentLabel Moved to a nested class to prevent CS0122 in external source generators by @SubhikshaSf4851 in #34514 <details> <summary>🔧 Fixes</summary> - [[MAUI] Building Maui App with sample content results CS0122 errors.](#34512) </details> ## Layout - Optimize ordering of children in Flex layout by @symbiogenesis in #21961 - [Android] Fix control size properties not available during Loaded event by @Vignesh-SF3580 in #31590 <details> <summary>🔧 Fixes</summary> - [CollectionView on Android does not provide height, width, logical children once loaded, works fine on Windows](#14364) - [Control's Loaded event invokes before calling its measure override method.](#14160) </details> ## Mediapicker - [iOS/Android] MediaPicker: Fix image orientation when RotateImage=true by @michalpobuta in #33892 <details> <summary>🔧 Fixes</summary> - [MediaPicker.PickPhotosAsync does not preserve image orientation](#32650) </details> ## Modal - [Windows] Fix modal page keyboard focus not shifting to newly opened modal by @jfversluis in #34212 <details> <summary>🔧 Fixes</summary> - [Keyboard focus does not shift to a newly opened modal page: Pressing enter clicks the button on the page beneath the modal page](#22938) </details> ## Navigation - [iOS26] Apply view margins in title view by @kubaflo in #32205 <details> <summary>🔧 Fixes</summary> - [NavigationPage TitleView iOS 26](#32200) </details> - [iOS] System.NullReferenceException at NavigationRenderer.SetStatusBarStyle() by @kubaflo in #29564 <details> <summary>🔧 Fixes</summary> - [System.NullReferenceException at NavigationRenderer.SetStatusBarStyle()](#29535) </details> - [iOS 26] Fix back button color not applied for NavigationPage by @Shalini-Ashokan in #34326 <details> <summary>🔧 Fixes</summary> - [[iOS] Color not applied to the Back button text or image on iOS 26](#33966) </details> ## Picker - Fix Picker layout on Mac Catalyst 26+ by @kubaflo in #33146 <details> <summary>🔧 Fixes</summary> - [[MacOS 26] Text on picker options are not centered on macOS 26.1](#33229) </details> ## Progressbar - [Android] Implemented Material3 support for ProgressBar by @SyedAbdulAzeemSF4852 in #33926 <details> <summary>🔧 Fixes</summary> - [Implement Material3 support for Progressbar](#33925) </details> ## RadioButton - [iOS, Mac] Fix for RadioButton TextColor for plain Content not working by @HarishwaranVijayakumar in #31940 <details> <summary>🔧 Fixes</summary> - [RadioButton: TextColor for plain Content not working on iOS](#18011) </details> - [All Platforms] Fix RadioButton warning when ControlTemplate is set with View content by @kubaflo in #33839 <details> <summary>🔧 Fixes</summary> - [Seeking clarification on RadioButton + ControlTemplate + Content documentation](#33829) </details> - Visual state change for disabled RadioButton by @kubaflo in #23471 <details> <summary>🔧 Fixes</summary> - [RadioButton disabled UI issue - iOS](#18668) </details> ## SafeArea - [Android] Fix for TabbedPage BottomNavigation BarBackgroundColor not extending to system navigation bar by @praveenkumarkarunanithi in #33428 <details> <summary>🔧 Fixes</summary> - [[Android] TabbedPage BottomNavigation BarBackgroundColor does not extend to system navigation bar area in Edge-to-Edge mode](#33344) </details> ## ScrollView - [Android] ScrollView: Fix HorizontalScrollBarVisibility not updating immediately at runtime by @SubhikshaSf4851 in #33528 <details> <summary>🔧 Fixes</summary> - [Runtime Scrollbar visibility not updating correctly on Android and macOS platforms.](#33400) </details> - Fixed crash when calling ItemsView.ScrollTo on unloaded CollectionView by @kubaflo in #25444 <details> <summary>🔧 Fixes</summary> - [App crashes when calling ItemsView.ScrollTo on unloaded CollectionView](#23014) </details> ## Shell - [Shell] Update logic for iOS large title display in ShellItemRenderer by @kubaflo in #33246 - [iOS][Shell] Fix navigation lifecycle and back button for More tab (>5 tabs) by @kubaflo in #27932 <details> <summary>🔧 Fixes</summary> - [OnAppearing and OnNavigatedTo does not work when using extended Tabbar (tabbar with more than 5 tabs) on IOS.](#27799) - [Shell.BackButtonBehavior does not work when using extended Tabbar (tabbar with more than 5 tabs)on IOS.](#27800) - [Shell TabBar More button causes ViewModel command binding disconnection on back navigation](#30862) - [Content page onappearing not firing if tabs are on the more tab on IOS](#31166) </details> - [iOS 26] Fix tab bar ghosting when navigating from modal to tabbed Shell content by @SubhikshaSf4851 in #34254 <details> <summary>🔧 Fixes</summary> - [[iOS] Tab bar ghosting issue on iOS 26 (liquid glass)](#34143) </details> - Fix for Shell tab visibility not updating when navigating back multiple pages by @BagavathiPerumal in #34403 <details> <summary>🔧 Fixes</summary> - [Changing Shell Tab Visibility when navigating back multiple pages ignores Shell Tab Visibility](#33351) </details> - [iOS/Mac] Fixed OnBackButtonPressed not firing for Shell Navigation Bar Button by @Dhivya-SF4094 in #34401 <details> <summary>🔧 Fixes</summary> - [[iOS] OnBackButtonPressed not firing for Shell Navigation Bar button](#34190) </details> ## Slider - [iOS] Fix for Slider ThumbImageSource is not centered properly on iOS 26 by @HarishwaranVijayakumar in #34019 <details> <summary>🔧 Fixes</summary> - [[iOS 26] Slider ThumbImageSource is not centered properly](#33967) </details> - [Android] Fix improper rendering of ThumbimageSource in Slider by @NirmalKumarYuvaraj in #34064 <details> <summary>🔧 Fixes</summary> - [[Slider] MAUI Slider thumb image is big on android](#13258) </details> ## Stepper - [iOS] Fix Stepper layout overlap in landscape on iOS 26 by @Vignesh-SF3580 in #34325 <details> <summary>🔧 Fixes</summary> - [[.NET10] D10 - Customize cursor position - Rotating simulator makes the button and label overlap](#34273) </details> ## SwipeView - [iOS] SwipeView: Honor FontImageSource.Color in SwipeItem icon by @kubaflo in #27389 <details> <summary>🔧 Fixes</summary> - [[iOS] SwipeView: SwipeItem.IconImageSource.FontImageSource color value not honored](#27377) </details> ## Switch - [Android] Fix Switch thumb shadow missing when ThumbColor is set by @Shalini-Ashokan in #33960 <details> <summary>🔧 Fixes</summary> - [Android Switch Control Thumb Shadow](#19676) </details> ## Toolbar - [iOS/Mac Catalyst 26] Fix Shell.ForegroundColor not applied to ToolbarItems by @SyedAbdulAzeemSF4852 in #34085 <details> <summary>🔧 Fixes</summary> - [[iOS26] Shell.ForegroundColor is not applied to ToolbarItems](#34083) </details> - [Android] VoiceOver on Toolbar Item by @kubaflo in #29596 <details> <summary>🔧 Fixes</summary> - [VoiceOver on Toolbar Item](#29573) - [SemanticProperties do not work on ToolbarItems](#23623) </details> <details> <summary>🧪 Testing (11)</summary> - [Testing] Additional Feature Matrix Test Cases for CollectionView by @TamilarasanSF4853 in #32432 - [Testing] Feature Matrix UITest Cases for VisualStateManager by @LogishaSelvarajSF4525 in #34146 - [Testing] Feature Matrix UITest Cases for Clip by @TamilarasanSF4853 in #34121 - [Testing] Feature matrix UITest Cases for Map Control by @HarishKumarSF4517 in #31656 - [Testing] Feature matrix UITest Cases for Visual Transform Control by @HarishKumarSF4517 in #32799 - [Testing] Feature Matrix UITest Cases for Shell Pages by @NafeelaNazhir in #33945 - [Testing] Feature Matrix UITest Cases for Triggers by @HarishKumarSF4517 in #34152 - [Testing] Refactoring Feature Matrix UITest Cases for CheckBox Control by @LogishaSelvarajSF4525 in #34283 - Resolve UI test Build Sample failures - Candidate March 16 by @Ahamed-Ali in #34442 - Fix the failures in the Candidate branch- March 16 by @Ahamed-Ali in #34453 <details> <summary>🔧 Fixes</summary> - [March 16th, Candidate](#34437) </details> - Fixed the iOS 18.5 Candidate failures (March 16,2026) by @Ahamed-Ali in #34593 <details> <summary>🔧 Fixes</summary> - [March 16th, Candidate](#34437) </details> </details> <details> <summary>📦 Other (2)</summary> - Fixed candidate test failures caused by PR #33428. by @Ahamed-Ali in #34515 <details> <summary>🔧 Fixes</summary> - [[.NET10] On Android, there's a big space at the top for I, M and N2 & N3](#34509) </details> - Revert "[iOS] Button RTL text and image overlap - fix (#29041)" in b0497af </details> <details> <summary>📝 Issue References</summary> Fixes #2574, Fixes #4993, Fixes #8486, Fixes #13258, Fixes #14160, Fixes #14364, Fixes #17799, Fixes #18011, Fixes #18668, Fixes #19676, Fixes #21044, Fixes #22938, Fixes #23014, Fixes #23623, Fixes #24450, Fixes #26187, Fixes #26726, Fixes #27377, Fixes #27799, Fixes #27800, Fixes #28656, Fixes #28784, Fixes #28968, Fixes #29141, Fixes #29394, Fixes #29535, Fixes #29573, Fixes #29921, Fixes #30085, Fixes #30347, Fixes #30363, Fixes #30837, Fixes #30862, Fixes #31166, Fixes #31239, Fixes #31259, Fixes #32016, Fixes #32200, Fixes #32312, Fixes #32650, Fixes #33114, Fixes #33201, Fixes #33229, Fixes #33316, Fixes #33344, Fixes #33351, Fixes #33400, Fixes #33407, Fixes #33479, Fixes #33660, Fixes #33722, Fixes #33829, Fixes #33925, Fixes #33966, Fixes #33967, Fixes #34083, Fixes #34143, Fixes #34190, Fixes #34247, Fixes #34273, Fixes #34278, Fixes #34437, Fixes #34509, Fixes #34512 </details> **Full Changelog**: main...inflight/candidate
…nt (dotnet#31590) <!-- 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! ### Issue Details On Android, controls do not provide valid size when the Loaded event fires. ### Root Cause On Android, the Loaded event fires before the layout pass completes, causing views to report incorrect dimensions. ### Description of Change Modified OnLoaded method to use view.Post() instead of immediate action execution, ensuring the Loaded event fires after the layout pass completes. ### Tested the behavior in the following platforms - [x] Android - [x] Windows - [x] iOS - [x] Mac ### Issues Fixed Fixes dotnet#14364 Fixes dotnet#14160 ### Screenshots | Before Issue Fix | After Issue Fix | |----------|----------| | <img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/703766e7-c3e8-4b9d-bdc0-5a2b943cd060"> | <img width="500" height="300" alt="image" src="https://github.com/user-attachments/assets/3fa34f58-c3f1-49ca-b638-29028930d4fd"> |



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 Details
On Android, controls do not provide valid size when the Loaded event fires.
Root Cause
On Android, the Loaded event fires before the layout pass completes, causing views to report incorrect dimensions.
Description of Change
Modified OnLoaded method to use view.Post() instead of immediate action execution, ensuring the Loaded event fires after the layout pass completes.
Tested the behavior in the following platforms
Issues Fixed
Fixes #14364
Fixes #14160
Screenshots