Skip to content

[Android] Fix incorrect top padding for translated views - #38295

Merged
kubaflo merged 1 commit into
mainfrom
kubaflo-forward-port-android-padding
Sep 7, 2026
Merged

kubaflo merged 1 commit into
mainfrom
kubaflo-forward-port-android-padding

Conversation

@kubaflo

@kubaflo kubaflo commented Sep 7, 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!

Description

Forward-ports the focused Android fix from #37772 to the current main branch.

The vertical safe-area animation heuristic now treats a translated view as a full-screen Shell navigation transition only when the view covers the usable screen height. Smaller translated controls, such as bottom sheets, no longer retain an incorrect top safe-area inset.

Adds the Issue37418 HostApp scenario and UI regression test. This intentionally excludes the unrelated .github/skills/release-readiness/SKILL.md change present in source merge commit 9d587ce9a6ce0b776496e930b5948da629b62ef2.

Issues Fixed

Fixes #37418

Validation

  • dotnet build Microsoft.Maui.BuildTasks.slnf
  • pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -TestFilter "FullyQualifiedName~Issue37418"

Forward-port the focused fix and Issue37418 regression coverage from #37772 to main.

Co-authored-by: devanathan-vaithiyanathan <114395405+devanathan-vaithiyanathan@users.noreply.github.com>

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Copilot AI lite review requested due to automatic review settings September 7, 2026 17:47
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool September 7, 2026 17:47 — with GitHub Actions Inactive
@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.

@github-actions

github-actions Bot commented Sep 7, 2026

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 -- 38295

Or

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

@kubaflo
kubaflo temporarily deployed to copilot-pat-pool September 7, 2026 17:48 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool September 7, 2026 17:50 — with GitHub Actions Inactive
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool September 7, 2026 17:51 — with GitHub Actions Inactive
@github-actions github-actions Bot added area-safearea Issues/PRs that have to do with the SafeArea functionality platform/android labels Sep 7, 2026
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool September 7, 2026 17:52 — 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.

🟡 Changes recommended

The new HostApp animation uses an async void OnSizeAllocated that can re-run animations on subsequent layout passes, and the new UITest measures positions without waiting for navigation/animation to settle, increasing flakiness risk.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

This PR updates Android safe-area inset handling to avoid treating translated, non–full-screen controls (e.g., bottom sheets) as full-screen Shell navigation transitions, preventing an incorrect top inset from being applied. It also adds a HostApp repro page and a UI regression test for #37418.

Changes:

  • Android: refine the “vertical animation” heuristic in SafeAreaExtensions to require the view’s height to cover the usable screen before applying the full top inset during animation.
  • Tests: add Issue37418 HostApp scenario (bottom sheet translated in/out via TranslateToAsync).
  • Tests: add Issue37418 UI test validating no extra top padding is applied.
File summaries
File Description
src/Core/src/Platform/Android/SafeAreaExtensions.cs Tightens vertical animation detection to avoid false positives for smaller translated views.
src/Controls/tests/TestCases.HostApp/Issues/Issue37418.cs Adds a Shell-based HostApp repro using a translated bottom sheet modal.
src/Controls/tests/TestCases.Shared.Tests/Tests/Issues/Issue37418.cs Adds a UI regression test measuring top padding behavior for the translated bottom sheet.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 2
  • Review effort level: Lite

Comment on lines +164 to +176
protected override async void OnSizeAllocated(double width, double height)
{
base.OnSizeAllocated(width, height);

if (_border is null)
{
return;
}

_border.TranslationY = _border.Measure(double.PositiveInfinity, double.PositiveInfinity).Height;
_border.IsVisible = true;
await _border.TranslateToAsync(_border.X, 0, 300, Easing.CubicIn);
}
Comment on lines +20 to +24
App.WaitForElement("OpenBottomSheetButton");
App.Tap("OpenBottomSheetButton");

var borderRect = App.WaitForElement("BottomSheetBorder").GetRect();
var closeButtonRect = App.WaitForElement("CloseBottomSheetButton").GetRect();
@kubaflo

kubaflo commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

@dalexsoto stamp

@kubaflo

kubaflo commented Sep 7, 2026

Copy link
Copy Markdown
Contributor Author

This is a back port from sr10.1

@kubaflo
kubaflo merged commit fa340de into main Sep 7, 2026
12 of 22 checks passed
@kubaflo
kubaflo deleted the kubaflo-forward-port-android-padding branch September 7, 2026 18:02
@github-actions github-actions Bot added this to the .NET 10 SR11 milestone Sep 7, 2026
kubaflo added a commit that referenced this pull request Sep 19, 2026
…38665)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Fix the two Android API 36 / Pixel 3 XL SafeAreaEdges failures in [build
1602666](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602666&view=logs&j=217a4b68-6397-5ebe-0d4b-1177e8401828&t=3a87bec2-0591-537a-1f29-40eb70176265).

- Preserve the full top inset throughout a full-height page's navigation
transition, including `0 < viewTop <= topInset`. Check animation before
partial overlap, and preserve the translated-child height guard from
#38295.
- Replace catch-and-retry NUnit assertions in
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` with delayed
constraints. NUnit 4.0.1 records an assertion failure before throwing,
so catching it and succeeding on a later attempt still leaves the test
failed. The original CI device log actually shows the grid shrinking
from 2705 to 1613 pixels and returning to 2705 after dismissal.
- Preserve the 15-second polling window, 500-ms interval, keyboard
visibility checks, and one-pixel restoration tolerance. Check restored
height and Y together on the same rectangle.
- Add six Android native cases exercising the production inset helper:
full-height offsets 0, 1, 99, 100, and 101 with a 100-pixel top inset,
plus a translated short child. Assert padding and inset consumption.

No snapshots, screenshot tolerances, public APIs, dependencies, or CI
configuration are changed. `LayoutShouldBeCorrectOnFirstNavigation`
remains unchanged.

### Regression origins

| Failure | Introducing change | Evidence |
| --- | --- | --- |
| Persistent incorrect top inset during navigation | #33788, commit
`9c0887b8c343a1a98762acfccb64190355e175ee` | Removed the deferred inset
reapplication added in #33285 and introduced `viewTop > top`, leaving
the final `0 < viewTop <= top` transition range unprotected. |
| Transient keyboard measurements retained as NUnit failures | #31022,
commit `0371d318282cc6f0cbb96d36315e7fc2f70680ff` | Introduced
catch-and-retry `RetryAssert` while the Android UI project already
referenced NUnit 4.0.1. |
| The specific keyboard test exposing that defect | #35083 | Added
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` using that
helper. The later keyboard waits in #37741 did not isolate recorded
NUnit failures. |

These are source-history attributions, not a historical full-build
bisect. The keyboard failure is a test-harness defect, not proof that
the grid never resized.

### Validation

Tested commit: `8aa80ab8d9312be1aeddfbb200ff580e5c678598`.

Environment: dedicated Android API 36 / Pixel 3 XL ARM64 emulator,
1440x2960 at density 560, Release HostApp, existing NUnit 4.0.1 /
adapter 4.5.0. Actual TRX and xUnit XML results were inspected, not
inferred from process exit codes.

| Coverage | Result |
| --- | --- |
| `SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` | Passed in
**3 consecutive focused runs**, on the first attempt each time. |
| `LayoutShouldBeCorrectOnFirstNavigation` | Passed in **3 consecutive
focused runs**, on the first attempt each time, against the unchanged
snapshot and tolerance. |
| Six native inset boundary cases, without native fix | Three expected
failures: offsets 1, 99, and 100 produced padding 99, 1, and 0 instead
of 100. Settled-origin, offset-101, and translated-child controls
passed. |
| Same six native cases, with native fix | **6 passed, 0 failed**. |
| Complete `Issue28986_ContentPage` fixture, final with-fix A/B leg |
**5 passed, 0 failed**, first attempt. |
| Standalone NUnit 4.0.1 probe | All five expected outcomes confirmed:
caught assertions remain failed; delayed height and compound bounds
constraints recover; permanently incorrect height or bounds still fail.
|

The repository `verify-tests-fail.ps1` finished with **`VERIFICATION
PASSED`**, using frozen base `49b62062536b4a2b957d965f76035eb56806615c`
and restoring only the two fix files. The final native A/B evidence is
deterministic. The without-fix keyboard fixture was timing-dependent and
also encountered element-lookup failures; its logs contain the original
retained `2705` assertion. The standalone NUnit probe independently
isolates that bookkeeping defect. No claim is made that every
broad-fixture failure was caused by this PR's targeted bug.

Initial verification attempts were blocked by the pinned XHarness
runtime and its default instrumentation selection. They are not counted
as native proof. Final native execution used the manifest's explicit
`com.microsoft.maui.core.devicetests.TestInstrumentation` with a
session-local runtime. No repository tool versions or machine-wide SDKs
were changed.

Focused UI command, executed three times:

```powershell
pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -Configuration Release -DeviceUdid emulator-5554 -TestFilter 'FullyQualifiedName~Issue33038|FullyQualifiedName~SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle'
```

The worktree was clean after verification. PR CI is separate: [maui-pr
build
1602977](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602977)
is running; this is not a full-CI-green or full-suite-green claim. No
`maui-pr-uitests` build had been scheduled at the time of this update.

### Related work and constraints

The native correction follows the narrowly scoped approach proposed in
closed, unmerged #38641, without its unrelated MacCatalyst skip. Open
#37953 proposes a broader SafeArea redesign; this PR keeps a small
correction and fixes the separate NUnit bookkeeping defect.

Do not replace the navigation baseline, widen its tolerance, or remove
the translated-child guard to make the test pass. Do not use caught
NUnit assertions as a polling predicate. The generic Appium helper
remains unchanged here to avoid adding an NUnit dependency or broad
test-infrastructure changes.

### Issues Fixed

Fixes #37555
Fixes #37556
Refs #33038
Refs #38135

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Sep 21, 2026
…38665)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Fix the two Android API 36 / Pixel 3 XL SafeAreaEdges failures in [build
1602666](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602666&view=logs&j=217a4b68-6397-5ebe-0d4b-1177e8401828&t=3a87bec2-0591-537a-1f29-40eb70176265).

- Preserve the full top inset throughout a full-height page's navigation
transition, including `0 < viewTop <= topInset`. Check animation before
partial overlap, and preserve the translated-child height guard from
#38295.
- Replace catch-and-retry NUnit assertions in
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` with delayed
constraints. NUnit 4.0.1 records an assertion failure before throwing,
so catching it and succeeding on a later attempt still leaves the test
failed. The original CI device log actually shows the grid shrinking
from 2705 to 1613 pixels and returning to 2705 after dismissal.
- Preserve the 15-second polling window, 500-ms interval, keyboard
visibility checks, and one-pixel restoration tolerance. Check restored
height and Y together on the same rectangle.
- Add six Android native cases exercising the production inset helper:
full-height offsets 0, 1, 99, 100, and 101 with a 100-pixel top inset,
plus a translated short child. Assert padding and inset consumption.

No snapshots, screenshot tolerances, public APIs, dependencies, or CI
configuration are changed. `LayoutShouldBeCorrectOnFirstNavigation`
remains unchanged.

### Regression origins

| Failure | Introducing change | Evidence |
| --- | --- | --- |
| Persistent incorrect top inset during navigation | #33788, commit
`9c0887b8c343a1a98762acfccb64190355e175ee` | Removed the deferred inset
reapplication added in #33285 and introduced `viewTop > top`, leaving
the final `0 < viewTop <= top` transition range unprotected. |
| Transient keyboard measurements retained as NUnit failures | #31022,
commit `0371d318282cc6f0cbb96d36315e7fc2f70680ff` | Introduced
catch-and-retry `RetryAssert` while the Android UI project already
referenced NUnit 4.0.1. |
| The specific keyboard test exposing that defect | #35083 | Added
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` using that
helper. The later keyboard waits in #37741 did not isolate recorded
NUnit failures. |

These are source-history attributions, not a historical full-build
bisect. The keyboard failure is a test-harness defect, not proof that
the grid never resized.

### Validation

Tested commit: `8aa80ab8d9312be1aeddfbb200ff580e5c678598`.

Environment: dedicated Android API 36 / Pixel 3 XL ARM64 emulator,
1440x2960 at density 560, Release HostApp, existing NUnit 4.0.1 /
adapter 4.5.0. Actual TRX and xUnit XML results were inspected, not
inferred from process exit codes.

| Coverage | Result |
| --- | --- |
| `SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` | Passed in
**3 consecutive focused runs**, on the first attempt each time. |
| `LayoutShouldBeCorrectOnFirstNavigation` | Passed in **3 consecutive
focused runs**, on the first attempt each time, against the unchanged
snapshot and tolerance. |
| Six native inset boundary cases, without native fix | Three expected
failures: offsets 1, 99, and 100 produced padding 99, 1, and 0 instead
of 100. Settled-origin, offset-101, and translated-child controls
passed. |
| Same six native cases, with native fix | **6 passed, 0 failed**. |
| Complete `Issue28986_ContentPage` fixture, final with-fix A/B leg |
**5 passed, 0 failed**, first attempt. |
| Standalone NUnit 4.0.1 probe | All five expected outcomes confirmed:
caught assertions remain failed; delayed height and compound bounds
constraints recover; permanently incorrect height or bounds still fail.
|

The repository `verify-tests-fail.ps1` finished with **`VERIFICATION
PASSED`**, using frozen base `49b62062536b4a2b957d965f76035eb56806615c`
and restoring only the two fix files. The final native A/B evidence is
deterministic. The without-fix keyboard fixture was timing-dependent and
also encountered element-lookup failures; its logs contain the original
retained `2705` assertion. The standalone NUnit probe independently
isolates that bookkeeping defect. No claim is made that every
broad-fixture failure was caused by this PR's targeted bug.

Initial verification attempts were blocked by the pinned XHarness
runtime and its default instrumentation selection. They are not counted
as native proof. Final native execution used the manifest's explicit
`com.microsoft.maui.core.devicetests.TestInstrumentation` with a
session-local runtime. No repository tool versions or machine-wide SDKs
were changed.

Focused UI command, executed three times:

```powershell
pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -Configuration Release -DeviceUdid emulator-5554 -TestFilter 'FullyQualifiedName~Issue33038|FullyQualifiedName~SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle'
```

The worktree was clean after verification. PR CI is separate: [maui-pr
build
1602977](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602977)
is running; this is not a full-CI-green or full-suite-green claim. No
`maui-pr-uitests` build had been scheduled at the time of this update.

### Related work and constraints

The native correction follows the narrowly scoped approach proposed in
closed, unmerged #38641, without its unrelated MacCatalyst skip. Open
#37953 proposes a broader SafeArea redesign; this PR keeps a small
correction and fixes the separate NUnit bookkeeping defect.

Do not replace the navigation baseline, widen its tolerance, or remove
the translated-child guard to make the test pass. Do not use caught
NUnit assertions as a polling predicate. The generic Appium helper
remains unchanged here to avoid adding an NUnit dependency or broad
test-infrastructure changes.

### Issues Fixed

Fixes #37555
Fixes #37556
Refs #33038
Refs #38135

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Sep 27, 2026
…38665)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Fix the two Android API 36 / Pixel 3 XL SafeAreaEdges failures in [build
1602666](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602666&view=logs&j=217a4b68-6397-5ebe-0d4b-1177e8401828&t=3a87bec2-0591-537a-1f29-40eb70176265).

- Preserve the full top inset throughout a full-height page's navigation
transition, including `0 < viewTop <= topInset`. Check animation before
partial overlap, and preserve the translated-child height guard from
#38295.
- Replace catch-and-retry NUnit assertions in
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` with delayed
constraints. NUnit 4.0.1 records an assertion failure before throwing,
so catching it and succeeding on a later attempt still leaves the test
failed. The original CI device log actually shows the grid shrinking
from 2705 to 1613 pixels and returning to 2705 after dismissal.
- Preserve the 15-second polling window, 500-ms interval, keyboard
visibility checks, and one-pixel restoration tolerance. Check restored
height and Y together on the same rectangle.
- Add six Android native cases exercising the production inset helper:
full-height offsets 0, 1, 99, 100, and 101 with a 100-pixel top inset,
plus a translated short child. Assert padding and inset consumption.

No snapshots, screenshot tolerances, public APIs, dependencies, or CI
configuration are changed. `LayoutShouldBeCorrectOnFirstNavigation`
remains unchanged.

### Regression origins

| Failure | Introducing change | Evidence |
| --- | --- | --- |
| Persistent incorrect top inset during navigation | #33788, commit
`9c0887b8c343a1a98762acfccb64190355e175ee` | Removed the deferred inset
reapplication added in #33285 and introduced `viewTop > top`, leaving
the final `0 < viewTop <= top` transition range unprotected. |
| Transient keyboard measurements retained as NUnit failures | #31022,
commit `0371d318282cc6f0cbb96d36315e7fc2f70680ff` | Introduced
catch-and-retry `RetryAssert` while the Android UI project already
referenced NUnit 4.0.1. |
| The specific keyboard test exposing that defect | #35083 | Added
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` using that
helper. The later keyboard waits in #37741 did not isolate recorded
NUnit failures. |

These are source-history attributions, not a historical full-build
bisect. The keyboard failure is a test-harness defect, not proof that
the grid never resized.

### Validation

Tested commit: `8aa80ab8d9312be1aeddfbb200ff580e5c678598`.

Environment: dedicated Android API 36 / Pixel 3 XL ARM64 emulator,
1440x2960 at density 560, Release HostApp, existing NUnit 4.0.1 /
adapter 4.5.0. Actual TRX and xUnit XML results were inspected, not
inferred from process exit codes.

| Coverage | Result |
| --- | --- |
| `SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` | Passed in
**3 consecutive focused runs**, on the first attempt each time. |
| `LayoutShouldBeCorrectOnFirstNavigation` | Passed in **3 consecutive
focused runs**, on the first attempt each time, against the unchanged
snapshot and tolerance. |
| Six native inset boundary cases, without native fix | Three expected
failures: offsets 1, 99, and 100 produced padding 99, 1, and 0 instead
of 100. Settled-origin, offset-101, and translated-child controls
passed. |
| Same six native cases, with native fix | **6 passed, 0 failed**. |
| Complete `Issue28986_ContentPage` fixture, final with-fix A/B leg |
**5 passed, 0 failed**, first attempt. |
| Standalone NUnit 4.0.1 probe | All five expected outcomes confirmed:
caught assertions remain failed; delayed height and compound bounds
constraints recover; permanently incorrect height or bounds still fail.
|

The repository `verify-tests-fail.ps1` finished with **`VERIFICATION
PASSED`**, using frozen base `49b62062536b4a2b957d965f76035eb56806615c`
and restoring only the two fix files. The final native A/B evidence is
deterministic. The without-fix keyboard fixture was timing-dependent and
also encountered element-lookup failures; its logs contain the original
retained `2705` assertion. The standalone NUnit probe independently
isolates that bookkeeping defect. No claim is made that every
broad-fixture failure was caused by this PR's targeted bug.

Initial verification attempts were blocked by the pinned XHarness
runtime and its default instrumentation selection. They are not counted
as native proof. Final native execution used the manifest's explicit
`com.microsoft.maui.core.devicetests.TestInstrumentation` with a
session-local runtime. No repository tool versions or machine-wide SDKs
were changed.

Focused UI command, executed three times:

```powershell
pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -Configuration Release -DeviceUdid emulator-5554 -TestFilter 'FullyQualifiedName~Issue33038|FullyQualifiedName~SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle'
```

The worktree was clean after verification. PR CI is separate: [maui-pr
build
1602977](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602977)
is running; this is not a full-CI-green or full-suite-green claim. No
`maui-pr-uitests` build had been scheduled at the time of this update.

### Related work and constraints

The native correction follows the narrowly scoped approach proposed in
closed, unmerged #38641, without its unrelated MacCatalyst skip. Open
#37953 proposes a broader SafeArea redesign; this PR keeps a small
correction and fixes the separate NUnit bookkeeping defect.

Do not replace the navigation baseline, widen its tolerance, or remove
the translated-child guard to make the test pass. Do not use caught
NUnit assertions as a polling predicate. The generic Appium helper
remains unchanged here to avoid adding an NUnit dependency or broad
test-infrastructure changes.

### Issues Fixed

Fixes #37555
Fixes #37556
Refs #33038
Refs #38135

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Sep 27, 2026
…38665)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Fix the two Android API 36 / Pixel 3 XL SafeAreaEdges failures in [build
1602666](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602666&view=logs&j=217a4b68-6397-5ebe-0d4b-1177e8401828&t=3a87bec2-0591-537a-1f29-40eb70176265).

- Preserve the full top inset throughout a full-height page's navigation
transition, including `0 < viewTop <= topInset`. Check animation before
partial overlap, and preserve the translated-child height guard from
#38295.
- Replace catch-and-retry NUnit assertions in
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` with delayed
constraints. NUnit 4.0.1 records an assertion failure before throwing,
so catching it and succeeding on a later attempt still leaves the test
failed. The original CI device log actually shows the grid shrinking
from 2705 to 1613 pixels and returning to 2705 after dismissal.
- Preserve the 15-second polling window, 500-ms interval, keyboard
visibility checks, and one-pixel restoration tolerance. Check restored
height and Y together on the same rectangle.
- Add six Android native cases exercising the production inset helper:
full-height offsets 0, 1, 99, 100, and 101 with a 100-pixel top inset,
plus a translated short child. Assert padding and inset consumption.

No snapshots, screenshot tolerances, public APIs, dependencies, or CI
configuration are changed. `LayoutShouldBeCorrectOnFirstNavigation`
remains unchanged.

### Regression origins

| Failure | Introducing change | Evidence |
| --- | --- | --- |
| Persistent incorrect top inset during navigation | #33788, commit
`9c0887b8c343a1a98762acfccb64190355e175ee` | Removed the deferred inset
reapplication added in #33285 and introduced `viewTop > top`, leaving
the final `0 < viewTop <= top` transition range unprotected. |
| Transient keyboard measurements retained as NUnit failures | #31022,
commit `0371d318282cc6f0cbb96d36315e7fc2f70680ff` | Introduced
catch-and-retry `RetryAssert` while the Android UI project already
referenced NUnit 4.0.1. |
| The specific keyboard test exposing that defect | #35083 | Added
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` using that
helper. The later keyboard waits in #37741 did not isolate recorded
NUnit failures. |

These are source-history attributions, not a historical full-build
bisect. The keyboard failure is a test-harness defect, not proof that
the grid never resized.

### Validation

Tested commit: `8aa80ab8d9312be1aeddfbb200ff580e5c678598`.

Environment: dedicated Android API 36 / Pixel 3 XL ARM64 emulator,
1440x2960 at density 560, Release HostApp, existing NUnit 4.0.1 /
adapter 4.5.0. Actual TRX and xUnit XML results were inspected, not
inferred from process exit codes.

| Coverage | Result |
| --- | --- |
| `SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` | Passed in
**3 consecutive focused runs**, on the first attempt each time. |
| `LayoutShouldBeCorrectOnFirstNavigation` | Passed in **3 consecutive
focused runs**, on the first attempt each time, against the unchanged
snapshot and tolerance. |
| Six native inset boundary cases, without native fix | Three expected
failures: offsets 1, 99, and 100 produced padding 99, 1, and 0 instead
of 100. Settled-origin, offset-101, and translated-child controls
passed. |
| Same six native cases, with native fix | **6 passed, 0 failed**. |
| Complete `Issue28986_ContentPage` fixture, final with-fix A/B leg |
**5 passed, 0 failed**, first attempt. |
| Standalone NUnit 4.0.1 probe | All five expected outcomes confirmed:
caught assertions remain failed; delayed height and compound bounds
constraints recover; permanently incorrect height or bounds still fail.
|

The repository `verify-tests-fail.ps1` finished with **`VERIFICATION
PASSED`**, using frozen base `49b62062536b4a2b957d965f76035eb56806615c`
and restoring only the two fix files. The final native A/B evidence is
deterministic. The without-fix keyboard fixture was timing-dependent and
also encountered element-lookup failures; its logs contain the original
retained `2705` assertion. The standalone NUnit probe independently
isolates that bookkeeping defect. No claim is made that every
broad-fixture failure was caused by this PR's targeted bug.

Initial verification attempts were blocked by the pinned XHarness
runtime and its default instrumentation selection. They are not counted
as native proof. Final native execution used the manifest's explicit
`com.microsoft.maui.core.devicetests.TestInstrumentation` with a
session-local runtime. No repository tool versions or machine-wide SDKs
were changed.

Focused UI command, executed three times:

```powershell
pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -Configuration Release -DeviceUdid emulator-5554 -TestFilter 'FullyQualifiedName~Issue33038|FullyQualifiedName~SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle'
```

The worktree was clean after verification. PR CI is separate: [maui-pr
build
1602977](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602977)
is running; this is not a full-CI-green or full-suite-green claim. No
`maui-pr-uitests` build had been scheduled at the time of this update.

### Related work and constraints

The native correction follows the narrowly scoped approach proposed in
closed, unmerged #38641, without its unrelated MacCatalyst skip. Open
#37953 proposes a broader SafeArea redesign; this PR keeps a small
correction and fixes the separate NUnit bookkeeping defect.

Do not replace the navigation baseline, widen its tolerance, or remove
the translated-child guard to make the test pass. Do not use caught
NUnit assertions as a polling predicate. The generic Appium helper
remains unchanged here to avoid adding an NUnit dependency or broad
test-infrastructure changes.

### Issues Fixed

Fixes #37555
Fixes #37556
Refs #33038
Refs #38135

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Oct 3, 2026
…38665)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Fix the two Android API 36 / Pixel 3 XL SafeAreaEdges failures in [build
1602666](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602666&view=logs&j=217a4b68-6397-5ebe-0d4b-1177e8401828&t=3a87bec2-0591-537a-1f29-40eb70176265).

- Preserve the full top inset throughout a full-height page's navigation
transition, including `0 < viewTop <= topInset`. Check animation before
partial overlap, and preserve the translated-child height guard from
#38295.
- Replace catch-and-retry NUnit assertions in
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` with delayed
constraints. NUnit 4.0.1 records an assertion failure before throwing,
so catching it and succeeding on a later attempt still leaves the test
failed. The original CI device log actually shows the grid shrinking
from 2705 to 1613 pixels and returning to 2705 after dismissal.
- Preserve the 15-second polling window, 500-ms interval, keyboard
visibility checks, and one-pixel restoration tolerance. Check restored
height and Y together on the same rectangle.
- Add six Android native cases exercising the production inset helper:
full-height offsets 0, 1, 99, 100, and 101 with a 100-pixel top inset,
plus a translated short child. Assert padding and inset consumption.

No snapshots, screenshot tolerances, public APIs, dependencies, or CI
configuration are changed. `LayoutShouldBeCorrectOnFirstNavigation`
remains unchanged.

### Regression origins

| Failure | Introducing change | Evidence |
| --- | --- | --- |
| Persistent incorrect top inset during navigation | #33788, commit
`9c0887b8c343a1a98762acfccb64190355e175ee` | Removed the deferred inset
reapplication added in #33285 and introduced `viewTop > top`, leaving
the final `0 < viewTop <= top` transition range unprotected. |
| Transient keyboard measurements retained as NUnit failures | #31022,
commit `0371d318282cc6f0cbb96d36315e7fc2f70680ff` | Introduced
catch-and-retry `RetryAssert` while the Android UI project already
referenced NUnit 4.0.1. |
| The specific keyboard test exposing that defect | #35083 | Added
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` using that
helper. The later keyboard waits in #37741 did not isolate recorded
NUnit failures. |

These are source-history attributions, not a historical full-build
bisect. The keyboard failure is a test-harness defect, not proof that
the grid never resized.

### Validation

Tested commit: `8aa80ab8d9312be1aeddfbb200ff580e5c678598`.

Environment: dedicated Android API 36 / Pixel 3 XL ARM64 emulator,
1440x2960 at density 560, Release HostApp, existing NUnit 4.0.1 /
adapter 4.5.0. Actual TRX and xUnit XML results were inspected, not
inferred from process exit codes.

| Coverage | Result |
| --- | --- |
| `SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` | Passed in
**3 consecutive focused runs**, on the first attempt each time. |
| `LayoutShouldBeCorrectOnFirstNavigation` | Passed in **3 consecutive
focused runs**, on the first attempt each time, against the unchanged
snapshot and tolerance. |
| Six native inset boundary cases, without native fix | Three expected
failures: offsets 1, 99, and 100 produced padding 99, 1, and 0 instead
of 100. Settled-origin, offset-101, and translated-child controls
passed. |
| Same six native cases, with native fix | **6 passed, 0 failed**. |
| Complete `Issue28986_ContentPage` fixture, final with-fix A/B leg |
**5 passed, 0 failed**, first attempt. |
| Standalone NUnit 4.0.1 probe | All five expected outcomes confirmed:
caught assertions remain failed; delayed height and compound bounds
constraints recover; permanently incorrect height or bounds still fail.
|

The repository `verify-tests-fail.ps1` finished with **`VERIFICATION
PASSED`**, using frozen base `49b62062536b4a2b957d965f76035eb56806615c`
and restoring only the two fix files. The final native A/B evidence is
deterministic. The without-fix keyboard fixture was timing-dependent and
also encountered element-lookup failures; its logs contain the original
retained `2705` assertion. The standalone NUnit probe independently
isolates that bookkeeping defect. No claim is made that every
broad-fixture failure was caused by this PR's targeted bug.

Initial verification attempts were blocked by the pinned XHarness
runtime and its default instrumentation selection. They are not counted
as native proof. Final native execution used the manifest's explicit
`com.microsoft.maui.core.devicetests.TestInstrumentation` with a
session-local runtime. No repository tool versions or machine-wide SDKs
were changed.

Focused UI command, executed three times:

```powershell
pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -Configuration Release -DeviceUdid emulator-5554 -TestFilter 'FullyQualifiedName~Issue33038|FullyQualifiedName~SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle'
```

The worktree was clean after verification. PR CI is separate: [maui-pr
build
1602977](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602977)
is running; this is not a full-CI-green or full-suite-green claim. No
`maui-pr-uitests` build had been scheduled at the time of this update.

### Related work and constraints

The native correction follows the narrowly scoped approach proposed in
closed, unmerged #38641, without its unrelated MacCatalyst skip. Open
#37953 proposes a broader SafeArea redesign; this PR keeps a small
correction and fixes the separate NUnit bookkeeping defect.

Do not replace the navigation baseline, widen its tolerance, or remove
the translated-child guard to make the test pass. Do not use caught
NUnit assertions as a polling predicate. The generic Appium helper
remains unchanged here to avoid adding an NUnit dependency or broad
test-infrastructure changes.

### Issues Fixed

Fixes #37555
Fixes #37556
Refs #33038
Refs #38135

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Oct 3, 2026
…38665)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Fix the two Android API 36 / Pixel 3 XL SafeAreaEdges failures in [build
1602666](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602666&view=logs&j=217a4b68-6397-5ebe-0d4b-1177e8401828&t=3a87bec2-0591-537a-1f29-40eb70176265).

- Preserve the full top inset throughout a full-height page's navigation
transition, including `0 < viewTop <= topInset`. Check animation before
partial overlap, and preserve the translated-child height guard from
#38295.
- Replace catch-and-retry NUnit assertions in
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` with delayed
constraints. NUnit 4.0.1 records an assertion failure before throwing,
so catching it and succeeding on a later attempt still leaves the test
failed. The original CI device log actually shows the grid shrinking
from 2705 to 1613 pixels and returning to 2705 after dismissal.
- Preserve the 15-second polling window, 500-ms interval, keyboard
visibility checks, and one-pixel restoration tolerance. Check restored
height and Y together on the same rectangle.
- Add six Android native cases exercising the production inset helper:
full-height offsets 0, 1, 99, 100, and 101 with a 100-pixel top inset,
plus a translated short child. Assert padding and inset consumption.

No snapshots, screenshot tolerances, public APIs, dependencies, or CI
configuration are changed. `LayoutShouldBeCorrectOnFirstNavigation`
remains unchanged.

### Regression origins

| Failure | Introducing change | Evidence |
| --- | --- | --- |
| Persistent incorrect top inset during navigation | #33788, commit
`9c0887b8c343a1a98762acfccb64190355e175ee` | Removed the deferred inset
reapplication added in #33285 and introduced `viewTop > top`, leaving
the final `0 < viewTop <= top` transition range unprotected. |
| Transient keyboard measurements retained as NUnit failures | #31022,
commit `0371d318282cc6f0cbb96d36315e7fc2f70680ff` | Introduced
catch-and-retry `RetryAssert` while the Android UI project already
referenced NUnit 4.0.1. |
| The specific keyboard test exposing that defect | #35083 | Added
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` using that
helper. The later keyboard waits in #37741 did not isolate recorded
NUnit failures. |

These are source-history attributions, not a historical full-build
bisect. The keyboard failure is a test-harness defect, not proof that
the grid never resized.

### Validation

Tested commit: `8aa80ab8d9312be1aeddfbb200ff580e5c678598`.

Environment: dedicated Android API 36 / Pixel 3 XL ARM64 emulator,
1440x2960 at density 560, Release HostApp, existing NUnit 4.0.1 /
adapter 4.5.0. Actual TRX and xUnit XML results were inspected, not
inferred from process exit codes.

| Coverage | Result |
| --- | --- |
| `SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` | Passed in
**3 consecutive focused runs**, on the first attempt each time. |
| `LayoutShouldBeCorrectOnFirstNavigation` | Passed in **3 consecutive
focused runs**, on the first attempt each time, against the unchanged
snapshot and tolerance. |
| Six native inset boundary cases, without native fix | Three expected
failures: offsets 1, 99, and 100 produced padding 99, 1, and 0 instead
of 100. Settled-origin, offset-101, and translated-child controls
passed. |
| Same six native cases, with native fix | **6 passed, 0 failed**. |
| Complete `Issue28986_ContentPage` fixture, final with-fix A/B leg |
**5 passed, 0 failed**, first attempt. |
| Standalone NUnit 4.0.1 probe | All five expected outcomes confirmed:
caught assertions remain failed; delayed height and compound bounds
constraints recover; permanently incorrect height or bounds still fail.
|

The repository `verify-tests-fail.ps1` finished with **`VERIFICATION
PASSED`**, using frozen base `49b62062536b4a2b957d965f76035eb56806615c`
and restoring only the two fix files. The final native A/B evidence is
deterministic. The without-fix keyboard fixture was timing-dependent and
also encountered element-lookup failures; its logs contain the original
retained `2705` assertion. The standalone NUnit probe independently
isolates that bookkeeping defect. No claim is made that every
broad-fixture failure was caused by this PR's targeted bug.

Initial verification attempts were blocked by the pinned XHarness
runtime and its default instrumentation selection. They are not counted
as native proof. Final native execution used the manifest's explicit
`com.microsoft.maui.core.devicetests.TestInstrumentation` with a
session-local runtime. No repository tool versions or machine-wide SDKs
were changed.

Focused UI command, executed three times:

```powershell
pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -Configuration Release -DeviceUdid emulator-5554 -TestFilter 'FullyQualifiedName~Issue33038|FullyQualifiedName~SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle'
```

The worktree was clean after verification. PR CI is separate: [maui-pr
build
1602977](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602977)
is running; this is not a full-CI-green or full-suite-green claim. No
`maui-pr-uitests` build had been scheduled at the time of this update.

### Related work and constraints

The native correction follows the narrowly scoped approach proposed in
closed, unmerged #38641, without its unrelated MacCatalyst skip. Open
#37953 proposes a broader SafeArea redesign; this PR keeps a small
correction and fixes the separate NUnit bookkeeping defect.

Do not replace the navigation baseline, widen its tolerance, or remove
the translated-child guard to make the test pass. Do not use caught
NUnit assertions as a polling predicate. The generic Appium helper
remains unchanged here to avoid adding an NUnit dependency or broad
test-infrastructure changes.

### Issues Fixed

Fixes #37555
Fixes #37556
Refs #33038
Refs #38135

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Oct 6, 2026
…38665)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Fix the two Android API 36 / Pixel 3 XL SafeAreaEdges failures in [build
1602666](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602666&view=logs&j=217a4b68-6397-5ebe-0d4b-1177e8401828&t=3a87bec2-0591-537a-1f29-40eb70176265).

- Preserve the full top inset throughout a full-height page's navigation
transition, including `0 < viewTop <= topInset`. Check animation before
partial overlap, and preserve the translated-child height guard from
#38295.
- Replace catch-and-retry NUnit assertions in
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` with delayed
constraints. NUnit 4.0.1 records an assertion failure before throwing,
so catching it and succeeding on a later attempt still leaves the test
failed. The original CI device log actually shows the grid shrinking
from 2705 to 1613 pixels and returning to 2705 after dismissal.
- Preserve the 15-second polling window, 500-ms interval, keyboard
visibility checks, and one-pixel restoration tolerance. Check restored
height and Y together on the same rectangle.
- Add six Android native cases exercising the production inset helper:
full-height offsets 0, 1, 99, 100, and 101 with a 100-pixel top inset,
plus a translated short child. Assert padding and inset consumption.

No snapshots, screenshot tolerances, public APIs, dependencies, or CI
configuration are changed. `LayoutShouldBeCorrectOnFirstNavigation`
remains unchanged.

### Regression origins

| Failure | Introducing change | Evidence |
| --- | --- | --- |
| Persistent incorrect top inset during navigation | #33788, commit
`9c0887b8c343a1a98762acfccb64190355e175ee` | Removed the deferred inset
reapplication added in #33285 and introduced `viewTop > top`, leaving
the final `0 < viewTop <= top` transition range unprotected. |
| Transient keyboard measurements retained as NUnit failures | #31022,
commit `0371d318282cc6f0cbb96d36315e7fc2f70680ff` | Introduced
catch-and-retry `RetryAssert` while the Android UI project already
referenced NUnit 4.0.1. |
| The specific keyboard test exposing that defect | #35083 | Added
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` using that
helper. The later keyboard waits in #37741 did not isolate recorded
NUnit failures. |

These are source-history attributions, not a historical full-build
bisect. The keyboard failure is a test-harness defect, not proof that
the grid never resized.

### Validation

Tested commit: `8aa80ab8d9312be1aeddfbb200ff580e5c678598`.

Environment: dedicated Android API 36 / Pixel 3 XL ARM64 emulator,
1440x2960 at density 560, Release HostApp, existing NUnit 4.0.1 /
adapter 4.5.0. Actual TRX and xUnit XML results were inspected, not
inferred from process exit codes.

| Coverage | Result |
| --- | --- |
| `SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` | Passed in
**3 consecutive focused runs**, on the first attempt each time. |
| `LayoutShouldBeCorrectOnFirstNavigation` | Passed in **3 consecutive
focused runs**, on the first attempt each time, against the unchanged
snapshot and tolerance. |
| Six native inset boundary cases, without native fix | Three expected
failures: offsets 1, 99, and 100 produced padding 99, 1, and 0 instead
of 100. Settled-origin, offset-101, and translated-child controls
passed. |
| Same six native cases, with native fix | **6 passed, 0 failed**. |
| Complete `Issue28986_ContentPage` fixture, final with-fix A/B leg |
**5 passed, 0 failed**, first attempt. |
| Standalone NUnit 4.0.1 probe | All five expected outcomes confirmed:
caught assertions remain failed; delayed height and compound bounds
constraints recover; permanently incorrect height or bounds still fail.
|

The repository `verify-tests-fail.ps1` finished with **`VERIFICATION
PASSED`**, using frozen base `49b62062536b4a2b957d965f76035eb56806615c`
and restoring only the two fix files. The final native A/B evidence is
deterministic. The without-fix keyboard fixture was timing-dependent and
also encountered element-lookup failures; its logs contain the original
retained `2705` assertion. The standalone NUnit probe independently
isolates that bookkeeping defect. No claim is made that every
broad-fixture failure was caused by this PR's targeted bug.

Initial verification attempts were blocked by the pinned XHarness
runtime and its default instrumentation selection. They are not counted
as native proof. Final native execution used the manifest's explicit
`com.microsoft.maui.core.devicetests.TestInstrumentation` with a
session-local runtime. No repository tool versions or machine-wide SDKs
were changed.

Focused UI command, executed three times:

```powershell
pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -Configuration Release -DeviceUdid emulator-5554 -TestFilter 'FullyQualifiedName~Issue33038|FullyQualifiedName~SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle'
```

The worktree was clean after verification. PR CI is separate: [maui-pr
build
1602977](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602977)
is running; this is not a full-CI-green or full-suite-green claim. No
`maui-pr-uitests` build had been scheduled at the time of this update.

### Related work and constraints

The native correction follows the narrowly scoped approach proposed in
closed, unmerged #38641, without its unrelated MacCatalyst skip. Open
#37953 proposes a broader SafeArea redesign; this PR keeps a small
correction and fixes the separate NUnit bookkeeping defect.

Do not replace the navigation baseline, widen its tolerance, or remove
the translated-child guard to make the test pass. Do not use caught
NUnit assertions as a polling predicate. The generic Appium helper
remains unchanged here to avoid adding an NUnit dependency or broad
test-infrastructure changes.

### Issues Fixed

Fixes #37555
Fixes #37556
Refs #33038
Refs #38135

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Oct 6, 2026
…38665)

