Skip to content

[net11] Fix flaky Issue35119 test: hide prompt keyboard without Appium's BACK fallback - #40361

Merged
kubaflo merged 1 commit into
net11from
kubaflo-net11-issue35119-esc-keyboard
Nov 18, 2026
Merged

kubaflo merged 1 commit into
net11from
kubaflo-net11-issue35119-esc-keyboard

Conversation

@kubaflo

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

Target Branch

This PR is for Initial base
New features, API changes, or .NET 12 work (including .NET 12 fixes) main
.NET 11 servicing fixes net11, for review
Older servicing, release integration, infrastructure, or documentation The branch designated for that work

For .NET 11 fixes, only a maintainer retargets the approved PR to the active
inflight lane and merges it after CI validates that final base. Do not merge
individual fixes directly into net11; agents must not retarget or merge.

Description of Change

Test-only fix for the intermittent Android Material3 UI test failure Issue35119.DialogsRenderWithM3Styling. It times out at Issue35119.cs:41 in TapDisplayAlertButton("Cancel") and passes on retry. It failed in 6 of 18 cached net11/candidate Material3 logs.

Root cause (from the failing attempt's logcat, maui-pr-uitests 1687006, Material3 drop):

  1. The prompt opens and the IME shows (ImeTracker onShown).
  2. App.DismissKeyboard() calls Appium hideKeyboard, which sends ESC. The IME consumes it (HIDE_SOFT_INPUT_FROM_VIEW), but the hide animation stalls (STATUS_TIMEOUT).
  3. appium-adb's hideKeyboard polls mInputShown for ~1s and then falls back to BACK. That BACK reaches the dialog's back callback: VRI[Prompt Title]: Dropping event due to root view being removed: KEYCODE_BACK. The prompt is cancelled before the test taps "Cancel".

Fix: if the IME is visible, send only ESC and wait (with the normal helper timeout) for the keyboard to hide. The test never sends BACK. ESC is sent only while the IME is shown, because without a visible IME it would reach the dialog. Product code, the shared DismissKeyboard helper (used by 43 tests), assertions and baselines are unchanged.

Local validation (Maui39688_M3_API36 emulator with CI's Material3 CoreCLR HostApp APK from build 1687006):

  • Mechanism probe (temporary, not committed; fresh fixture, status initially "No dialog shown yet"):
    • ESC + BACK on the open prompt dismissed it and set "Prompt result: cancelled" with no Cancel tap.
    • ESC alone hid the keyboard and left the prompt open.
  • Fixed test: passed 3/3 at normal animation speed and 1/1 at 10× animation scale. The Appium log shows only pressKey 111 for the prompt and no hideKeyboard or BACK.
  • Limitation: the CI IME stall did not reproduce locally. The original test also passed at 10× because ESC hid the IME within Appium's 1s window. Red→green is therefore shown at the mechanism level (CI logcat plus the probe), not as a local test reproduction.

The test file is identical on net11, the candidate SR2 branch and main, and no open PR addresses this.

Issues Fixed

Fixes intermittent CI failure of Issue35119.DialogsRenderWithM3Styling (test added in #35121).

App.DismissKeyboard() uses Appium hideKeyboard, which sends ESC and falls
back to BACK when the IME still reports shown after ~1s. On slow CI
emulators the IME hide animation outlasts that window, so BACK reaches
the prompt and cancels it; TapDisplayAlertButton("Cancel") then times out.
Send only ESC (when the IME is visible) and wait for the keyboard to hide.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
@kubaflo
kubaflo temporarily deployed to copilot-pat-pool November 18, 2026 05:28 — 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 -- 40361

Or

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

@azure-pipelines

This comment has been minimized.

@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 Nov 18, 2026
@kubaflo

kubaflo commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

/rebase

@kubaflo

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@MauiBot

MauiBot commented Nov 18, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@kubaflo — existing-test verification; Setup did not capture a tested commit.

Result INCONCLUSIVE Platform Android


🧪 Gate analysis — click to expand

⚠ Inconclusive. Setup, build, or execution did not produce a conclusive result. This does not prove the fix is incorrect.

No interpretable test-group summary was produced. No additional test execution is inferred.

Setup did not capture a verified PR head; no commit is claimed as tested.

No immutable without-fix baseline was prepared.

@MauiBot MauiBot removed the s/agent-review-in-progress AI review is currently running for this PR label Nov 18, 2026

@github-actions github-actions Bot 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.

Expert Review — 0 findings

Reviewed commit ba87a9c.

@kubaflo

This comment has been minimized.

@github-actions

Copy link
Copy Markdown
Contributor

Tests Failure Analysis

@kubaflo — test-failure analysis for commit ba87a9c.

Scope CI failures Commit ba87a9c


🧪 CI Analysis — click to expand
📊 maui-pr

🧪 maui-pr-devicetests

Windows failures below lack diagnostic-equivalent matches across the five target runs; name-only Border/hover matches cannot establish unrelatedness.


🧪 maui-pr-uitests

The matching iOS/MacCatalyst failures below also occur without this Android-only helper change.


🧭 Follow-up — actions and refresh

Next action: Retrieve the macOS Release diagnostic; compare unresolved tests on net11 with identical parameters/setup, inspect the Windows snapshot and Android crash log.

Maintainers: comment /review tests to refresh this report.

@kubaflo
kubaflo merged commit 9327ac2 into net11 Nov 18, 2026
148 of 167 checks passed
@kubaflo
kubaflo deleted the kubaflo-net11-issue35119-esc-keyboard branch November 18, 2026 10:40
@kubaflo kubaflo mentioned this pull request Nov 18, 2026
1 task
marcelomoresco pushed a commit to marcelomoresco/dotnet-maui that referenced this pull request Nov 18, 2026
…m's BACK fallback (dotnet#40361)

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

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only fix for the intermittent Android Material3 UI test failure
`Issue35119.DialogsRenderWithM3Styling`. It times out at
`Issue35119.cs:41` in `TapDisplayAlertButton("Cancel")` and passes on
retry. It failed in 6 of 18 cached net11/candidate Material3 logs.

**Root cause (from the failing attempt's logcat, maui-pr-uitests
1687006, Material3 drop):**
1. The prompt opens and the IME shows (`ImeTracker onShown`).
2. `App.DismissKeyboard()` calls Appium `hideKeyboard`, which sends ESC.
The IME consumes it (`HIDE_SOFT_INPUT_FROM_VIEW`), but the hide
animation stalls (`STATUS_TIMEOUT`).
3. appium-adb's `hideKeyboard` polls `mInputShown` for ~1s and then
falls back to **BACK**. That BACK reaches the dialog's back callback:
`VRI[Prompt Title]: Dropping event due to root view being removed:
KEYCODE_BACK`. The prompt is cancelled before the test taps "Cancel".

**Fix:** if the IME is visible, send only ESC and wait (with the normal
helper timeout) for the keyboard to hide. The test never sends BACK. ESC
is sent only while the IME is shown, because without a visible IME it
would reach the dialog. Product code, the shared `DismissKeyboard`
helper (used by 43 tests), assertions and baselines are unchanged.

**Local validation** (`Maui39688_M3_API36` emulator with CI's Material3
CoreCLR HostApp APK from build 1687006):
- **Mechanism probe** (temporary, not committed; fresh fixture, status
initially "No dialog shown yet"):
- ESC + BACK on the open prompt dismissed it and set "Prompt result:
cancelled" with no Cancel tap.
  - ESC alone hid the keyboard and left the prompt open.
- **Fixed test:** passed 3/3 at normal animation speed and 1/1 at 10×
animation scale. The Appium log shows only `pressKey 111` for the prompt
and no `hideKeyboard` or BACK.
- **Limitation:** the CI IME stall did not reproduce locally. The
original test also passed at 10× because ESC hid the IME within Appium's
1s window. Red→green is therefore shown at the mechanism level (CI
logcat plus the probe), not as a local test reproduction.

The test file is identical on `net11`, the candidate SR2 branch and
`main`, and no open PR addresses this.

### Issues Fixed

Fixes intermittent CI failure of `Issue35119.DialogsRenderWithM3Styling`
(test added in dotnet#35121).

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…on Windows (#40394)

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

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).
This is a test-only fix for a failure on the SR2 candidate #40116.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change. No product code changes.

> [!WARNING]
> **Draft:** the current head includes a temporary diagnostic test,
`DiagnosticSynchronousCurrentItemOverrideRequestOrdering`, which always
fails and reports timings. It will be removed in a follow-up commit
after Windows device CI records its results.

**Symptom.** Candidate device build
[1688573](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688573)
(#40116), *Run DeviceTests Windows* (`Controls.DeviceTests-packaged`):
`CarouselViewTests.CollectionChangePreservesSynchronousCurrentItemOverride`
failed with `Assert.Equal() Failure: Expected: 1, Actual: 0` after 0.54
s. Since 11-13 it failed in 6 of 552 Windows device runs: candidate
1688573, #40361's 1687233, #40288's 1683284, darc-net11 1681785, net11
1680671 and inflight 1680652. The test file is identical on the
candidate, `net11` and `main`.

**Root cause (test race).** Removing the current item makes
`replacement` current, and the test's `CurrentItemChanged` handler
overrides it to `override`. Synchronously, the handler sets `Position =
1` and queues the deferred override scroll. In this test, item 1 is not
visible yet, so the Low-priority
`CompleteCollectionCurrentItemOverrideScroll` does three things:

1. It calls `ScrollIntoView`. Since the viewport width equals the item
width, this already centers item 1 natively.
2. It schedules a 50 ms retry.
3. On the retry pass, it sees the item visible, clears the override and
calls `ItemsView.ScrollTo(1, Center, animate: false)`. That call raises
the counted `ScrollToRequested`.

So the visible centering always precedes the counted request by at least
50 ms. The test asserted `scrollToRequests == 1` as soon as
`WaitForCenteredPositionAsync` (100 ms poll) observed centering. It
passed only when the poll landed after the retry pass.

**Fix.** Wait for the request before asserting the count, exactly like
the sibling
`CollectionChangePreservesCurrentItemOverrideFromPositionChanged` test:

```csharp
await AssertEventually(() => scrollToRequests == 1, timeout: 2000, message: "The deferred current-item override did not request its final centered scroll.");
```

Every existing assertion is unchanged, including `Assert.Equal(1,
scrollToRequests)` and the Mode/Index/Center/IsAnimated checks, so a
duplicate request still fails. No timeout, retry or tolerance changes.

### Issues Fixed

Fixes a failing device test on the SR2 candidate (#40116).

### Validation

Pending Windows device CI. The evidence will be added here.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…on Windows (#40394)

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

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).
This is a test-only fix for a failure on the SR2 candidate #40116.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change. No product code changes.

> [!WARNING]
> **Draft:** the current head includes a temporary diagnostic test,
`DiagnosticSynchronousCurrentItemOverrideRequestOrdering`, which always
fails and reports timings. It will be removed in a follow-up commit
after Windows device CI records its results.

**Symptom.** Candidate device build
[1688573](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688573)
(#40116), *Run DeviceTests Windows* (`Controls.DeviceTests-packaged`):
`CarouselViewTests.CollectionChangePreservesSynchronousCurrentItemOverride`
failed with `Assert.Equal() Failure: Expected: 1, Actual: 0` after 0.54
s. Since 11-13 it failed in 6 of 552 Windows device runs: candidate
1688573, #40361's 1687233, #40288's 1683284, darc-net11 1681785, net11
1680671 and inflight 1680652. The test file is identical on the
candidate, `net11` and `main`.

**Root cause (test race).** Removing the current item makes
`replacement` current, and the test's `CurrentItemChanged` handler
overrides it to `override`. Synchronously, the handler sets `Position =
1` and queues the deferred override scroll. In this test, item 1 is not
visible yet, so the Low-priority
`CompleteCollectionCurrentItemOverrideScroll` does three things:

1. It calls `ScrollIntoView`. Since the viewport width equals the item
width, this already centers item 1 natively.
2. It schedules a 50 ms retry.
3. On the retry pass, it sees the item visible, clears the override and
calls `ItemsView.ScrollTo(1, Center, animate: false)`. That call raises
the counted `ScrollToRequested`.

So the visible centering always precedes the counted request by at least
50 ms. The test asserted `scrollToRequests == 1` as soon as
`WaitForCenteredPositionAsync` (100 ms poll) observed centering. It
passed only when the poll landed after the retry pass.

**Fix.** Wait for the request before asserting the count, exactly like
the sibling
`CollectionChangePreservesCurrentItemOverrideFromPositionChanged` test:

```csharp
await AssertEventually(() => scrollToRequests == 1, timeout: 2000, message: "The deferred current-item override did not request its final centered scroll.");
```

Every existing assertion is unchanged, including `Assert.Equal(1,
scrollToRequests)` and the Mode/Index/Center/IsAnimated checks, so a
duplicate request still fails. No timeout, retry or tolerance changes.

### Issues Fixed

Fixes a failing device test on the SR2 candidate (#40116).

### Validation

Pending Windows device CI. The evidence will be added here.

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

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

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only. On Android, `App.DismissKeyboard()` calls Appium's
`hideKeyboard`. That sends ESC, and if the IME is still reported as
shown about a second later, it also sends BACK. When the IME hide takes
longer than that, BACK closes the test page's `MainActivity` and the
launcher comes to the front. The next element lookup then throws a
`NullReferenceException` or times out.

This is the same mechanism as #40361 (Issue35119). There, BACK cancelled
a prompt.

The fix replaces the three Android `DismissKeyboard()` calls in
`Issue28986_ContentPage` (`SafeAreaPerEdgeValidation`,
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`) and
`Issue28986.SafeAreaPerEdgeValidation` with a helper:
- It waits for the keyboard to show.
- It sends only ESC, which the visible IME consumes.
- It asserts that the keyboard hides.

iOS still calls `DismissKeyboard()`. No assertions, tolerances or
baselines change. The keyboard tests in
`Issue28986_SafeAreaBorderOrientation` are excluded on Android
(`TEST_FAILS_ON_ANDROID`), so they are unchanged.

**CI evidence.** Candidate UI 1689104, SafeAreaEdges API36 (log 2836):
- The original attempt hit an NRE in `Tap("GridResetAllButton")` at line
156, right after `DismissKeyboard()` and a passing
`WaitForKeyboardToHide()`.
- Logcat shows ESC to Gboard, then the app's `onRequestHide`, then
`onHidden` after a stalled IME dump. Then a `Transition CLOSE` for the
app task brings the launcher to the front.
- The same NRE@156 signature appears in UI builds 1687709 and 1687330.

**Local causal validation.** Android 16 (API 36) emulator, `net11`
Material3 HostApp APK from UI build 1688901, filter
`Name=SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle|Name=SafeAreaPerEdgeValidation`
(3 tests per run):

| Phase | Runs | Failed tests |
| --- | --- | --- |
| Baseline (`net11`) | 3 | 9/9 |
| Fixed | 3 | 1/9 |
| Fix reverted | 3 | 6/9 |
| Fix restored | 3 | 1/9 |

- Baseline failures match CI: NRE at `Issue28986_ContentPage.cs:156`
(4), timeout at line 105 (4), a failure at line 126 (1), and timeout in
`Issue28986.cs` at line 193 (6). Each comes after ESC, then `onHidden`,
then a mid-test `Transition CLOSE` of the uitests task. The app
relaunches only after the timeout.
- Both fixed-run failures are in
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` at line 121. That is
the earlier "keyboard shown" assertion, before any hide. Logcat shows no
`onRequestShow` in those runs, so the keyboard was never requested. This
is a separate, pre-hide failure that this PR doesn't address.

### Issues Fixed

Fixes CI flakiness in
`Issue28986_ContentPage.SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`,
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` and
`Issue28986.SafeAreaPerEdgeValidation` on Android.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
…on Windows (#40394)

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

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).
This is a test-only fix for a failure on the SR2 candidate #40116.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change. No product code changes.

> [!WARNING]
> **Draft:** the current head includes a temporary diagnostic test,
`DiagnosticSynchronousCurrentItemOverrideRequestOrdering`, which always
fails and reports timings. It will be removed in a follow-up commit
after Windows device CI records its results.

**Symptom.** Candidate device build
[1688573](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688573)
(#40116), *Run DeviceTests Windows* (`Controls.DeviceTests-packaged`):
`CarouselViewTests.CollectionChangePreservesSynchronousCurrentItemOverride`
failed with `Assert.Equal() Failure: Expected: 1, Actual: 0` after 0.54
s. Since 11-13 it failed in 6 of 552 Windows device runs: candidate
1688573, #40361's 1687233, #40288's 1683284, darc-net11 1681785, net11
1680671 and inflight 1680652. The test file is identical on the
candidate, `net11` and `main`.

**Root cause (test race).** Removing the current item makes
`replacement` current, and the test's `CurrentItemChanged` handler
overrides it to `override`. Synchronously, the handler sets `Position =
1` and queues the deferred override scroll. In this test, item 1 is not
visible yet, so the Low-priority
`CompleteCollectionCurrentItemOverrideScroll` does three things:

1. It calls `ScrollIntoView`. Since the viewport width equals the item
width, this already centers item 1 natively.
2. It schedules a 50 ms retry.
3. On the retry pass, it sees the item visible, clears the override and
calls `ItemsView.ScrollTo(1, Center, animate: false)`. That call raises
the counted `ScrollToRequested`.

So the visible centering always precedes the counted request by at least
50 ms. The test asserted `scrollToRequests == 1` as soon as
`WaitForCenteredPositionAsync` (100 ms poll) observed centering. It
passed only when the poll landed after the retry pass.

**Fix.** Wait for the request before asserting the count, exactly like
the sibling
`CollectionChangePreservesCurrentItemOverrideFromPositionChanged` test:

```csharp
await AssertEventually(() => scrollToRequests == 1, timeout: 2000, message: "The deferred current-item override did not request its final centered scroll.");
```

Every existing assertion is unchanged, including `Assert.Equal(1,
scrollToRequests)` and the Mode/Index/Center/IsAnimated checks, so a
duplicate request still fails. No timeout, retry or tolerance changes.

### Issues Fixed

Fixes a failing device test on the SR2 candidate (#40116).

### Validation

Pending Windows device CI. The evidence will be added here.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
…on Windows (#40394)

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

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).
This is a test-only fix for a failure on the SR2 candidate #40116.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change. No product code changes.

> [!WARNING]
> **Draft:** the current head includes a temporary diagnostic test,
`DiagnosticSynchronousCurrentItemOverrideRequestOrdering`, which always
fails and reports timings. It will be removed in a follow-up commit
after Windows device CI records its results.

**Symptom.** Candidate device build
[1688573](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688573)
(#40116), *Run DeviceTests Windows* (`Controls.DeviceTests-packaged`):
`CarouselViewTests.CollectionChangePreservesSynchronousCurrentItemOverride`
failed with `Assert.Equal() Failure: Expected: 1, Actual: 0` after 0.54
s. Since 11-13 it failed in 6 of 552 Windows device runs: candidate
1688573, #40361's 1687233, #40288's 1683284, darc-net11 1681785, net11
1680671 and inflight 1680652. The test file is identical on the
candidate, `net11` and `main`.

**Root cause (test race).** Removing the current item makes
`replacement` current, and the test's `CurrentItemChanged` handler
overrides it to `override`. Synchronously, the handler sets `Position =
1` and queues the deferred override scroll. In this test, item 1 is not
visible yet, so the Low-priority
`CompleteCollectionCurrentItemOverrideScroll` does three things:

1. It calls `ScrollIntoView`. Since the viewport width equals the item
width, this already centers item 1 natively.
2. It schedules a 50 ms retry.
3. On the retry pass, it sees the item visible, clears the override and
calls `ItemsView.ScrollTo(1, Center, animate: false)`. That call raises
the counted `ScrollToRequested`.

So the visible centering always precedes the counted request by at least
50 ms. The test asserted `scrollToRequests == 1` as soon as
`WaitForCenteredPositionAsync` (100 ms poll) observed centering. It
passed only when the poll landed after the retry pass.

**Fix.** Wait for the request before asserting the count, exactly like
the sibling
`CollectionChangePreservesCurrentItemOverrideFromPositionChanged` test:

```csharp
await AssertEventually(() => scrollToRequests == 1, timeout: 2000, message: "The deferred current-item override did not request its final centered scroll.");
```

Every existing assertion is unchanged, including `Assert.Equal(1,
scrollToRequests)` and the Mode/Index/Center/IsAnimated checks, so a
duplicate request still fails. No timeout, retry or tolerance changes.

### Issues Fixed

Fixes a failing device test on the SR2 candidate (#40116).

### Validation

Pending Windows device CI. The evidence will be added here.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
SubhikshaSf4851 pushed a commit to SubhikshaSf4851/maui that referenced this pull request Nov 23, 2026
…net#40412)

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

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only. On Android, `App.DismissKeyboard()` calls Appium's
`hideKeyboard`. That sends ESC, and if the IME is still reported as
shown about a second later, it also sends BACK. When the IME hide takes
longer than that, BACK closes the test page's `MainActivity` and the
launcher comes to the front. The next element lookup then throws a
`NullReferenceException` or times out.

This is the same mechanism as dotnet#40361 (Issue35119). There, BACK cancelled
a prompt.

The fix replaces the three Android `DismissKeyboard()` calls in
`Issue28986_ContentPage` (`SafeAreaPerEdgeValidation`,
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`) and
`Issue28986.SafeAreaPerEdgeValidation` with a helper:
- It waits for the keyboard to show.
- It sends only ESC, which the visible IME consumes.
- It asserts that the keyboard hides.

iOS still calls `DismissKeyboard()`. No assertions, tolerances or
baselines change. The keyboard tests in
`Issue28986_SafeAreaBorderOrientation` are excluded on Android
(`TEST_FAILS_ON_ANDROID`), so they are unchanged.

**CI evidence.** Candidate UI 1689104, SafeAreaEdges API36 (log 2836):
- The original attempt hit an NRE in `Tap("GridResetAllButton")` at line
156, right after `DismissKeyboard()` and a passing
`WaitForKeyboardToHide()`.
- Logcat shows ESC to Gboard, then the app's `onRequestHide`, then
`onHidden` after a stalled IME dump. Then a `Transition CLOSE` for the
app task brings the launcher to the front.
- The same NRE@156 signature appears in UI builds 1687709 and 1687330.

**Local causal validation.** Android 16 (API 36) emulator, `net11`
Material3 HostApp APK from UI build 1688901, filter
`Name=SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle|Name=SafeAreaPerEdgeValidation`
(3 tests per run):

| Phase | Runs | Failed tests |
| --- | --- | --- |
| Baseline (`net11`) | 3 | 9/9 |
| Fixed | 3 | 1/9 |
| Fix reverted | 3 | 6/9 |
| Fix restored | 3 | 1/9 |

- Baseline failures match CI: NRE at `Issue28986_ContentPage.cs:156`
(4), timeout at line 105 (4), a failure at line 126 (1), and timeout in
`Issue28986.cs` at line 193 (6). Each comes after ESC, then `onHidden`,
then a mid-test `Transition CLOSE` of the uitests task. The app
relaunches only after the timeout.
- Both fixed-run failures are in
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` at line 121. That is
the earlier "keyboard shown" assertion, before any hide. Logcat shows no
`onRequestShow` in those runs, so the keyboard was never requested. This
is a separate, pre-hide failure that this PR doesn't address.

### Issues Fixed

Fixes CI flakiness in
`Issue28986_ContentPage.SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`,
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` and
`Issue28986.SafeAreaPerEdgeValidation` on Android.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…on Windows (#40394)

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

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).
This is a test-only fix for a failure on the SR2 candidate #40116.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change. No product code changes.

> [!WARNING]
> **Draft:** the current head includes a temporary diagnostic test,
`DiagnosticSynchronousCurrentItemOverrideRequestOrdering`, which always
fails and reports timings. It will be removed in a follow-up commit
after Windows device CI records its results.

**Symptom.** Candidate device build
[1688573](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688573)
(#40116), *Run DeviceTests Windows* (`Controls.DeviceTests-packaged`):
`CarouselViewTests.CollectionChangePreservesSynchronousCurrentItemOverride`
failed with `Assert.Equal() Failure: Expected: 1, Actual: 0` after 0.54
s. Since 11-13 it failed in 6 of 552 Windows device runs: candidate
1688573, #40361's 1687233, #40288's 1683284, darc-net11 1681785, net11
1680671 and inflight 1680652. The test file is identical on the
candidate, `net11` and `main`.

**Root cause (test race).** Removing the current item makes
`replacement` current, and the test's `CurrentItemChanged` handler
overrides it to `override`. Synchronously, the handler sets `Position =
1` and queues the deferred override scroll. In this test, item 1 is not
visible yet, so the Low-priority
`CompleteCollectionCurrentItemOverrideScroll` does three things:

1. It calls `ScrollIntoView`. Since the viewport width equals the item
width, this already centers item 1 natively.
2. It schedules a 50 ms retry.
3. On the retry pass, it sees the item visible, clears the override and
calls `ItemsView.ScrollTo(1, Center, animate: false)`. That call raises
the counted `ScrollToRequested`.

So the visible centering always precedes the counted request by at least
50 ms. The test asserted `scrollToRequests == 1` as soon as
`WaitForCenteredPositionAsync` (100 ms poll) observed centering. It
passed only when the poll landed after the retry pass.

**Fix.** Wait for the request before asserting the count, exactly like
the sibling
`CollectionChangePreservesCurrentItemOverrideFromPositionChanged` test:

```csharp
await AssertEventually(() => scrollToRequests == 1, timeout: 2000, message: "The deferred current-item override did not request its final centered scroll.");
```

Every existing assertion is unchanged, including `Assert.Equal(1,
scrollToRequests)` and the Mode/Index/Center/IsAnimated checks, so a
duplicate request still fails. No timeout, retry or tolerance changes.

### Issues Fixed

Fixes a failing device test on the SR2 candidate (#40116).

### Validation

Pending Windows device CI. The evidence will be added here.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo added a commit to kubaflo/maui that referenced this pull request Nov 23, 2026
…net#40412)

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

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only. On Android, `App.DismissKeyboard()` calls Appium's
`hideKeyboard`. That sends ESC, and if the IME is still reported as
shown about a second later, it also sends BACK. When the IME hide takes
longer than that, BACK closes the test page's `MainActivity` and the
launcher comes to the front. The next element lookup then throws a
`NullReferenceException` or times out.

This is the same mechanism as dotnet#40361 (Issue35119). There, BACK cancelled
a prompt.

The fix replaces the three Android `DismissKeyboard()` calls in
`Issue28986_ContentPage` (`SafeAreaPerEdgeValidation`,
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`) and
`Issue28986.SafeAreaPerEdgeValidation` with a helper:
- It waits for the keyboard to show.
- It sends only ESC, which the visible IME consumes.
- It asserts that the keyboard hides.

iOS still calls `DismissKeyboard()`. No assertions, tolerances or
baselines change. The keyboard tests in
`Issue28986_SafeAreaBorderOrientation` are excluded on Android
(`TEST_FAILS_ON_ANDROID`), so they are unchanged.

**CI evidence.** Candidate UI 1689104, SafeAreaEdges API36 (log 2836):
- The original attempt hit an NRE in `Tap("GridResetAllButton")` at line
156, right after `DismissKeyboard()` and a passing
`WaitForKeyboardToHide()`.
- Logcat shows ESC to Gboard, then the app's `onRequestHide`, then
`onHidden` after a stalled IME dump. Then a `Transition CLOSE` for the
app task brings the launcher to the front.
- The same NRE@156 signature appears in UI builds 1687709 and 1687330.

**Local causal validation.** Android 16 (API 36) emulator, `net11`
Material3 HostApp APK from UI build 1688901, filter
`Name=SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle|Name=SafeAreaPerEdgeValidation`
(3 tests per run):

| Phase | Runs | Failed tests |
| --- | --- | --- |
| Baseline (`net11`) | 3 | 9/9 |
| Fixed | 3 | 1/9 |
| Fix reverted | 3 | 6/9 |
| Fix restored | 3 | 1/9 |

- Baseline failures match CI: NRE at `Issue28986_ContentPage.cs:156`
(4), timeout at line 105 (4), a failure at line 126 (1), and timeout in
`Issue28986.cs` at line 193 (6). Each comes after ESC, then `onHidden`,
then a mid-test `Transition CLOSE` of the uitests task. The app
relaunches only after the timeout.
- Both fixed-run failures are in
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` at line 121. That is
the earlier "keyboard shown" assertion, before any hide. Logcat shows no
`onRequestShow` in those runs, so the keyboard was never requested. This
is a separate, pre-hide failure that this PR doesn't address.

### Issues Fixed

Fixes CI flakiness in
`Issue28986_ContentPage.SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`,
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` and
`Issue28986.SafeAreaPerEdgeValidation` on Android.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
SuthiYuvaraj pushed a commit to SuthiYuvaraj/maui that referenced this pull request Nov 25, 2026
…net#40412)

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

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only. On Android, `App.DismissKeyboard()` calls Appium's
`hideKeyboard`. That sends ESC, and if the IME is still reported as
shown about a second later, it also sends BACK. When the IME hide takes
longer than that, BACK closes the test page's `MainActivity` and the
launcher comes to the front. The next element lookup then throws a
`NullReferenceException` or times out.

This is the same mechanism as dotnet#40361 (Issue35119). There, BACK cancelled
a prompt.

The fix replaces the three Android `DismissKeyboard()` calls in
`Issue28986_ContentPage` (`SafeAreaPerEdgeValidation`,
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`) and
`Issue28986.SafeAreaPerEdgeValidation` with a helper:
- It waits for the keyboard to show.
- It sends only ESC, which the visible IME consumes.
- It asserts that the keyboard hides.

iOS still calls `DismissKeyboard()`. No assertions, tolerances or
baselines change. The keyboard tests in
`Issue28986_SafeAreaBorderOrientation` are excluded on Android
(`TEST_FAILS_ON_ANDROID`), so they are unchanged.

**CI evidence.** Candidate UI 1689104, SafeAreaEdges API36 (log 2836):
- The original attempt hit an NRE in `Tap("GridResetAllButton")` at line
156, right after `DismissKeyboard()` and a passing
`WaitForKeyboardToHide()`.
- Logcat shows ESC to Gboard, then the app's `onRequestHide`, then
`onHidden` after a stalled IME dump. Then a `Transition CLOSE` for the
app task brings the launcher to the front.
- The same NRE@156 signature appears in UI builds 1687709 and 1687330.

**Local causal validation.** Android 16 (API 36) emulator, `net11`
Material3 HostApp APK from UI build 1688901, filter
`Name=SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle|Name=SafeAreaPerEdgeValidation`
(3 tests per run):

| Phase | Runs | Failed tests |
| --- | --- | --- |
| Baseline (`net11`) | 3 | 9/9 |
| Fixed | 3 | 1/9 |
| Fix reverted | 3 | 6/9 |
| Fix restored | 3 | 1/9 |

- Baseline failures match CI: NRE at `Issue28986_ContentPage.cs:156`
(4), timeout at line 105 (4), a failure at line 126 (1), and timeout in
`Issue28986.cs` at line 193 (6). Each comes after ESC, then `onHidden`,
then a mid-test `Transition CLOSE` of the uitests task. The app
relaunches only after the timeout.
- Both fixed-run failures are in
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` at line 121. That is
the earlier "keyboard shown" assertion, before any hide. Logcat shows no
`onRequestShow` in those runs, so the keyboard was never requested. This
is a separate, pre-hide failure that this PR doesn't address.

### Issues Fixed

Fixes CI flakiness in
`Issue28986_ContentPage.SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`,
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` and
`Issue28986.SafeAreaPerEdgeValidation` on Android.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…net#40412)

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

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only. On Android, `App.DismissKeyboard()` calls Appium's
`hideKeyboard`. That sends ESC, and if the IME is still reported as
shown about a second later, it also sends BACK. When the IME hide takes
longer than that, BACK closes the test page's `MainActivity` and the
launcher comes to the front. The next element lookup then throws a
`NullReferenceException` or times out.

This is the same mechanism as dotnet#40361 (Issue35119). There, BACK cancelled
a prompt.

The fix replaces the three Android `DismissKeyboard()` calls in
`Issue28986_ContentPage` (`SafeAreaPerEdgeValidation`,
`SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`) and
`Issue28986.SafeAreaPerEdgeValidation` with a helper:
- It waits for the keyboard to show.
- It sends only ESC, which the visible IME consumes.
- It asserts that the keyboard hides.

iOS still calls `DismissKeyboard()`. No assertions, tolerances or
baselines change. The keyboard tests in
`Issue28986_SafeAreaBorderOrientation` are excluded on Android
(`TEST_FAILS_ON_ANDROID`), so they are unchanged.

**CI evidence.** Candidate UI 1689104, SafeAreaEdges API36 (log 2836):
- The original attempt hit an NRE in `Tap("GridResetAllButton")` at line
156, right after `DismissKeyboard()` and a passing
`WaitForKeyboardToHide()`.
- Logcat shows ESC to Gboard, then the app's `onRequestHide`, then
`onHidden` after a stalled IME dump. Then a `Transition CLOSE` for the
app task brings the launcher to the front.
- The same NRE@156 signature appears in UI builds 1687709 and 1687330.

**Local causal validation.** Android 16 (API 36) emulator, `net11`
Material3 HostApp APK from UI build 1688901, filter
`Name=SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle|Name=SafeAreaPerEdgeValidation`
(3 tests per run):

| Phase | Runs | Failed tests |
| --- | --- | --- |
| Baseline (`net11`) | 3 | 9/9 |
| Fixed | 3 | 1/9 |
| Fix reverted | 3 | 6/9 |
| Fix restored | 3 | 1/9 |

- Baseline failures match CI: NRE at `Issue28986_ContentPage.cs:156`
(4), timeout at line 105 (4), a failure at line 126 (1), and timeout in
`Issue28986.cs` at line 193 (6). Each comes after ESC, then `onHidden`,
then a mid-test `Transition CLOSE` of the uitests task. The app
relaunches only after the timeout.
- Both fixed-run failures are in
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` at line 121. That is
the earlier "keyboard shown" assertion, before any hide. Logcat shows no
`onRequestShow` in those runs, so the keyboard was never requested. This
is a separate, pre-hide failure that this PR doesn't address.

### Issues Fixed

Fixes CI flakiness in
`Issue28986_ContentPage.SafeAreaNoWhiteSpaceAfterKeyboardDismissAndEdgeToggle`,
`Issue28986_ContentPage.SafeAreaPerEdgeValidation` and
`Issue28986.SafeAreaPerEdgeValidation` on Android.

Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…on Windows (dotnet#40394)

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

<!--
Open .NET 11 fix PRs against net11 for review; target main for
next-major features.
After approval, a maintainer manually retargets the fix PR to the active
inflight
branch and merges it directly there. Do not merge individual fixes into
net11.
Bots must not retarget or merge. Candidate integration into net11 and
release/*
changes are separate, explicitly coordinated release work.
-->

### Target Branch

| This PR is for | Initial base |
| --- | --- |
| New features, API changes, or .NET 12 work (including .NET 12 fixes) |
`main` |
| .NET 11 servicing fixes | `net11`, for review |
| Older servicing, release integration, infrastructure, or documentation
| The branch designated for that work |

- [x] I selected the applicable base branch using the [contribution
guide](https://github.com/dotnet/maui/blob/main/.github/CONTRIBUTING.md#choose-your-pr-base-before-starting).
This is a test-only fix for a failure on the SR2 candidate dotnet#40116.

For .NET 11 fixes, only a maintainer retargets the approved PR to the
active
inflight lane and merges it after CI validates that final base. Do not
merge
individual fixes directly into `net11`; agents must not retarget or
merge.

### Description of Change

Test-only change. No product code changes.

> [!WARNING]
> **Draft:** the current head includes a temporary diagnostic test,
`DiagnosticSynchronousCurrentItemOverrideRequestOrdering`, which always
fails and reports timings. It will be removed in a follow-up commit
after Windows device CI records its results.

**Symptom.** Candidate device build
[1688573](https://dev.azure.com/dnceng-public/public/_build/results?buildId=1688573)
(dotnet#40116), *Run DeviceTests Windows* (`Controls.DeviceTests-packaged`):
`CarouselViewTests.CollectionChangePreservesSynchronousCurrentItemOverride`
failed with `Assert.Equal() Failure: Expected: 1, Actual: 0` after 0.54
s. Since 11-13 it failed in 6 of 552 Windows device runs: candidate
1688573, dotnet#40361's 1687233, dotnet#40288's 1683284, darc-net11 1681785, net11
1680671 and inflight 1680652. The test file is identical on the
candidate, `net11` and `main`.

**Root cause (test race).** Removing the current item makes
`replacement` current, and the test's `CurrentItemChanged` handler
overrides it to `override`. Synchronously, the handler sets `Position =
1` and queues the deferred override scroll. In this test, item 1 is not
visible yet, so the Low-priority
`CompleteCollectionCurrentItemOverrideScroll` does three things:

1. It calls `ScrollIntoView`. Since the viewport width equals the item
width, this already centers item 1 natively.
2. It schedules a 50 ms retry.
3. On the retry pass, it sees the item visible, clears the override and
calls `ItemsView.ScrollTo(1, Center, animate: false)`. That call raises
the counted `ScrollToRequested`.

So the visible centering always precedes the counted request by at least
50 ms. The test asserted `scrollToRequests == 1` as soon as
`WaitForCenteredPositionAsync` (100 ms poll) observed centering. It
passed only when the poll landed after the retry pass.

**Fix.** Wait for the request before asserting the count, exactly like
the sibling
`CollectionChangePreservesCurrentItemOverrideFromPositionChanged` test:

```csharp
await AssertEventually(() => scrollToRequests == 1, timeout: 2000, message: "The deferred current-item override did not request its final centered scroll.");
```

Every existing assertion is unchanged, including `Assert.Equal(1,
scrollToRequests)` and the Mode/Index/Center/IsAnimated checks, so a
duplicate request still fails. No timeout, retry or tolerance changes.

### Issues Fixed

Fixes a failing device test on the SR2 candidate (dotnet#40116).

### Validation

Pending Windows device CI. The evidence will be added here.

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

This branch was previously deployed

1 inactive deployment
copilot-pat-pool — ba87a9c3 Deployed Nov 18, 2026 by kubaflo via conclusion #3064
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants