Skip to content

[net11.0] Expose safe area contract for custom views - #37750

Closed
kubaflo wants to merge 39 commits into
dotnet:net11.0from
kubaflo:kubaflo/37384-public-safe-area-api
Closed

kubaflo wants to merge 39 commits into
dotnet:net11.0from
kubaflo:kubaflo/37384-public-safe-area-api

Conversation

@kubaflo

@kubaflo kubaflo commented Aug 22, 2026 •

Copy link
Copy Markdown
Contributor

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!

Summary

  • make ISafeAreaElement the public per-edge safe-area contract for custom views and native hosts
  • expose HasExplicitSafeAreaEdges and GetDefaultSafeAreaEdges() so platform code can preserve control defaults and distinguish an explicit value from a default-created value
  • expose GetEffectiveSafeAreaEdges() so public native hosts read the same effective strategy as MAUI handlers, including built-in controls that intentionally preserve an explicit Default
  • expose the shared SafeAreaElement.SafeAreaEdgesProperty and SafeAreaElement.IsSafeAreaEdgesSet(BindableObject) helper for custom BindableObject implementations
  • keep the shipped ISafeAreaView contract unchanged as a compatible legacy fallback
  • keep built-in default/legacy normalization and edge-index lookup internal rather than adding another numbered public interface or a public magic-integer API
  • route iOS, Mac Catalyst, Android, keyboard, collection-cell, and nested-view safe-area handling through one capability resolver and reuse one four-edge snapshot per evaluation
  • preserve runtime Apple descendant invalidation, per-edge ancestor suppression, child keyboard overlap beyond ancestor container insets, pixel-level inset tolerance, and Android listener refresh
  • add unit, XAML, device, HostApp, AOT, mutation, and runtime-media coverage for public-only custom views and legacy behavior

This targets net11.0 because #37384 is an API request for .NET 11.

Public API and compatibility

The new public surface is added to every applicable Core and Controls API baseline:

  • ISafeAreaElement.SafeAreaEdges
  • ISafeAreaElement.HasExplicitSafeAreaEdges
  • ISafeAreaElement.GetDefaultSafeAreaEdges()
  • SafeAreaElementExtensions.GetEffectiveSafeAreaEdges(ISafeAreaElement)
  • SafeAreaElement.SafeAreaEdgesProperty
  • SafeAreaElement.IsSafeAreaEdgesSet(BindableObject)

ISafeAreaView remains unchanged because it is already shipped and implemented by external controls. Built-in controls use an internal strategy for their existing legacy/default semantics; third-party controls only implement ISafeAreaElement.

Leaving ContentPage.SafeAreaEdges unset preserves its existing platform/legacy default. Explicit values remain explicit, including full and partial Default regions, so setting the shipped named default does not become edge-to-edge. GetEffectiveSafeAreaEdges() delegates to the same strategy resolver as the handlers, preventing public native hosts from interpreting those values differently.

Validation

The broad focused build, API, unit, XAML, AOT, and platform validation below was completed through product head 777f65e227af9af1a0148a55223317a59ec94a0a. Commits c32e41e882e0b6baa9da3b830a2840262e015c2e and 310d7e93c0fd3280aba2833ef1191b54afd51a41 harden nested Bottom SoftInput residual handling and its geometry-sensitive coverage. Commit c265a307d821eea36c61116b1a549fdf7a9e03f6 adds pixel-gated overlap caching, screen-to-window keyboard conversion, active-ancestor checks, descendant convergence invalidation, a real cross-platform arrange regression, and reusable bindable-property specificity metadata. Commit 104f8146610f38465118de78bdd2c2f9336e4751 compares absolute overlap values in device-pixel buckets so cumulative sub-pixel movement cannot be ignored indefinitely. Commit 79cdc7408d6140335f5fa27a9aeb999897cfb0f9 adds two-dimensional floating-keyboard intersection and clamping, uses the owning window's screen scale, preserves UIKit-applied scroll insets, verifies specificity-only/no-op updates, and removes avoidable ancestor work without making suppression depend on layout order.

Current PR head 6a01b3521f7adfeb1da45393434ba449ee985303 contains the reviewed safe-area tree from 7efb2686323f82301bf2846cb573f943b0b07a9b and normally merges concurrent follow-up 01770ad87f1cdc4d6169ebc8757e0241d618d4aa. Commit 3d3c42bd7d6ff08fb7d38fbc7f9896af6a108915 adds a keyboard-hidden strategy-resolution fast path with show/hide/show lifecycle coverage, strengthens the system-adjusted MauiScrollView geometry and SizeThatFits regression, documents compatibility-resolved interface values, and aligns Android/iOS safe-area mapper guard ordering. Commit ac8d98c01fa8b5802e4b9111252a9b3446bfe13f applies the justified exact-head reviewer refinements: it restores the unrelated Android event hookup to the target-branch form and documents effective-value, UIKit-inset, and keyboard-resolution semantics. Commit 92f72f9dcf73753b229a79d90045ef9ad3331d15 documents why specificity/default members are required, why invalidation must cross unchanged intermediate native views, how nested keyboard residuals settle, and how custom Page subclasses inherit the public contract. The final tree adds ClearValue specificity coverage, distinguishes resolved handler input from final platform geometry, documents physical-inset ancestor suppression, and makes the two UI fixtures exposed by the review filters independent of predecessor state and orientation.

The screenshots and videos were captured at f5a35e4a729a7875b26e2474e4fd90c1a1af0099. The later commits repair Android AOT profile encoding, clarify compatibility documentation, and harden nested keyboard behavior; they do not change the captured Container → None → bottom-only Container → Container probe flow. That flow and the keyboard regressions were rebuilt and revalidated in the final platform suites.

  • exact pushed-head SafeAreaTests: 77/77
  • focused SafeAreaTests plus bindable-object selection at merged head: 174/174
  • SafeAreaEdgesTests: 15/15 across runtime, XamlC, and source-generator paths, including a third-party control using the public shared property
  • Microsoft.Maui.BuildTasks.slnf: succeeded with PublicApiType=Validate
  • Core and Controls Core: succeeded for netstandard2.0, iOS, Mac Catalyst, and Android

The platform-handler implementation was exercised at f6db02a3ad6cb67b3e555085ca03eb33997f2b98; the only later commit adds the public resolver, its documentation/API baselines, and focused tests. Exact-head platform libraries and both empirical apps were rebuilt, and the new resolver itself is displayed in the iOS and Android evidence below.

Platform Controls View Controls Page Controls ScrollView Core ScrollViewHandler
iPhone 11 Pro CoreSimulator, iOS 26.5 63/63 5/5 12 passed, 1 ignored 57 passed, 1 ignored
Mac Catalyst arm64 63/63 5/5 12 passed, 1 ignored 52 passed, 6 ignored
Android arm64 emulator (API 35 for final View) 53/53 16/16 12/12 —
  • exact pushed head 6a01b3521f7adfeb1da45393434ba449ee985303 is tree-identical to the locally reviewed and empirically validated 7efb2686323f82301bf2846cb573f943b0b07a9b: iOS 63/63, Mac Catalyst 63/63, Android Release 53/53, and focused units 78/78
  • FloatingKeyboardUsesClampedViewIntersection covers a laterally disjoint floating keyboard and an oversized frame; restoring the old Y-only overlap produced the sole iOS failure (61/62)
  • SystemAdjustedScrollViewInsetsAreNotSuppressedByParent preserves the full viewport inset that UIKit already applies; applying ancestor suppression to that UIKit-owned inset produced the sole iOS failure (62/63, expected viewport height 60, mutated result 70)
  • removing the keyboard-hidden fast path produced the sole iOS failure (62/63, expected one safe-area strategy read, actual two)
  • removing the empty-inset ancestor fast paths produced exactly the two instrumented failures (60/62)
  • restoring farther-ancestor keyboard geometry after Bottom was already resolved produced the sole iOS failure (61/62)
  • adding the suggested _safeAreaInvalidated subtree early exit produced the sole iOS failure (61/62), proving that measure-invalidated parents can still have descendants requiring safe-area invalidation
  • disabling specificity-change metadata produced the sole focused unit failure (76/77)
  • final-head nested-keyboard tests cover parent and child both declaring Bottom SoftInput: a correctly arranged child does not double-pad, while an overflowing child retains its positive frame-relative residual; transformed geometry is recomputed without requiring another keyboard notification, keyboard hide clears the residual, and a nested MauiScrollView still suppresses its raw/system Bottom inset
  • the nested arrange regression now uses a real MAUI Grid measure/arrange path instead of assigning native frames manually
  • restoring the old ancestor-SoftInput guard produced 50/51, with only the overflowing-child regression failing
  • removing active keyboard-geometry refresh produced 50/51, with the transformed child retaining stale height 50 instead of the expected 100
  • treating MauiScrollView's raw/system Bottom inset as a computed keyboard residual produced 50/51, with only the nested scroll-view suppression regression failing
  • removing the pixel-level overlap gate produced 55/56, with only the stable-geometry cache regression failing (expected 0 ancestor reads, actual 4)
  • restoring adjacent-delta comparison produced 55/56, with only the strengthened cache regression failing because two individually sub-pixel moves crossed a cumulative device-pixel boundary
  • skipping screen-to-window keyboard conversion produced 55/56, with only the nonzero-window-origin regression failing (expected X 0, actual 137)
  • treating a non-responding SoftInput ancestor under UIScrollView as active produced 55/56, with only the fallback-auto-scroll regression failing
  • removing interaction-change descendant invalidation produced 55/56, with only the non-SoftInput descendant convergence regression failing (expected height 70, actual 100)
  • disabling reusable specificity-change metadata produced Android 51/53, failing exactly the listener attach/detach regressions; the restored APK passed 53/53
  • the updated repository XHarness failed before Android app launch with Invalid userId -2; the same rebuilt APK passed 53/53 when instrumentation explicitly targeted emulator owner user 0
  • the exact MauiBot-style iOS method-name filter passed 12/12; Issue32586.VerifyRuntimeSafeAreaEdgesChange now derives the expected post-tap footer state instead of assuming ordered test 2 ran first
  • all iOS HostApp SafeAreaEdges cases pass 109/109 on the final tree; Issue28986_ParentChildTest first establishes and observes settled portrait geometry, so preceding orientation-changing fixtures can no longer contaminate its initial bounds, and the complete fixture also passes 4/4 in isolation
  • all three binary AOT profiles exactly match their text snapshots; each has two six-parameter and zero stale five-parameter OnBindablePropertySet entries
  • each profile contains one fully qualified Microsoft.Maui.SafeAreaViewStrategy type, one Android-reachable TryGetSafeAreaEdges method, no leading-dot type, and no linker-unreachable GetSafeAreaRegionsForEdge entry
  • final profile counts are maui: 38 modules / 1,814 types / 8,632 methods; maui-sc: 49 / 2,264 / 10,963; maui-blazor: 43 / 2,186 / 8,568
  • exact-head Android Mono profiled-AOT publish consumed the profiles and compiled all 110/110 assemblies; the unstripped output contains the native Microsoft_Maui_SafeAreaViewStrategy_TryGetSafeAreaEdges_object_Microsoft_Maui_SafeAreaEdges__bool body
  • temporary public-only Sandbox probe built in Release for iOS Simulator and Android arm64 before the empirical runs below
  • mutation checks proved the assertions detect public custom-view resolution, canonical public-host strategy precedence, declared defaults, explicit and partial ContentPage.Default, specificity-only assignments, Android exact inset consumption, nested/disjoint Apple edges, child keyboard overlap beyond a parent container inset, complete descendant invalidation, legacy MauiScrollView behavior, residual sub-pixel ancestor insets, completed ancestor traversal, and stale five-parameter AOT signatures