<!-- Please let the below note in for people that find this PR -->
> [!NOTE]
> Are you waiting for the changes in this PR to be merged?
> It would be very helpful if you could [test the resulting
artifacts](https://github.com/dotnet/maui/wiki/Testing-PR-Builds) from
this PR and let us know in a comment if this change resolves your issue.
Thank you!

### Description of Change

Fix the two Android API 36 / Pixel 3 XL SafeAreaEdges failures in [build
1602666](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602666&view=logs&j=217a4b68-6397-5ebe-0d4b-1177e8401828&t=3a87bec2-0591-537a-1f29-40eb70176265).

- Preserve the full top inset throughout a full-height page's navigation
transition, including `0 < viewTop <= topInset`. Check animation before
partial overlap, and preserve the translated-child height guard from
#38295.
- Replace catch-and-retry NUnit assertions in
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` with delayed
constraints. NUnit 4.0.1 records an assertion failure before throwing,
so catching it and succeeding on a later attempt still leaves the test
failed. The original CI device log actually shows the grid shrinking
from 2705 to 1613 pixels and returning to 2705 after dismissal.
- Preserve the 15-second polling window, 500-ms interval, keyboard
visibility checks, and one-pixel restoration tolerance. Check restored
height and Y together on the same rectangle.
- Add six Android native cases exercising the production inset helper:
full-height offsets 0, 1, 99, 100, and 101 with a 100-pixel top inset,
plus a translated short child. Assert padding and inset consumption.

No snapshots, screenshot tolerances, public APIs, dependencies, or CI
configuration are changed. `LayoutShouldBeCorrectOnFirstNavigation`
remains unchanged.

### Regression origins

| Failure | Introducing change | Evidence |
| --- | --- | --- |
| Persistent incorrect top inset during navigation | #33788, commit
`9c0887b8c343a1a98762acfccb64190355e175ee` | Removed the deferred inset
reapplication added in #33285 and introduced `viewTop > top`, leaving
the final `0 < viewTop <= top` transition range unprotected. |
| Transient keyboard measurements retained as NUnit failures | #31022,
commit `0371d318282cc6f0cbb96d36315e7fc2f70680ff` | Introduced
catch-and-retry `RetryAssert` while the Android UI project already
referenced NUnit 4.0.1. |
| The specific keyboard test exposing that defect | #35083 | Added
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` using that
helper. The later keyboard waits in #37741 did not isolate recorded
NUnit failures. |

These are source-history attributions, not a historical full-build
bisect. The keyboard failure is a test-harness defect, not proof that
the grid never resized.

### Validation

Tested commit: `8aa80ab8d9312be1aeddfbb200ff580e5c678598`.

Environment: dedicated Android API 36 / Pixel 3 XL ARM64 emulator,
1440x2960 at density 560, Release HostApp, existing NUnit 4.0.1 /
adapter 4.5.0. Actual TRX and xUnit XML results were inspected, not
inferred from process exit codes.

| Coverage | Result |
| --- | --- |
| `SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle` | Passed in
**3 consecutive focused runs**, on the first attempt each time. |
| `LayoutShouldBeCorrectOnFirstNavigation` | Passed in **3 consecutive
focused runs**, on the first attempt each time, against the unchanged
snapshot and tolerance. |
| Six native inset boundary cases, without native fix | Three expected
failures: offsets 1, 99, and 100 produced padding 99, 1, and 0 instead
of 100. Settled-origin, offset-101, and translated-child controls
passed. |
| Same six native cases, with native fix | **6 passed, 0 failed**. |
| Complete `Issue28986_ContentPage` fixture, final with-fix A/B leg |
**5 passed, 0 failed**, first attempt. |
| Standalone NUnit 4.0.1 probe | All five expected outcomes confirmed:
caught assertions remain failed; delayed height and compound bounds
constraints recover; permanently incorrect height or bounds still fail.
|

The repository `verify-tests-fail.ps1` finished with **`VERIFICATION
PASSED`**, using frozen base `49b62062536b4a2b957d965f76035eb56806615c`
and restoring only the two fix files. The final native A/B evidence is
deterministic. The without-fix keyboard fixture was timing-dependent and
also encountered element-lookup failures; its logs contain the original
retained `2705` assertion. The standalone NUnit probe independently
isolates that bookkeeping defect. No claim is made that every
broad-fixture failure was caused by this PR's targeted bug.

Initial verification attempts were blocked by the pinned XHarness
runtime and its default instrumentation selection. They are not counted
as native proof. Final native execution used the manifest's explicit
`com.microsoft.maui.core.devicetests.TestInstrumentation` with a
session-local runtime. No repository tool versions or machine-wide SDKs
were changed.

Focused UI command, executed three times:

```powershell
pwsh .github/scripts/BuildAndRunHostApp.ps1 -Platform android -Configuration Release -DeviceUdid emulator-5554 -TestFilter 'FullyQualifiedName~Issue33038|FullyQualifiedName~SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle'
```

The worktree was clean after verification. PR CI is separate: [maui-pr
build
1602977](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1602977)
is running; this is not a full-CI-green or full-suite-green claim. No
`maui-pr-uitests` build had been scheduled at the time of this update.

### Related work and constraints

The native correction follows the narrowly scoped approach proposed in
closed, unmerged #38641, without its unrelated MacCatalyst skip. Open
#37953 proposes a broader SafeArea redesign; this PR keeps a small
correction and fixes the separate NUnit bookkeeping defect.

Do not replace the navigation baseline, widen its tolerance, or remove
the translated-child guard to make the test pass. Do not use caught
NUnit assertions as a polling predicate. The generic Appium helper
remains unchanged here to avoid adding an NUnit dependency or broad
test-infrastructure changes.

### Issues Fixed

Fixes #37555
Fixes #37556
Refs #33038
Refs #38135

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@github-actions github-actions Bot locked and limited conversation to collaborators Oct 8, 2026

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — a51ae7a0 Deployed Sep 7, 2026 by kubaflo via conclusion #1778
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 platform/android

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] TranslationY out of screen creates broken layout padding

3 participants