Completed public build 1567759 uses merge commit 30ce3756e59cf4d10e60ea9c6ce9f5e916746767, whose second parent is PR head 490a33f8dc17a653823d181f844aacd41b2e87fc. Every integration-test job succeeded, including Android runtime, six iOS CoreCLR/NativeAOT configurations, AOT/build, samples, Blazor, multi-project, and Windows template/build coverage.

Replacement build 1567853 uses merge commit cdb262e0517e81025f2038574b3a1bd9da829515, with target parent 4695c95801e0b6764beb83f314c62141ee9c7f2e and PR parent 310d7e93c0fd3280aba2833ef1191b54afd51a41. Its final raw timeline contains 24 successful jobs and only two failed jobs: Windows Debug and Release. Every failed task/job/phase log was downloaded and inspected without deduplication; both build tasks report only the target branch's four CS0103 errors for missing AssertEventually at TabbedPageTests.Windows.cs lines 141 and 155 across the two Windows TFMs. Both Windows Helix jobs succeeded. Target commit c127c3f3503e06a347c0f100504911659f6154c1 fixes that compile error and is included in current head 92f72f9dcf73753b229a79d90045ef9ad3331d15.

Build 1568885 was audited from every failed raw phase/job/task log and all 16 Helix work-item details and console logs, preserving repeated lines. Every test process passed with zero failures and exited 0; Windows Helix reported exit -4 only when publishing results failed with TF10216: Azure DevOps services are currently unavailable or one Azure request-read timeout. This build contains no product or test failure.

Public maui-pr run 1569748 succeeded for synthetic merge 1ae4d8c234, whose parents are target ec79089f65 and PR head 92f72f9dcf. All 27/27 jobs succeeded: Windows/macOS Debug and Release builds, both package jobs, Helix units, Android runtime, all iOS CoreCLR and NativeAOT configurations, AOT, samples, Blazor, multi-project, and Windows-template integration tests. The raw final timeline contained no failed or partially successful record. Its only annotations were expected empty-result publisher warnings in four build jobs and preview Android-manifest package-signing warnings; all corresponding tasks and jobs completed successfully.

Review run 15111758 covered stale head 79cdc7408d6140335f5fa27a9aeb999897cfb0f9, as its published warning states. Its deep UI stage passed 660 tests, skipped 6, and reported one EntriesScrollingPageTest geometry assertion. Raw teardown evidence shows the compared keyboard frame was parked below the screen: Entry14 retained its idle center Y 869, while the invisible keyboard began at Y 829 in a 375×812 window and only the 44-point accessory toolbar remained visible. The tested hierarchy does not opt into SoftInput, so the PR's parent-soft-input suppression path is inactive. On current head, all four local executions that reached and completed this exact test body passed; separate failed attempts were Appium/WebDriverAgent crashes or lost sessions before a geometry result.

Review run 15114354 covered head 3d3c42bd7d6ff08fb7d38fbc7f9896af6a108915 before the final documentation-only follow-ups. Its raw timeline completed successfully. The A/B gate passed focused units 77/77, focused XAML 15/15, and the broad XAML suite 2115/2123 with 8 skips; its DeviceTest comparisons were inconclusive only because XHarness did not produce fresh results. The independent platform-pool stage passed all six detected iOS categories: 661 passed, 0 failed, 6 skipped, including SafeAreaEdges 109/109 and Layout 194/199 with the five expected skips. All 13/13 historical safe-area regression invocations passed. The review's justified documentation and unrelated-syntax recommendations are incorporated in ac8d98c01f and 92f72f9dcf; the proposed system-inset suppression and subtree pruning remain rejected by focused mutation evidence.

Review run 15115319 covered head 92f72f9dcf73753b229a79d90045ef9ad3331d15 and completed successfully in the raw timeline. Its independent iOS pool passed 661, failed 0, and skipped 6: Border 58/58, Layout 194/199 with five expected skips, Page 26/26, SafeAreaEdges 109/109, ScrollView 162/163 with one expected skip, and ViewBaseTests 112/112. All 13/13 historical regressions for issues #35756, #28986, #32586, #33595, and #33934 passed. The gate was inconclusive only because its XHarness DeviceTest path produced no fresh result. Its twelve findings were individually adjudicated: the actionable public-doc, explicitness-test, helper-name, and invariant-comment refinements are in the final tree; the runtime proposals are rejected by focused device and mutation evidence.

Claude Opus 5 independently reviewed the safe-area hot paths and rejected both applied-state ancestor caching and _safeAreaInvalidated subtree pruning as layout-order correctness regressions. Its topology-independent optimizations are in 79cdc7408d. A separate GPT-5.6 Terra exact-diff review reported no significant issues. A later Claude Opus 5 exact-follow-up review found no significant issue in 3d3c42bd7d, and an independent multimodal audit classified the stale-head deep-UI result above as a parked-keyboard test race rather than a product regression. On head 92f72f9dcf, Claude Opus 5 reviewed the complete 56-file target diff and reported no significant issue; GPT-5.6 Terra decoded both final proof videos and reviewed all six screenshots/contact sheets, finding the iOS and Android evidence coherent and sufficient. On the exact final tree, Claude Opus 5 reviewed the API/runtime refinements and GPT-5.6 Terra reviewed the UI-order fixes; both reported no actionable finding. All 47/47 inline review threads have evidence-backed dispositions and are resolved.

Empirical evidence

A temporary SafeAreaProbe : TemplatedView, ISafeAreaElement implemented only the new public contract, reused the public shared bindable property, and displayed GetEffectiveSafeAreaEdges() as Public host: .... At the capture head it was advanced live through all-edge Container, None, bottom-only Container, and back to all-edge Container. The probe was removed after capture.

Both videos are H.264/yuv420p at a constant 30 fps and contain only the ordered runtime states 1 → 2 → 3 → 1; sampled-frame review found no blank, splash, crash, or stale-state frames. On iOS, Appium taps drove the live property changes deterministically.

iOS — iPhone 11 Pro simulator

All edges (T44/B34) Edge-to-edge (T0/B0) Bottom only (T0/B34)
iOS public custom view using Container on all edges iOS public custom view using None edge-to-edge iOS public custom view using Container on the bottom edge only

Video — live runtime transitions:

ios-safe-area-demo-f5a.mp4

Android — API 34 arm64 emulator

The probe theme leaves the Android system bars opaque. Edge-to-edge is demonstrated by the SAFE CONTENT markers moving beneath those bars (and therefore disappearing), while bottom-only restores only the bottom marker; the background cannot show through the opaque bars.

All edges Edge-to-edge Bottom only
Android public custom view using Container on all edges Android public custom view using None edge-to-edge Android public custom view using Container on the bottom edge only

Video — live runtime transitions:

android-safe-area-demo-f5a.mp4

MauiBot follow-up

  • applied the connect-time Apple invalidation guard
  • strengthened Android coverage to assert exact consumed insets and listener replacement
  • simplified the final public surface to one modern custom-view contract while retaining the existing legacy interface unchanged
  • documented custom-view Default resolution, explicit shared-property misuse, and the public CLR-property pattern required by XAML
  • preserved explicit and partially explicit ContentPage.Default regions while retaining the unset edge-to-edge default
  • added one canonical public-host resolver so public consumers and handlers preserve those built-in defaults identically
  • replaced repeated handler/type resolution on layout paths with one reusable four-edge snapshot
  • made nested Apple suppression per-edge, pixel-tolerant, and bounded once all four ancestor-handled edges are known
  • preserved a child's frame-relative keyboard overlap when an ancestor handles only the smaller container inset, with an arranging-parent regression whose assertion fails under unconditional suppression
  • made every Bottom SoftInput MauiView compute its own residual even when an ancestor also declares SoftInput: an arranged child falls back to ordinary ancestor suppression, while an overflowing child retains only its positive live overlap
  • refreshed active Bottom SoftInput geometry during layout so transforms cannot preserve stale keyboard overlap; mutation testing makes the transformed-child assertion fail without the refresh
  • retained ancestor-edge caches across unchanged keyboard-visible layout passes by comparing absolute overlap values in device-pixel buckets, including cumulative sub-pixel movement
  • converted keyboard notification frames from screen coordinates into the active window before view-frame intersection
  • required a two-dimensional keyboard/view intersection, clamped overlap to the view height, and classified ancestor pixel values with the owning window's screen scale
  • required a SoftInput ancestor to respond to safe area before it can suppress keyboard auto-scroll
  • propagated actual safe-area interaction changes to plain descendants so multi-pass keyboard layout converges without per-layout subtree churn
  • exercised the synchronous cross-platform arrange ordering through a real MAUI Grid
  • replaced the shared Element safe-area identity special case with reusable internal bindable-property specificity metadata
  • documented the same-edge keyboard-residual exception and why MauiScrollView deliberately keeps ordinary suppression for raw/system insets, with a bottom-edge regression that fails if the keyboard exemption is applied there
  • preserved UIKit SystemAdjustedContentInset values while keeping per-edge ancestor suppression for manually computed scroll insets
  • skipped ancestor lookup for empty adjusted insets and skipped farther-ancestor keyboard geometry once Bottom is resolved
  • skipped duplicate strategy resolution when the keyboard is already hidden, with read-count and show/hide/show lifecycle coverage
  • retained full native-subtree invalidation because an exact mutation proves _safeAreaInvalidated cannot represent descendant state; a persistent latch is also unsound across same-window reparenting of generic UIView subtrees
  • preserved the pre-existing edge-to-edge fallback for legacy-only IScrollView implementations
  • clarified compatibility-resolved interface values for built-in controls and aligned the Android handler guard ordering with iOS
  • clarified that GetEffectiveSafeAreaEdges() returns resolved handler input rather than final platform-applied geometry
  • verified that clearing an equal-valued explicit SafeAreaEdges value still notifies the handler when explicitness changes
  • made focused and full-category safe-area UI fixtures independent of predecessor footer state and orientation
  • regenerated all three binary/text AOT profile pairs for the six-parameter property-set signatures, repaired the fully qualified strategy type, removed the Android-unreachable strategy method, and validated them with a real Mono profiled-AOT publish

Existing PR comparison

I searched the open pull requests for #37384 and equivalent safe-area API titles. No competing implementation exists, so there was no alternative change set to compare.

Fixes #37384

Make the per-edge safe area interfaces and shared bindable-property plumbing reusable outside MAUI. Keep platform inset reporting internal, migrate built-in controls, and add custom-view regression coverage.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings August 22, 2026 23:18
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 22, 2026 23:19 — with GitHub Actions Inactive
@github-actions

Copy link
Copy Markdown
Contributor

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 37750

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 37750"

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
There may be pipelines that require an authorized user to comment /azp run to run.

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 22, 2026 23:19 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 22, 2026 23:20 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 22, 2026 23:23 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 22, 2026 23:24 — with GitHub Actions Inactive
@github-actions github-actions Bot added area-safearea Issues/PRs that have to do with the SafeArea functionality platform/ios labels Aug 22, 2026
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool August 22, 2026 23:24 — with GitHub Actions Inactive

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR exposes public per-edge safe-area contracts for custom MAUI views and native hosts, adds shared plumbing, and preserves internal iOS inset reporting.

Changes:

  • Publishes safe-area interfaces and edge lookup APIs.
  • Migrates built-in controls to shared safe-area helpers.
  • Adds API baselines and regression coverage.

Reviewed changes

Copilot reviewed 28 out of 28 changed files in this pull request and generated 1 comment.

Show a summary per file
File Summary
src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt Records Core API additions.
src/Core/src/PublicAPI/netstandard/PublicAPI.Unshipped.txt Records Core API additions.
src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt Records Core API additions.
src/Core/src/PublicAPI/net-windows/PublicAPI.Unshipped.txt Records Core API additions.
src/Core/src/PublicAPI/net-tizen/PublicAPI.Unshipped.txt Records Core API additions.
src/Core/src/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt Records Core API additions.
src/Core/src/PublicAPI/net-ios/PublicAPI.Unshipped.txt Records Core API additions.
src/Core/src/PublicAPI/net-android/PublicAPI.Unshipped.txt Records Core API additions.
src/Core/src/Primitives/SafeAreaEdges.cs Exposes per-edge lookup.
src/Core/src/Platform/iOS/MauiView.cs Uses the internal inset sink.
src/Core/src/Core/ISafeAreaView2.cs Publishes the per-edge safe-area contract.
src/Core/src/Core/ISafeAreaInsets.cs Defines internal inset reporting.
src/Core/src/Core/ISafeAreaElement.cs Publishes the shared element contract.
src/Controls/tests/Core.UnitTests/SafeAreaTests.cs Critical (1 vote): the private CustomSafeAreaView has a non-public constructor, causing Activator.CreateInstance(Type) to throw MissingMethodException.
src/Controls/src/Core/ScrollView/ScrollView.cs Migrates safe-area behavior.
src/Controls/src/Core/SafeAreaElement.cs Adds shared safe-area property plumbing.
src/Controls/src/Core/PublicAPI/netstandard/PublicAPI.Unshipped.txt Records Controls API additions.
src/Controls/src/Core/PublicAPI/net/PublicAPI.Unshipped.txt Records Controls API additions.
src/Controls/src/Core/PublicAPI/net-windows/PublicAPI.Unshipped.txt Records Controls API additions.
src/Controls/src/Core/PublicAPI/net-tizen/PublicAPI.Unshipped.txt Records Controls API additions.
src/Controls/src/Core/PublicAPI/net-maccatalyst/PublicAPI.Unshipped.txt Records Controls API additions.
src/Controls/src/Core/PublicAPI/net-ios/PublicAPI.Unshipped.txt Records Controls API additions.
src/Controls/src/Core/PublicAPI/net-android/PublicAPI.Unshipped.txt Records Controls API additions.
src/Controls/src/Core/Page/Page.cs Implements inset handling.
src/Controls/src/Core/Layout/Layout.cs Migrates safe-area behavior.
src/Controls/src/Core/ContentView/ContentView.cs Migrates safe-area behavior.
src/Controls/src/Core/ContentPage/ContentPage.cs Migrates safe-area behavior.
src/Controls/src/Core/Border/Border.cs Migrates safe-area behavior.
Suppressed comments (4)

src/Controls/src/Core/ContentPage/ContentPage.cs:174

  • HasExplicitSafeAreaEdges now correctly uses IsSafeAreaEdgesSet, but the adjacent per-edge resolver still uses IsSet. IsSet treats default-value creation as set, so merely reading SafeAreaEdges first causes this method to skip the iOS IgnoreSafeArea fallback and return the default None instead. Use SafeAreaElement.IsSafeAreaEdgesSet(this) here as well and cover the read-then-resolve sequence.
		bool ISafeAreaView2.HasExplicitSafeAreaEdges => SafeAreaElement.IsSafeAreaEdgesSet(this);

src/Controls/src/Core/Layout/Layout.cs:376

  • Please regenerate the profiled AOT artifacts for this rename. The checked-in maui.aotprofile.txt and maui-sc.aotprofile.txt still list Layout/ScrollView:ISafeAreaElement.SafeAreaEdgesDefaultValueCreator, while these implementations are now GetDefaultSafeAreaEdges; Microsoft.Maui.Controls.targets imports the corresponding binary profiles for Android, so these calls will no longer match the profiled methods (and the profile tool may report missing methods).
		SafeAreaEdges ISafeAreaElement.GetDefaultSafeAreaEdges()
		{
			return SafeAreaEdges.Container;
		}

src/Controls/src/Core/ScrollView/ScrollView.cs:553

  • This renames the explicit ISafeAreaElement implementation used by Layout and ScrollView, but the checked-in profiled-AOT lists still reference Microsoft.Maui.ISafeAreaElement.SafeAreaEdgesDefaultValueCreator (in maui.aotprofile.txt and maui-sc.aotprofile.txt). Regenerate those profile outputs so they reference GetDefaultSafeAreaEdges; otherwise the profiles are stale and no longer describe methods in the assembly.
		SafeAreaEdges ISafeAreaElement.GetDefaultSafeAreaEdges()

src/Controls/tests/Core.UnitTests/SafeAreaTests.cs:287

  • These assertions verify the public contracts and property mapping only; they never create a handler or send insets through the iOS MauiView/Android inset-listener paths. A regression in the platform-side ISafeAreaView2 lookup or listener refresh would therefore still pass these tests even though a direct custom View no longer receives the advertised per-edge behavior. Add focused device coverage for the custom view on Android and iOS, or include the probe as an automated test.
		public void CustomView_CanReuseSafeAreaEdgesContract()
		{
			var view = new CustomSafeAreaView();
			var safeAreaView = (ISafeAreaView2)view;

@kubaflo

kubaflo commented Aug 22, 2026

Copy link
Copy Markdown
Contributor Author

Validated the review findings against the current head:

  • ContentPage.GetSafeAreaRegionsForEdge still uses IsSet, so default-value creation can incorrectly bypass the legacy iOS fallback.
  • Both checked-in AOT profiles retain four SafeAreaEdgesDefaultValueCreator entries after the rename.
  • The 28-file diff contains no device-test coverage for the platform inset path.
  • The private-constructor Activator.CreateInstance issue is confirmed separately in the inline thread.

This branch is actively owned in another worktree with recent source/build activity, so the monitor is reply-only here: I did not edit or push, and the actionable thread remains open for the owning agent.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: d00747b7-96f3-4e7a-8dfb-e3a48db04b2d
Copilot AI review requested due to automatic review settings August 23, 2026 02:09
@kubaflo

kubaflo commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

@copilot-pull-request-reviewer addressed the validated feedback in ecf8393: corrected ContentPage explicit-edge detection after default-value reads, regenerated both binary/text AOT profiles for the renamed explicit implementations, fixed private test-view construction, and added Android/iOS custom-view handler coverage. Focused validation passed (64 unit, 40 iOS View, 5 iOS Page, and 51 Android View tests). This is ready for re-review — thanks!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 34 out of 36 changed files in this pull request and generated 2 comments.

Suppressed comments (1)

src/Controls/src/Core/SafeAreaElement.cs:24

  • This newly reusable property is not wired to safe-area invalidation on Mac Catalyst: the existing ViewHandler mapper is guarded by #if ANDROID || IOS, while MauiView and ViewHandler.iOS.cs also compile for Mac Catalyst. Consequently, changing a custom view's SafeAreaEdges after its handler is connected does not invalidate the safe-area layout there. Register MapSafeAreaEdges for MACCATALYST as well and add a post-handler-change regression test.
		public static readonly BindableProperty SafeAreaEdgesProperty =
			BindableProperty.Create(nameof(ISafeAreaElement.SafeAreaEdges), typeof(SafeAreaEdges), typeof(ISafeAreaElement), SafeAreaEdges.Default,
									defaultValueCreator: SafeAreaEdgesDefaultValueCreator);

Comment thread src/Core/src/Core/ISafeAreaView2.cs Resolved
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: d00747b7-96f3-4e7a-8dfb-e3a48db04b2d
Copilot AI review requested due to automatic review settings August 23, 2026 03:36
@kubaflo

kubaflo commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

@copilot-pull-request-reviewer[bot] addressed both latest findings in dc737cb: descendant safe-area caches are invalidated when an ancestor strategy changes, and the mapper now runs on Mac Catalyst. Focused View device tests passed 41/41 on both iOS and Mac Catalyst. This is ready for re-review — thanks!

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 36 out of 38 changed files in this pull request and generated no new comments.

Suppressed comments (2)

src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/maui-sc.aotprofile.txt:3287

  • The text snapshot now records GetDefaultSafeAreaEdges, but the paired maui-sc.aotprofile binary is not regenerated. Microsoft.Maui.Controls.targets imports that binary for Android profiled AOT, so consumers will still ship a profile containing the removed interface method and will not profile the new calls. Please rerun the documented Record target for maui-sc and commit the regenerated binary with this snapshot.
    src/Controls/src/Build.Tasks/nuget/buildTransitive/netstandard2.0/maui.aotprofile.txt:2594
  • The text snapshot now records GetDefaultSafeAreaEdges, but the paired maui.aotprofile binary is not regenerated. Microsoft.Maui.Controls.targets imports that binary for Android profiled AOT, so consumers will still ship a profile containing the removed interface method and will not profile the new calls. Please rerun the documented Record target for maui and commit the regenerated binary with this snapshot.
	Microsoft.Maui.SafeAreaEdges Microsoft.Maui.Controls.Layout:Microsoft.Maui.ISafeAreaElement.GetDefaultSafeAreaEdges ()

@kubaflo

kubaflo commented Aug 23, 2026

Copy link
Copy Markdown
Contributor Author

Thanks for the re-review. The two suppressed AOT-profile notes are already satisfied by ecf8393: that commit changed both maui.aotprofile and maui-sc.aotprofile, and aprofutil -m shows the new GetDefaultSafeAreaEdges entries in each binary. A full sorted method-set comparison against the checked-in text snapshots reports zero differences (maui: 8,634 methods; maui-sc: 10,965 methods), so another profile regeneration would be redundant. No code change is needed for these suppressed findings.

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added the s/agent-review-in-progress AI review is currently running for this PR label Aug 23, 2026
@MauiBot

This comment has been minimized.

@github-actions github-actions Bot added s/agent-review-in-progress AI review is currently running for this PR and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 27, 2026
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: de9c7c01-82c4-42fd-9ab7-882279aadd15

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 9 findings

See inline comments for details.

Comment thread src/Core/src/Platform/iOS/MauiView.cs Resolved
Comment thread src/Core/src/Platform/iOS/MauiView.cs Resolved
Comment thread src/Core/src/Platform/iOS/MauiView.cs Resolved
Comment thread src/Core/src/Platform/iOS/MauiView.cs Resolved
Comment thread src/Core/src/Core/ISafeAreaElement.cs Resolved
Comment thread src/Core/src/Platform/iOS/MauiView.cs Resolved
MauiBot

This comment was marked as outdated.

Clarify native inset and invalidation semantics, strengthen keyboard cache coverage, and keep frame-relative keyboard overlap out of desired-size growth.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot-Session: de9c7c01-82c4-42fd-9ab7-882279aadd15
@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added s/agent-review-in-progress AI review is currently running for this PR and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 28, 2026
@kubaflo kubaflo added the s/agent-review-in-progress AI review is currently running for this PR label Aug 28, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 4 findings

See inline comments for details.

// depend on whether the ancestor has already completed its layout pass.
// Keyboard overlap only changes Bottom, so farther ancestors can omit that
// calculation after the nearest nonzero Bottom has been classified.
var safeArea = mauiView.GetAdjustedSafeAreaInsets(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Performance-Critical Path — This ancestor walk recomputes each ancestor's full adjusted safe area on every cache miss. GetAdjustedSafeAreaInsets resolves the strategy (SafeAreaViewStrategy.TryGetSafeAreaEdges), loops all four edges through GetSafeAreaForEdge, and — when includeKeyboardOverlap is true — crosses into UIKit via ConvertRectToView/ConvertRectFromCoordinateSpace. The previous implementation read the already-computed mv._appliesSafeAreaAdjustments field and short-circuited via FindParent at the first matching ancestor; the new loop only exits once all four edges are non-None, so in the common case (page applies Top only, or nothing applies) it walks to the root recomputing insets at every level.

Concrete scenario: a ContentPage > Grid > Border > ContentView > Layout chain of depth N where each level is a MauiView. Every ValidateSafeArea on level i walks i ancestors and fully re-resolves each, giving O(N²) inset resolutions per layout pass — and _parentHandledSafeAreaEdges is now invalidated far more often (soft-input overlap change at line ~828, InvalidateDescendantSafeAreas cascade), so cache misses are frequent rather than one-time.

Suggestion: cache the ancestor's resolved insets on the ancestor itself (it already computes them in ValidateSafeArea) and reuse that, or short-circuit the ancestor loop once the edges this view actually requests are all classified rather than requiring all four.

(oldSafeArea.EqualsAtPixelLevel(_safeArea) || !_appliesSafeAreaAdjustments);

if (!interactionUnchanged)
InvalidateDescendantSafeAreas();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Layout Measure-Arrange Correctness — InvalidateDescendantSafeAreas() is invoked from ValidateSafeArea, which runs inside the layout pass (LayoutSubviews). It recursively walks the entire native descendant subtree (InvalidateSafeArea(UIView) at line 982), marshalling a fresh managed UIView[] from Subviews at every node and calling SetNeedsLayout() on every descendant MauiView/MauiScrollView. Each invalidated descendant then re-runs ValidateSafeArea on the next pass and, if its interaction changed, invalidates its own subtree again.

Concrete scenario: rotation or keyboard show on a deep page — the root MauiView's interaction changes, it dirties the whole subtree; the direct children then each dirty their own (overlapping) subtrees on the following pass, so a single safe-area change produces repeated full-subtree walks and multiple extra layout passes proportional to nesting depth. This is the same class of layout-oscillation risk the pixel-level comparison at line 866 exists to suppress.

Suggestion: restrict the cascade to descendants whose cached _parentHandledSafeAreaEdges is actually non-null (i.e. would change), and stop recursing into a subtree once a descendant's classification is unaffected, instead of an unconditional full-subtree walk.


if (handler.PlatformView is PlatformView platformView)
{
MauiView.InvalidateSafeArea(platformView);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Performance-Critical Path — MapSafeAreaEdges now triggers a full recursive walk of the platform view's entire descendant subtree (MauiView.InvalidateSafeArea allocates a managed UIView[] per node and calls SetNeedsLayout() on every MauiView/MauiScrollView found). This mapper also fires more often than before: SafeAreaElement.SafeAreaEdgesProperty sets the new UpdateHandlerOnSpecificityChange = true flag (SafeAreaElement.cs), so Element.OnBindablePropertySet now calls UpdateHandlerValue(..., true) when only the setter specificity changed and the resolved value is identical.

Concrete scenario: a page with an implicit style that sets SafeAreaEdges, applied/removed during a visual-state or theme change — the value never changes, but every specificity transition now walks and dirties the whole page subtree. Consider scoping the invalidation to the handler's own platform view plus descendants that actually cache ancestor-handled edges, or short-circuiting when the resolved SafeAreaEdges value is unchanged.

/// <see cref="HasExplicitSafeAreaEdges"/> and <see cref="GetDefaultSafeAreaEdges"/> are required because platform
/// handlers need both values to distinguish configured behavior from each control's default behavior.
/// </remarks>
public interface ISafeAreaElement

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Public API Surface Design — ISafeAreaElement is promoted from internal to public with three required members (SafeAreaEdges, HasExplicitSafeAreaEdges, GetDefaultSafeAreaEdges()) and no default interface implementations. Once shipped, any future member cannot be added without a binary/source breaking change for every third-party implementer — which is exactly the constraint that forced the ISafeAreaView → ISafeAreaView2 numbered-interface churn this PR is unwinding.

Two of the three members have an obvious, safe default: HasExplicitSafeAreaEdges is documented to be implemented as SafeAreaElement.IsSafeAreaEdgesSet(this) and GetDefaultSafeAreaEdges() almost always returns SafeAreaEdges.None. Providing these as default interface methods (leaving only SafeAreaEdges required) would both reduce the implementation burden for custom views and establish the DIM pattern that makes future additive members non-breaking.

MauiBot

This comment was marked as outdated.

@MauiBot MauiBot added s/agent-fix-pr-picked AI could not beat the PR fix - PR is the best among all candidates and removed s/agent-fix-win AI found a better alternative fix than the PR s/agent-review-in-progress AI review is currently running for this PR labels Aug 28, 2026
@kubaflo

kubaflo commented Aug 28, 2026

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 3 pipeline(s).

@kubaflo

This comment has been minimized.

@github-actions github-actions Bot added s/agent-review-in-progress AI review is currently running for this PR and removed s/agent-review-in-progress AI review is currently running for this PR labels Aug 28, 2026
@kubaflo kubaflo added the s/agent-review-in-progress AI review is currently running for this PR label Aug 28, 2026

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Expert Review — 12 findings

See inline comments for details.

Microsoft.Maui.ISafeAreaElement.GetDefaultSafeAreaEdges() -> Microsoft.Maui.SafeAreaEdges
Microsoft.Maui.SafeAreaElementExtensions
static Microsoft.Maui.SafeAreaElementExtensions.GetEffectiveSafeAreaEdges(this Microsoft.Maui.ISafeAreaElement! safeAreaElement) -> Microsoft.Maui.SafeAreaEdges
Microsoft.Maui.StatusBarTheme

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[critical] Public API Surface — These five StatusBarTheme entries (lines 8-12) are duplicates: the same symbols already exist further down this file at lines 26-30 and were not removed. PublicAPI.Unshipped.txt must not contain duplicate entries, so the public-API analyzer fails the build (RS0025 "Do not duplicate symbols in public API files") for Microsoft.Maui on every net target. This is what the gate observed as a with-fix HostApp BUILD ERROR (Issue28986_ParentChildTest and Issue32586 legs). These entries are also unrelated to the safe-area feature — they appear to be an accidental re-add during a rebase. Remove lines 8-12 and keep only the ISafeAreaElement/SafeAreaElementExtensions additions.

Microsoft.Maui.ISafeAreaElement.GetDefaultSafeAreaEdges() -> Microsoft.Maui.SafeAreaEdges
Microsoft.Maui.SafeAreaElementExtensions
static Microsoft.Maui.SafeAreaElementExtensions.GetEffectiveSafeAreaEdges(this Microsoft.Maui.ISafeAreaElement! safeAreaElement) -> Microsoft.Maui.SafeAreaEdges
Microsoft.Maui.StatusBarTheme

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[critical] Public API Surface — Same duplication as the net baseline: Microsoft.Maui.StatusBarTheme and its three members are added at lines 8-11 while identical entries already exist at lines 25-28. RS0025 fails the build for the netstandard2.0 target. Remove the newly added StatusBarTheme block.

// depend on whether the ancestor has already completed its layout pass.
// Keyboard overlap only changes Bottom, so farther ancestors can omit that
// calculation after the nearest nonzero Bottom has been classified.
var safeArea = mauiView.GetAdjustedSafeAreaInsets(

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Performance-Critical Path — GetParentHandledSafeAreaEdges recomputes each ancestor's full adjusted safe area from scratch (GetAdjustedSafeAreaInsets → SafeAreaViewStrategy.TryGetSafeAreaEdges interface dispatch, SafeAreaInsets marshalling, and for the first ancestor ConvertRectToView + keyboard-frame conversion) instead of reading the ancestor's already-computed _safeArea. This runs on the layout path for every MauiView/MauiScrollView whose ancestor-edge cache was dropped. Concrete scenario: a page with a nested layout depth of ~8 and 100 MauiView descendants — a single keyboard show invalidates the whole subtree (InvalidateSafeArea, line 982), so the next layout pass performs ~800 full ancestor inset recomputations with per-ancestor coordinate conversions, none of them shared between siblings. The comment justifies bypassing the ancestor's cached state ("so suppression does not depend on whether the ancestor has already completed its layout pass"), but the cost is O(depth) per view per invalidation with no memoization; consider caching the resolved per-ancestor result for the duration of one layout pass.

/// <summary>
/// Invalidates safe area state for a native subtree.
/// </summary>
internal static void InvalidateSafeArea(UIView platformView)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Performance-Critical Path / Memory — InvalidateSafeArea(UIView) walks the entire native subtree recursively and UIView.Subviews allocates a new managed array (marshalled from NSArray) at every node, including for the many non-MAUI intermediate views. It is invoked from MapSafeAreaEdges (ViewHandler.iOS.cs), from every keyboard will-show/will-hide/change notification (ClearKeyboardState, OnKeyboardWillShow), and indirectly from InvalidateDescendantSafeAreas on each safe-area interaction change. Concrete scenario: a CollectionView page with several hundred realized cells — each keyboard toggle allocates one array per view in the subtree and calls SetNeedsLayout() on every MauiView, forcing a full-subtree layout pass rather than only the views whose safe area actually changed. Consider bounding the walk (stop descending into subtrees that cannot respond to safe area, e.g. below a UIScrollView where RespondsToSafeArea() is already false) and avoiding the repeated Subviews allocation.

(oldSafeArea.EqualsAtPixelLevel(_safeArea) || !_appliesSafeAreaAdjustments);

if (!interactionUnchanged)
InvalidateDescendantSafeAreas();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Layout Measure-Arrange Correctness — InvalidateDescendantSafeAreas() is called from inside UpdateSafeAreaValues, which runs on the layout path. Each descendant is marked _safeAreaInvalidated and gets SetNeedsLayout(), and each descendant that then changes its own interaction state re-invalidates its descendants. The only guard against re-entry is the pixel-level comparison in EqualsAtPixelLevel. Concrete scenario: a parent whose padding change alters a child's frame, where the child's SoftInput bottom overlap is frame-relative (TryGetSoftInputBottomOverlap) — parent invalidates child → child's overlap changes → child invalidates its own descendants and requests layout → parent re-measures. During a keyboard animation the frames move every frame, so the pixel quantization is the sole thing preventing a sustained invalidate/layout cycle of the kind #32586 and #33934 previously hit. The added device tests exercise settled states; please add explicit coverage that the number of layout passes converges while the keyboard frame is animating (not just after it settles).

&& AreEqualAtPixelLevel(Bottom, other.Bottom, scale);
}

public static bool AreEqualAtPixelLevel(double first, double second, double scale)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Logic and Correctness / iOS Platform — AreEqualAtPixelLevel/IsZeroAtPixelLevel take an explicit scale, and the new call sites in MauiView pass the view's own screen scale (view.Window?.Screen.Scale ?? UIScreen.MainScreen.Scale), but EqualsAtPixelLevel (line 39) still hardcodes UIScreen.MainScreen.Scale. The two quantizations therefore disagree whenever the window is not on the main screen — external display, Stage Manager, or Mac Catalyst with a non-1.0 backing scale. Concrete effect: GetParentHandledSafeAreaEdges classifies an edge as "not zero" at the window scale while UpdateSafeAreaValues decides the interaction is "unchanged" at the main-screen scale, so a real inset change can be swallowed (stale padding) or a sub-pixel one can be treated as a change (extra layout passes). Route EqualsAtPixelLevel through the same window-derived scale.


var oldApplyingSafeAreaAdjustments = _appliesSafeAreaAdjustments;
_appliesSafeAreaAdjustments = !IsParentHandlingSafeArea() && RespondsToSafeArea() && !_safeArea.IsEmpty;
_appliesSafeAreaAdjustments = RespondsToSafeArea() && !_safeArea.IsEmpty;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Layout Measure-Arrange Correctness — _appliesSafeAreaAdjustments no longer includes the parent-handled check, and suppression is now folded into _safeArea only on the manual-inset branch (line 379). On the else branch the value is taken verbatim from SystemAdjustedContentInset with no ancestor filtering. Concrete scenario: a ScrollView inside a Grid with SafeAreaEdges="Container" whose content is initially shorter than the bounds (manual branch, bottom suppressed because the parent already padded it) and then grows past the bounds — UIKit starts reporting a non-zero SystemAdjustedContentInset and the same bottom inset is applied a second time, shifting content by roughly 2× the home-indicator inset at the moment the content crosses the scroll bounds. The inline comment argues UIKit already accounts for ancestor geometry; if that is the intended contract, please state which UIKit guarantee makes the ancestor's padding observable in SystemAdjustedContentInset, and add a device test that crosses the content-size threshold with a padding ancestor (the existing ScrollViewTransitionToSystemAdjustedInsetsDropsParentSuppression asserts the suppression is dropped, not that the result is not double-padded).


// Step 5: Verify UI is still responsive
// Step 5: Verify UI is still responsive from either initial footer state.
var footerStatus = App.WaitForElement("TestLabel").GetText();

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[major] Regression Prevention — This change makes the assertion self-fulfilling: the expected text is derived from the state the app currently reports, so the test now passes for either toggle direction. The previous version pinned the outcome ("Footer is now hidden"), which is what made it a regression guard for #32586 — a fix that leaves the footer in the wrong state after the safe-area cycle would still satisfy the new assertion. This PR is also flagged by regression-check as REVERT (it removes lines added by #34024 in MauiView.cs, MauiScrollView.cs, and SafeAreaPadding.cs), and the A/B gate could not establish a without-fix baseline because the reshaped ISafeAreaElement breaks compilation of the test project. Weakening the only executable guard for #32586 in the same PR removes the last independent signal. Please restore a deterministic expectation (drive the fixture to a known state first, then assert the specific resulting text).

/// <inheritdoc cref="ISafeAreaView2.GetSafeAreaRegionsForEdge"/>
SafeAreaRegions ISafeAreaView2.GetSafeAreaRegionsForEdge(int edge)
/// <inheritdoc cref="ISafeAreaElement.SafeAreaEdges"/>
SafeAreaEdges ISafeAreaElement.SafeAreaEdges

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Public API Surface / Cross-Platform Consistency — ISafeAreaElement.SafeAreaEdges on ContentPage deliberately returns a value different from the public SafeAreaEdges property: when the property is unset on iOS/MacCatalyst it reports SafeAreaEdges.Container (from legacy IgnoreSafeArea) while page.SafeAreaEdges reports None. Because ISafeAreaElement is now public, third-party code reading ((ISafeAreaElement)page).SafeAreaEdges or the public SafeAreaElementExtensions.GetEffectiveSafeAreaEdges(page) gets a value that contradicts the property it can read directly, and the divergence is platform-conditional (#if IOS || MACCATALYST) so the same code returns None on Android/Windows. If the compatibility resolution must be observable, expose it through a distinct member (e.g. only via GetEffectiveSafeAreaEdges) and let the interface property mirror the bindable value, so the public contract has one meaning per member.

/// <see cref="HasExplicitSafeAreaEdges"/> and <see cref="GetDefaultSafeAreaEdges"/> are required because platform
/// handlers need both values to distinguish configured behavior from each control's default behavior.
/// </remarks>
public interface ISafeAreaElement

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔍 AI-Generated Review (multi-model)

[moderate] Public API Surface — ISafeAreaElement becomes public with three required members and no default implementations, so every future addition to the safe-area contract is a binary/source breaking change for third-party implementers; consider adding default interface implementations for HasExplicitSafeAreaEdges and GetDefaultSafeAreaEdges now (returning false / SafeAreaEdges.Default) so the common case is a one-member implementation and later growth stays non-breaking. Two further parts of the contract are documented but unenforceable: the requirement to also expose a public SafeAreaEdges property backed by a public static SafeAreaEdgesProperty field (XAML addressability), and the requirement to be a BindableObject using SafeAreaElement.SafeAreaEdgesProperty — an implementer that violates the latter gets an InvalidOperationException thrown from inside the bindable-property default-value creator on first read rather than a compile-time error. An analyzer or a base type would make this diagnosable.

@MauiBot MauiBot left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AI Review Summary

@kubaflo — new AI review results are available based on commit e7d2cdc.

Gate Failed Confidence Unknown Platform iOS


🗂️ Review Sessions — click to expand
🚦 Gate — Test Before & After Fix

Gate Result: ❌ FAILED

Platform: IOS · Base: net11.0 · Merge base: 533bb4aa

🩺 Pre-existing build failure (not the fix) — both the without-fix baseline AND the with-fix build fail with a build error, so the PR's fix is NOT the cause. This is a broken main/merge-base or a toolchain/environment failure (e.g. an ILLink IL1012 trimmer crash). The gate cannot verify anything; investigate the build environment rather than the PR.

/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/SafeAreaTests.cs(538,26): error CS0539: 'SafeAreaTests.CustomSafeAreaView.HasExplicitSafeAreaEdges' in explicit interface declaration i...

⚠️ Gate coverage limitations

  • The A/B gate did not verify 1 dropped DeviceTest group(s): ViewTests (CustomViewSafeAreaEdgesReachMauiView, ChangingParentSafeAreaEdgesInvalidatesDescendants, MeasureInvalidatedParentDoesNotBlockDescendantSafeAreaInvalidation, ParentSafeAreaSuppressionDoesNotDependOnLayoutOrder, ResolvedBottomEdgeSkipsFartherAncestorKeyboardGeometry, ResidualParentInsetDoesNotSuppressChildSafeArea, ParentHandledEdgeLookupStopsWhenAllEdgesAreResolved, EmptySafeAreaSkipsParentHandledEdgeLookup, EmptyManualScrollViewSafeAreaSkipsParentHandledEdgeLookup, KeyboardSafeAreaChangesInvalidateDescendants, ParentContainerSafeAreaDoesNotSuppressChildKeyboardSafeArea, ParentAndChildKeyboardSafeAreasDoNotDoublePadArrangedChild, ParentAndChildKeyboardSafeAreasProtectOverflowingChild, HiddenKeyboardSkipsDuplicateSoftInputStrategyResolution, UnchangedKeyboardGeometryKeepsAncestorSafeAreaCache, ChangedKeyboardOverlapInvalidatesNonSoftInputDescendants, SoftInputAncestorInsideScrollViewDoesNotSuppressKeyboardAutoScroll, KeyboardFrameConvertsFromScreenToWindowCoordinates, FloatingKeyboardUsesClampedViewIntersection, DesiredSizeDrivenSoftInputViewSettlesWhileKeyboardIsVisible, NestedKeyboardSafeAreasUseCrossPlatformArrange, ParentOnlySuppressesOverlappingChildSafeAreaEdges, ParentOnlySuppressesOverlappingScrollViewSafeAreaEdges, SystemAdjustedScrollViewInsetsAreNotSuppressedByParent, ScrollViewTransitionToSystemAdjustedInsetsDropsParentSuppression, ChangingAncestorSafeAreaEdgesInvalidatesEdgeDisjointGrandchild). Deep UI Tests runs HostApp UI categories only and does not execute DeviceTests; separate device-test validation is required.
Test Without Fix (expect FAIL) With Fix (expect PASS)
🧪 SafeAreaTests SafeAreaTests 🛠️ BUILD ERROR ✅ PASS — 16s
📄 SafeAreaEdgesTests SafeAreaEdgesTests 🛠️ BUILD ERROR ✅ PASS — 15s
📄 Tests Tests 🛠️ BUILD ERROR ✅ PASS — 120s
📱 PageTests (ReadingDefaultSafeAreaEdgesPreservesLegacySafeAreaFallback) Category=Page 🛠️ BUILD ERROR ⚠️ ENV ERROR
📱 ScrollViewHandlerTests (LegacySafeAreaViewWithoutModernContractRemainsEdgeToEdge) Category=ScrollView ⚠️ ENV ERROR ⚠️ ENV ERROR
🖥️ Issue28986_ParentChildTest Issue28986_ParentChildTest ❌ PASS — 347s 🛠️ BUILD ERROR
🖥️ Issue32586 Issue32586 ❌ PASS — 347s 🛠️ BUILD ERROR
🔴 Without fix — 🧪 SafeAreaTests: 🛠️ BUILD ERROR · 16s

Error-relevant lines (filtered from the build log):

/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/SafeAreaTests.cs(596,35): error CS0539: 'SafeAreaTests.DerivedSafeAreaContentPage.GetDefaultSafeAreaEdges()' in explicit interface declaration is not found among members of the interface that can be implemented [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/SafeAreaTests.cs(602,26): error CS0539: 'SafeAreaTests.DerivedDefaultSafeAreaContentPage.HasExplicitSafeAreaEdges' in explicit interface declaration is not found among members of the interface that can be implemented [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/SafeAreaTests.cs(603,35): error CS0539: 'SafeAreaTests.DerivedDefaultSafeAreaContentPage.GetDefaultSafeAreaEdges()' in explicit interface declaration is not found among members of the interface that can be implemented [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/SafeAreaTests.cs(616,26): error CS0539: 'SafeAreaTests.CustomNoneSafeAreaView.HasExplicitSafeAreaEdges' in explicit interface declaration is not found among members of the interface that can be implemented [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/SafeAreaTests.cs(618,35): error CS0539: 'SafeAreaTests.CustomNoneSafeAreaView.GetDefaultSafeAreaEdges()' in explicit interface declaration is not found among members of the interface that can be implemented [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/SafeAreaTests.cs(631,26): error CS0539: 'SafeAreaTests.CustomMixedSafeAreaView.HasExplicitSafeAreaEdges' in explicit interface declaration is not found among members of the interface that can be implemented [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/SafeAreaTests.cs(633,35): error CS0539: 'SafeAreaTests.CustomMixedSafeAreaView.GetDefaultSafeAreaEdges()' in explicit interface declaration is not found among members of the interface that can be implemented [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/SafeAreaTests.cs(516,43): error CS0535: 'SafeAreaTests.CustomSafeAreaView' does not implement interface member 'ISafeAreaElement.SafeAreaEdgesDefaultValueCreator()' [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]
/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/SafeAreaTests.cs(543,43): error CS0535: 'SafeAreaTests.CustomSafeAreaPage' does not implement interface member 'ISafeAreaElement.SafeAreaEdgesDefaultValueCreator()' [/Users/cloudtest/vss/_work/1/s/src/Controls/tests/Core.UnitTests/Controls.Core.UnitTests.csproj]

This Gate section was shortened to keep every required review section visible. Full details remain available in the pipeline build artifacts.


📋 Pre-Flight — Context & Validation

PR #37750 Pre-Flight

Scope

  • PR: #37750, [net11.0] Expose safe area contract for custom views
  • Issue: #37384, requesting a public per-edge safe-area contract and reusable bindable-property plumbing for third-party views and native hosts.
  • Review branch: pr-review-37750
  • Materialized PR commit: 132954fc3c523c030b15820a17819d694734b45c (PR #37750 squashed for review)
  • PR parent / gate merge base: 533bb4aaef6b78d2e3d9db4a5ece6cd04c8ea220
  • Canonical diff: HEAD^..HEAD. The local origin/main...HEAD range is not a valid representation of this materialized PR because the review branch ancestry includes unrelated target-branch movement.
  • Patch size: 58 files, 3,265 insertions, 538 deletions.

Existing implementation

The PR replaces the internal numbered ISafeAreaView2 contract with a public capability-oriented ISafeAreaElement contract. It exposes SafeAreaEdges, explicit-value state, control-specific defaults, a public effective-value resolver, and the shared Controls bindable property. Built-in controls retain an internal strategy layer for legacy/default compatibility. Android and Apple handlers resolve all modern and legacy inputs through that shared strategy.

The Apple implementation substantially rewrites ancestor suppression and invalidation. MauiView and MauiScrollView resolve safe-area regions per edge, classify nonzero physical insets at device-pixel resolution, cache handled ancestor edges, invalidate descendants when geometry or strategy changes, and calculate nested keyboard overlap from window-relative frames. SafeAreaPadding adds reusable pixel-level equality and zero checks.

The patch also changes bindable-property specificity notifications, updates every affected public API baseline and AOT profile, adds extensive unit/XAML/device coverage, and adjusts two historical HostApp fixtures to make their state and orientation independent.

Direct diff observations

  • Public API is centered on src/Core/src/Core/ISafeAreaElement.cs; built-in compatibility and legacy precedence are centralized in the new src/Core/src/Core/ISafeAreaViewStrategy.cs.
  • Shared bindable-property creation and explicitness detection are in src/Controls/src/Core/SafeAreaElement.cs.
  • The highest-risk runtime changes are in:
    • src/Core/src/Platform/iOS/MauiView.cs
    • src/Core/src/Platform/iOS/MauiScrollView.cs
    • src/Core/src/Platform/iOS/KeyboardAutoManagerScroll.cs
    • src/Core/src/Platform/iOS/SafeAreaPadding.cs
  • Regression cross-reference found removed lines previously introduced by #34024 in MauiView.cs, MauiScrollView.cs, and SafeAreaPadding.cs. The removed nullable parent-state cache and direct pixel comparison are replaced by per-edge ancestor state and shared pixel helpers, so historical behavior must be demonstrated rather than inferred.
  • The PR adds two production files: ISafeAreaInsets.cs and ISafeAreaViewStrategy.cs. The try-fix baseline contract requires an attempt to report Blocked before editing if EstablishBrokenBaseline.ps1 records either as an unsafe NewFiles entry.

Gate evidence

The existing gate is definitive FAILED; it must not be rerun or overwritten.

  • With the PR applied, focused SafeAreaTests passed 78/78 and SafeAreaEdgesTests passed 15/15.

This pre-flight section was shortened to keep every required review section visible. Full details remain available in the pipeline build artifacts.


🔬 Code Review — Deep Analysis

Expert PR Evaluation — dotnet/maui #37750

PR: [net11.0] Expose safe area contract for custom views · Issue #37384
Materialized commit: 132954fc3c (PR #37750 squashed for review) · parent 533bb4aaef
Canonical diff: HEAD^..HEAD — 58 files, +3,265 / −538
Scope of this pass: raw submitted PR fix only. Read-only. No product-code edits, no candidate patch, no gate rerun, no GitHub posting.
Primary artifact: CustomAgentLogsTmp/PRState/37750/PRAgent/inline-findings.json (12 findings, all on added RIGHT-side lines, machine-verified against git diff -U0).


1. Independent assessment (formed from the diff before reading pipeline narrative)

The PR does four separable things:

  1. Contract reshape (Core). The internal numbered interface ISafeAreaView2 is deleted and split into three pieces:

    • public interface ISafeAreaElement (SafeAreaEdges, HasExplicitSafeAreaEdges, GetDefaultSafeAreaEdges()) — the capability-oriented public contract requested by #37384, replacing the previously-internal ISafeAreaElement.SafeAreaEdgesDefaultValueCreator().
    • internal interface ISafeAreaViewStrategy + internal static class SafeAreaViewStrategy — built-in-control compatibility/legacy resolution (GetSafeAreaRegionsForEdge, TryGetSafeAreaEdges, ResolveVirtualView, IsModernSafeAreaView).
    • internal interface ISafeAreaInsets — the write-back of raw SafeAreaInsets to Page.
      This is the right decomposition and directly satisfies the repo's own guidance ("prefer a capability-oriented contract such as ISafeAreaElement over publishing a numbered interface"). Resolution precedence is centralized in exactly one place (SafeAreaViewStrategy.TryGetSafeAreaEdges: strategy → element → legacy), which removes the duplicated per-control if (region == Default) ladders in Border, ContentView, ContentPage, Layout, ScrollView. Per-control default semantics are preserved (Border/ContentView/ContentPage → None, Layout → Container, ScrollView → unresolved Default via resolveUnspecifiedDefault: false), and Layout keeps IgnoreSafeArea winning over an explicit SafeAreaEdges, matching the pre-PR ordering. I verified each of these equivalences line-by-line against the deleted code; I found no semantic drift in the Controls-layer refactor.
  2. Controls plumbing. SafeAreaElement becomes public static and exposes the shared SafeAreaEdgesProperty plus IsSafeAreaEdgesSet(BindableObject). A new BindableProperty.UpdateHandlerOnSpecificityChange flag threads a specificityChanged argument through BindableObject.ClearValueCore/SetValueActual → OnBindablePropertySet → Element.UpdateHandlerValue, so a style/binding specificity change that leaves the value equal still re-runs the mapper. The specificity capture points are correct (original.Key captured before Values.Remove; originalSpecificity captured before Values.SetValue), and the flag is opt-in and currently set on exactly one property, so blast radius is contained. Element.OnBindablePropertySet re-tests property.UpdateHandlerOnSpecificityChange redundantly (already folded into specificityChanged) — harmless.

  3. Apple runtime rewrite (the actual risk). MauiView/MauiScrollView replace the boolean _parentHandlesSafeArea with per-edge SafeAreaEdges? _parentHandledSafeAreaEdges; suppression moves out of _appliesSafeAreaAdjustments and into the _safeArea value itself (ExcludeParentHandledSafeAreaEdges); the ancestor walk classifies an edge as handled by physical nonzero inset at device-pixel resolution rather than by region equality; keyboard overlap becomes frame-relative (TryGetSoftInputBottomOverlap, window-coordinate conversion, Math.Clamp); and a new recursive InvalidateSafeArea(UIView) / InvalidateDescendantSafeAreas() pushes invalidation down the native subtree. SafeAreaPadding gains scale-parameterized pixel helpers.

  4. Housekeeping. Public API baselines for 7+8 TFM folders, AOT profiles, ~2,500 lines of new unit/XAML/device tests, and edits to two existing HostApp UI regression tests.

My independent read is that (1) and (2) are well-executed and land the requested feature; (3) is a substantial behavioral rewrite whose correctness argument is carried mostly by inline comments plus new device tests that the pipeline could not execute; and (4) contains a build-breaking mistake.


2. Findings

Twelve findings written to inline-findings.json. Summary by severity:

Critical (2) — build break, unrelated to the feature

  • src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt:8-12 and src/Core/src/PublicAPI/netstandard2.0/PublicAPI.Unshipped.txt:8-11 re-add Microsoft.Maui.StatusBarTheme (+ members, + IWindow.StatusBarTheme.get in the net file) that already exist later in the same files (net: lines 26-30; ns2.0: lines 25-28). Verified mechanically:

    $ sort src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt | uniq -d
    Microsoft.Maui.IWindow.StatusBarTheme.get -> Microsoft.Maui.StatusBarTheme
    Microsoft.Maui.StatusBarTheme
    Microsoft.Maui.StatusBarTheme.Dark = 2 -> ...
    Microsoft.Maui.StatusBarTheme.Default = 0 -> ...
    Microsoft.Maui.StatusBarTheme.Light = 1 -> ...
    

    and the pre-PR file already contained those five lines (at 15-19). RS0025 (Do not duplicate symbols in public API files) fails the Microsoft.Maui build. This is the direct cause of the gate's with-fix BUILD ERROR on the two HostApp legs (Issue28986_ParentChildTest, Issue32586), which the pre-flight recorded as an "unrelated duplicate IWindow.StatusBarTheme" problem — it is not unrelated to this PR: the PR introduces the duplicates. Trivial to fix; must be fixed before merge.

Major (4)

  • MauiView.cs:553 — ancestor walk recomputes each ancestor's full adjusted safe area (interface dispatch + SafeAreaInsets + coordinate conversions) instead of reading the ancestor's cached _safeArea; O(depth) per view per invalidation, no sharing between siblings.

This code-review section was shortened to keep every required review section visible. Full details remain available in the pipeline build artifacts.


🛠️ Try-Fix — Analysis & Comparison

FINAL STEP 5a — Try-Fix Candidates (PR #37750)

Status: Bounded two-candidate set complete. Candidate 1: Blocked. Candidate 2: Blocked. No further candidate is authorized or pending.

Materialized PR: 132954fc3c523c030b15820a17819d694734b45c · canonical diff HEAD^..HEAD · Platform: iOS.

Aggregate conclusion

Neither alternative could be implemented or empirically tested because the mandatory try-fix baseline failed before producing an edit allow-list. Both candidates independently invoked EstablishBrokenBaseline.ps1; both received the same dirty-worktree abort against 83 pre-existing harness-owned paths, and neither invocation created .github/.baseline-state.json. Independently, the PR adds src/Core/src/Core/ISafeAreaInsets.cs and src/Core/src/Core/ISafeAreaViewStrategy.cs; even on a clean tree those would make baseline NewFiles non-empty and force Blocked under the skill's restore-safety rule.

Both candidates obeyed the boundary: empty candidate diffs, no tests, inline self-review with 0 findings, script-only -Restore returning the accepted no-state result (Restored False, No baseline state found), zero src/ drift, and all 83 pre-existing paths preserved. Consequently there is no empirical winner and neither design should be represented as validated. The surviving review signal is that the PR's without-fix gate leg does not compile because ISafeAreaElement was reshaped (SafeAreaEdgesDefaultValueCreator() versus HasExplicitSafeAreaEdges/GetDefaultSafeAreaEdges()), which is concrete source-compatibility evidence and also prevents a meaningful A/B behavioral baseline.


Candidate 1 — Blocked

Artifacts: CustomAgentLogsTmp/PRState/37750/PRAgent/try-fix/attempt-1/
Full narrative: CustomAgentLogsTmp/PRState/37750/PRAgent/try-fix-1/content.md

Approach designed (not implemented)

UIKit-owned inset subtraction via AdditionalSafeAreaInsets, plus a non-breaking additive public capability shim. When a MAUI container consumes a safe-area edge, write the consumed amount into the native view's AdditionalSafeAreaInsets as a negative per-edge offset. UIKit then propagates already-netted SafeAreaInsets and descendant callbacks, allowing each MauiView/MauiScrollView to read only its own inset. Expose the third-party capability through an attached bindable property and public static effective-value resolver while leaving built-in legacy/default semantics in the pre-existing ISafeAreaView compatibility path.

Prior approach avoided and mechanism difference

PR #37750 and predecessor #34024 both assume MAUI must maintain a managed mirror of ancestor safe-area consumption. #34024 used a nullable whole-view flag; #37750 generalizes it into per-edge ancestor caches, explicit descendant invalidation, pixel-tolerant comparisons, and window-relative keyboard residual calculations. Their shared vulnerability is cache coherency across geometry, strategy, orientation, keyboard, and reparenting changes.

Candidate 1 would subtract consumption at the UIKit producer. UIKit would own propagation, eliminating rather than relocating the managed cache/invalidation class. Its additive API shim would avoid reshaping the existing interface and therefore avoid the gate's source break.

Exact diff and validation

Candidate diff: empty. fix.diff and reviewer-findings.diff are 0 bytes.

  • Baseline: exit 1, dirty worktree; no baseline state.
  • Primary focused unit test: not run because no edit was permitted.
  • All 13 HostApp regressions: not run; gated behind primary success.
  • Inline self-review: 0 findings.
  • Restore: exit 0, Restored False / No baseline state found.
  • Post-restore: 83 pre-existing status paths, 0 src/ changes.

Candidate 1 result

Blocked, not a design failure. Both the absent RevertedFiles allow-list and the PR's two added production files independently require this result. Candidate 1 was completed once and was never reopened, rerun, edited, or otherwise disturbed by Candidate 2.


Candidate 2 — Blocked

Artifacts: CustomAgentLogsTmp/PRState/37750/PRAgent/try-fix/attempt-2/
Full narrative: CustomAgentLogsTmp/PRState/37750/PRAgent/try-fix-2/content.md

Approach designed (not implemented)

This try-fix section was shortened to keep every required review section visible. Full details remain available in the pipeline build artifacts.


🏁 Report — Final Recommendation

⚠️ Final Recommendation: REQUEST CHANGES

Winner: pr-plus-reviewer. It is the only candidate that removes the submitted PR's confirmed build break and then passes the complete bounded validation contract. The submitted pr must incorporate pr-plus-reviewer/reviewer.patch; the trusted Gate remains failed, so the raw PR cannot be approved.

Candidate ranking

Rank Candidate Implementation Focused unit result Required iOS regression result Assessment
1 pr-plus-reviewer Raw PR plus a 5-file reviewer patch PASS — 78/78 PASS — all 13 invocations (34 test executions) Winner. Fixes RS0025 and uses the active window's display scale without disturbing the submitted runtime design.
2 pr Submitted 58-file safe-area contract/runtime change PASS — 78/78 SafeAreaTests; 15/15 SafeAreaEdgesTests in Gate FAILED/BLOCKED — sampled with-fix HostApp runs stopped at RS0025 duplicate API entries Strong feature implementation, but it does not build through the required regression path as submitted. Per the ranking rule, it is below the passing candidate.
3 try-fix-1 Proposed UIKit-owned AdditionalSafeAreaInsets subtraction and additive attached API NOT RUN NOT RUN Blocked before editing by the baseline harness; empty diff. Conceptually narrower than candidate 2 but entirely unvalidated.
4 try-fix-2 Proposed ephemeral top-down geometric safe-area budget NOT RUN NOT RUN Blocked before editing by the same harness boundary; empty diff. It is the largest architectural departure and has no implementation evidence.

The two STEP 5a alternatives are not failed designs; they are blocked, non-materialized proposals. Neither can outrank a candidate with a reviewable diff and passing regressions. They also cannot supply a non-empty winning diff.

Why pr-plus-reviewer wins

The expert review identified a certain, mechanically verified defect: the raw PR re-adds StatusBarTheme API entries already present in both Core baselines. That produces RS0025 and is exactly why the raw PR's with-fix Issue28986_ParentChildTest and Issue32586 Gate legs ended at build time. Removing those duplicates allowed every required HostApp regression to execute and pass.

The same patch resolves the concrete screen-scale inconsistency in the Apple safe-area comparison path. Ancestor inset classification already uses view.Window?.Screen.Scale; MauiView and MauiScrollView now use that same scale when deciding whether applied insets changed. This is a localized correctness fix for external displays and Mac Catalyst windows.

The candidate retained the PR's deliberate order-independent Issue32586 logic. Its expected value is the opposite of the observed known state, so a no-op toggle still fails; it is not a self-fulfilling assertion. Three independent candidate invocations passed all five Issue32586 tests.

Expert-review reconciliation

Expert feedback Disposition
Duplicate Core PublicAPI entries Confirmed and fixed. Zero duplicate lines remain in either affected baseline.
Main-screen versus window-screen pixel scale Confirmed and fixed. Callers now provide the current window scale.
Issue32586 dynamic expected footer state Not accepted as a defect. The assertion checks an opposite-state transition and avoids dependence on earlier ordered tests.

This report section was shortened to keep every required review section visible. Full details remain available in the pipeline build artifacts.


🔗 Regression Cross-Reference

🔍 Regression Cross-Reference

✗ Revert risks detected — this PR removes 3 line(s) previously added by labeled bug-fix PRs.

File Fix PR Fixed issue(s) Risk Reverted line
src/Core/src/Platform/iOS/MauiScrollView.cs #34024 #32586, #33934, #33595, #34042 ✗ REVERT bool? _parentHandlesSafeArea;
src/Core/src/Platform/iOS/MauiView.cs #34024 #32586, #33934, #33595, #34042 ✗ REVERT bool? _parentHandlesSafeArea;
src/Core/src/Platform/iOS/SafeAreaPadding.cs #34024 #32586, #33934, #33595, #34042 ✗ REVERT return RoundToPixel(Left, scale) == RoundToPixel(other.Left, scale)

Action required: Verify that issues #32586, #33595, #33934, #34042 do not re-regress before merging.

🧪 Regression Tests to Verify

These tests were added by the fix PRs being reverted. They must still pass:

Fix PR Type Test Filter
#34024 UITest Issue28986_ParentChildTest Issue28986_ParentChildTest
#34024 UITest Issue32586 Issue32586
#34024 UITest Issue33595 Issue33595
#34024 UITest Issue33934 Issue33934
#34024 UITest Issue28986_ParentChildTest Issue28986_ParentChildTest
#34024 UITest Issue32586 Issue32586
#34024 UITest Issue33595 Issue33595
#34024 UITest Issue33934 Issue33934
#34024 UITest Issue28986_ParentChildTest Issue28986_ParentChildTest
#34024 UITest Issue32586 Issue32586
#34024 UITest Issue33595 Issue33595
#34024 UITest Issue33934 Issue33934

🧪 Regression Test Results

❌ FAILED — 0 passed, 13 failed, 0 skipped

Fix PR Test Type Result
#35916 Issue35756 UITest ❌ FAILED
#34024 Issue28986_ParentChildTest UITest ❌ FAILED
#34024 Issue32586 UITest ❌ FAILED
#34024 Issue33595 UITest ❌ FAILED
#34024 Issue33934 UITest ❌ FAILED
#34024 Issue28986_ParentChildTest UITest ❌ FAILED
#34024 Issue32586 UITest ❌ FAILED
#34024 Issue33595 UITest ❌ FAILED
#34024 Issue33934 UITest ❌ FAILED
#34024 Issue28986_ParentChildTest UITest ❌ FAILED
#34024 Issue32586 UITest ❌ FAILED
#34024 Issue33595 UITest ❌ FAILED
#34024 Issue33934 UITest ❌ FAILED

📱 UI Tests — Border,Layout,Page,SafeAreaEdges,ScrollView,ViewBaseTests

Detected UI test categories: Border,Layout,Page,SafeAreaEdges,ScrollView,ViewBaseTests

⚠️ Deep UI tests — The build failed to compile for 6 categories (Border, Layout, Page, SafeAreaEdges, ScrollView, ViewBaseTests), so those deep UI tests could not run. The compiler reported: error RS0025: The symbol 'Microsoft.Maui.IWindow.StatusBarTheme.get -> Microsoft.Maui.StatusBarTheme' appears more than once in the public API files (https://github.com/dotnet/roslyn/blob/main/src/RoslynAnalyzers/PublicApiAnalyzers/PublicAp…. This is a compile error introduced by this PR — src/Core/src/PublicAPI/net/PublicAPI.Unshipped.txt is one of the files this PR changes. Fix the build error, then re-comment /review to run the deep tests.


🧭 Next Steps — reviewer changes required

The reviewer-enhanced candidate identified changes that are not yet in the submitted PR.

Why: pr-plus-reviewer fixes the raw PR's confirmed RS0025 duplicate-PublicAPI build break and aligns pixel comparisons with the active window scale. It then passes 78 focused unit tests and all 13 required iOS HostApp regression invocations, while both try-fix alternatives remain blocked with empty diffs.

Address the actionable findings in this review before merging.

@MauiBot MauiBot added the s/agent-gate-failed AI could not verify tests catch the bug label Aug 29, 2026

@kubaflo kubaflo left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code review findings from the MAUI expert review.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

area-safearea Issues/PRs that have to do with the SafeArea functionality p/0 Current heighest priority issues that we are targeting for a release. platform/ios s/agent-changes-requested AI agent recommends changes - found a better alternative or issues s/agent-fix-win AI found a better alternative fix than the PR s/agent-gate-failed AI could not verify tests catch the bug s/agent-reviewed PR was reviewed by AI agent workflow (full 4-phase review)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants