Skip to content

[Android] Fix immediate modal pop leaving dialog visible after non-animated push - #40135

Merged
kubaflo merged 2 commits into
dotnet:candidate/11.0.1xx-sr2from
sheiksyedm:fix-android-modal-immediate-pop
Nov 11, 2026
Merged

kubaflo merged 2 commits into
dotnet:candidate/11.0.1xx-sr2from
sheiksyedm:fix-android-modal-immediate-pop

Conversation

@sheiksyedm

@sheiksyedm sheiksyedm commented Nov 10, 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!

Issue details

Issue reports that immediately popping an Android modal after a non-animated push removes the page from Navigation.ModalStack, but leaves its native ModalFragment dialog on screen:

await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);

Expected: the modal closes and the previous page becomes visible. Actual: the logical modal stack is empty, but a full-screen native dialog remains, leaving logical and native navigation out of sync. The author reports working behavior in 10.0.20, failure in 10.0.30, and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes are not affected by the reported reproduction because the animation gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on Android 15/API 35: before the fix, Loaded at pop: False; stack: 0; dialogs: 1.

Root cause

ModalFragment.OnResume can run before the modal page's platform view is attached and Loaded has fired. Previously, it unconditionally raised PresentationCompleted, allowing PushModalAsync(animated: false) to return before the modal was ready for an immediate native pop.

The subsequent PopModalAsync checks IsModalReady. When the current platform page is not loaded, it skips PopModalPlatformAsync and defers stack synchronization, but still removes the modal's logical parent and disconnects its handler. The native modal remains in _platformModalPages. Deferred synchronization then waits for that same modal to have a handler and loaded platform view, a condition that cannot recover after disconnection. Consequently, the native dialog is never dismissed.

Regression reason

The likely introducing change is PR #32479, which fixed a related hang involving Task.Yield() by making non-animated pushes await a new PresentationCompleted event. That event was raised synchronously from OnResume, which is not sufficient proof that the modal page is loaded. An awaiting immediate pop can therefore continue inside this lifecycle timing window.

Release-source tracing supports this attribution:

  • The Android modal-manager source in 10.0.20 exactly matches the parent of the shipped change 5214279.
  • The source in 10.0.30 exactly matches both the original PR merge and that shipped change, integrated through dotnet/maui#33363.
  • The shared modal-manager source is identical between those releases, locating the relevant behavioral difference in Android presentation timing.

This is likely, not confirmed introduction: no same-environment runtime comparison of the candidate and its parent was performed. The release histories diverge, so the version comparison was not treated as a linear bisect.

Fix details

In ModalNavigationManager.Android.cs, complete presentation only when both the page is loaded and the fragment is resumed:

  • Subscribe to the modal page's Loaded event when constructing the fragment.
  • If Loaded happens first, OnResume completes presentation only when IsLoaded is true.
  • If resume happens first, the Loaded handler completes presentation only when IsResumed is true.
  • Unsubscribe Loaded when presentation completes or the dialog is dismissed.
  • Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding delays or changing shared modal-stack cleanup. No public API changes are introduced, and other platform implementations are unchanged.

Issues Fixed

Fixes #40134

github-actions Bot and others added 2 commits November 10, 2026 02:07
<!-- 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 |

- [ ] 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

<!-- Enter description of the fix in this section -->

<!-- maui-release-state:production:11.0.1xx-sr2 -->

Advance canonical **`eng/release-rollover.json`** from SR1 to SR2 after
verified staging, reviewed normalization and next-lane preparation.

Staged source: `01c74ef93c991830e310a77ec808b51b29bcac1f`. Next
candidate: `candidate/11.0.1xx-sr2`. Next inflight:
`inflight/11.0.1xx-sr3`.
No real release branch or servicing review is required for this state
update. Independently, the publication workflow opens a servicing PR
against staging; after reviewing it and using Create a merge commit, a
maintainer manually cuts the real release at that exact merge. Staging
alone never authorizes signing.

Only `currentSr` changes. `nightlyMode` remains **legacy**; SDK, package
metadata, branch roles, release contents and access rules are unchanged.

**Review and required CI are mandatory. Automation never updates the
default branch, approves, retargets or merges this PR.**
If nightlyMode is already versioned, advancing currentSr also selects
the following inflight lane. Before merging, verify that exact lane has
its protections, internal mirror, schedule, signed artifacts and
existing feed/channel wiring deployed.
The first legacy-to-versioned switch is a separate owner-reviewed state
change after that deployment evidence exists; this PR does not guess or
certify it.

### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

N/A - staged release configuration.

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
Wait for the modal page to load and the fragment to resume before completing presentation, so an immediate pop dismisses the native dialog.

Add repeated Shell and NavigationPage regression coverage with animated and non-animated pops. Relates to dotnet#40134.
Copilot AI balanced review requested due to automatic review settings November 10, 2026 14:48
@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 -- 40135

Or

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

@dotnet-policy-service dotnet-policy-service Bot added the partner/syncfusion Issues / PR's with Syncfusion collaboration label Nov 10, 2026
@azure-pipelines

This comment has been minimized.

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.

🔵 Needs a closer look

The native Android lifecycle-timing changes require device validation across Loaded/resume orderings and animated/non-animated pops, but the new device tests were not executed.

No open issues 🎉

What changed in this PR

Fixes #40134 by tightening Android modal presentation readiness so an immediate pop after a non-animated push can dismiss the native dialog rather than leaving it visible.

Changes:

  • Wait for both the modal page to load and the fragment to resume before completing normal presentation.
  • Remove the Loaded subscription when presentation completes or the dialog is dismissed.
  • Add regression coverage for Shell and NavigationPage roots, animated and non-animated pops, and repeated push/pop sequences.
File Description
src/​Controls/​tests/​DeviceTests/​Elements/​Modal/​ModalTests.Android.cs Tests readiness, logical stack cleanup, and native dialog dismissal after immediate pops.
src/​Controls/​src/​Core/​Platform/​ModalNavigationManager/​ModalNavigationManager.Android.cs Coordinates loaded/resumed readiness and cleans up the new event subscription.

Review effort: Balanced

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

This comment has been minimized.

@azure-pipelines

This comment has been minimized.

@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 cf4988f.

@MauiBot

MauiBot commented Nov 10, 2026

Copy link
Copy Markdown
Collaborator

PR Test Gate

@sheiksyedm — existing-test verification for commit cf4988f6.

Result PASSED Platform Android Commit cf4988f6


🧪 Gate analysis — click to expand

✅ Passed. The selected verification satisfied the gate's passing conditions. Unmatched, skipped, or inconclusive groups are not passing evidence.

📱 Device tests
Test group Without fix With fix
ModalTests (ImmediatePopAfterNonAnimatedPushDismissesDialog) ✅ Failed as expected (431s) ✅ Passed (421s)
Execution log excerpts

Without fix ModalTests (ImmediatePopAfterNonAnimatedPushDismissesDialog)

moryBytes": 8322981888
          },
          "target": {
            "kind": "emulator",
            "name": "sdk_gphone_x86_64",
            "identifier": "emulator-5554",
            "operatingSystem": "Android",
            "operatingSystemVersion": "11",
            "apiLevel": 30,
            "architecture": "x86_64",
            "supportedArchitectures": [
              "x86_64",
              "x86",
              "arm64-v8a",
              "armeabi-v7a",
              "armeabi"
            ],
            "manufacturer": "Google",
            "model": "sdk_gphone_x86_64",
            "productName": "sdk_gphone_x86_64",
            "buildFingerprint": "google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys",
            "cpuModel": "0",
            "cpuMaxFrequencyHertz": 2000,
            "totalMemoryBytes": 2077544448
          }
        }
      }
      <<XHARNESS_RESULT_END>>
info: Attempting to remove apk 'com.microsoft.maui.controls.devicetests'..
info: Successfully uninstalled com.microsoft.maui.controls.devicetests
XHarness exit code: 1 (TESTS_FAILED)
  Passed: 0
  Failed: 4
  Skipped: 0
  Total: 4
  Tests completed with exit code: 1

With fix ModalTests (ImmediatePopAfterNonAnimatedPushDismissesDialog)

            "totalMemoryBytes": 8322981888
          },
          "target": {
            "kind": "emulator",
            "name": "sdk_gphone_x86_64",
            "identifier": "emulator-5554",
            "operatingSystem": "Android",
            "operatingSystemVersion": "11",
            "apiLevel": 30,
            "architecture": "x86_64",
            "supportedArchitectures": [
              "x86_64",
              "x86",
              "arm64-v8a",
              "armeabi-v7a",
              "armeabi"
            ],
            "manufacturer": "Google",
            "model": "sdk_gphone_x86_64",
            "productName": "sdk_gphone_x86_64",
            "buildFingerprint": "google/sdk_gphone_x86_64/generic_x86_64_arm64:11/RSR1.201211.001/7027799:user/release-keys",
            "cpuModel": "0",
            "cpuMaxFrequencyHertz": 2000,
            "totalMemoryBytes": 2077544448
          }
        }
      }
      <<XHARNESS_RESULT_END>>
info: Attempting to remove apk 'com.microsoft.maui.controls.devicetests'..
info: Successfully uninstalled com.microsoft.maui.controls.devicetests
XHarness exit code: 0
  Passed: 4
  Failed: 0
  Skipped: 0
  Total: 4
  Tests completed successfully

PR head: cf4988f6.

Without-fix baseline: 13832fce.

@MauiBot MauiBot added s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix) and removed s/agent-review-in-progress AI review is currently running for this PR labels Nov 10, 2026
@kubaflo
kubaflo changed the base branch from main to candidate/11.0.1xx-sr2 November 11, 2026 16:07
@kubaflo
kubaflo merged commit 64dd3c3 into dotnet:candidate/11.0.1xx-sr2 Nov 11, 2026
168 of 187 checks passed
kubaflo added a commit that referenced this pull request Nov 11, 2026
…imated push (#40135)

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

### Issue details

Issue reports that immediately popping an Android modal after a
non-animated push removes the page from `Navigation.ModalStack`, but
leaves its native `ModalFragment` dialog on screen:

```csharp
await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);
```

Expected: the modal closes and the previous page becomes visible.
Actual: the logical modal stack is empty, but a full-screen native
dialog remains, leaving logical and native navigation out of sync. The
author reports working behavior in **10.0.20**, failure in **10.0.30**,
and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes
are not affected by the reported reproduction because the animation
gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on
**Android 15/API 35**: before the fix, `Loaded at pop: False; stack: 0;
dialogs: 1`.

### Root cause

`ModalFragment.OnResume` can run before the modal page's platform view
is attached and `Loaded` has fired. Previously, it unconditionally
raised `PresentationCompleted`, allowing `PushModalAsync(animated:
false)` to return before the modal was ready for an immediate native
pop.

The subsequent `PopModalAsync` checks `IsModalReady`. When the current
platform page is not loaded, it skips `PopModalPlatformAsync` and defers
stack synchronization, but still removes the modal's logical parent and
disconnects its handler. The native modal remains in
`_platformModalPages`. Deferred synchronization then waits for that same
modal to have a handler and loaded platform view, a condition that
cannot recover after disconnection. Consequently, the native dialog is
never dismissed.

### Regression reason

The **likely introducing change** is [PR
#32479](#32479), which fixed a
related hang involving `Task.Yield()` by making non-animated pushes
await a new `PresentationCompleted` event. That event was raised
synchronously from `OnResume`, which is not sufficient proof that the
modal page is loaded. An awaiting immediate pop can therefore continue
inside this lifecycle timing window.

Release-source tracing supports this attribution:

- The Android modal-manager source in **10.0.20** exactly matches the
parent of the [shipped change
`5214279`](5214279).
- The source in **10.0.30** exactly matches both the original PR merge
and that shipped change, integrated through
[#33363](#33363).
- The shared modal-manager source is identical between those releases,
locating the relevant behavioral difference in Android presentation
timing.

This is **likely**, not confirmed introduction: no same-environment
runtime comparison of the candidate and its parent was performed. The
release histories diverge, so the version comparison was not treated as
a linear bisect.

### Fix details

In `ModalNavigationManager.Android.cs`, complete presentation only when
**both** the page is loaded and the fragment is resumed:

- Subscribe to the modal page's `Loaded` event when constructing the
fragment.
- If `Loaded` happens first, `OnResume` completes presentation only when
`IsLoaded` is true.
- If resume happens first, the `Loaded` handler completes presentation
only when `IsResumed` is true.
- Unsubscribe `Loaded` when presentation completes or the dialog is
dismissed.
- Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding
delays or changing shared modal-stack cleanup. No public API changes are
introduced, and other platform implementations are unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40134

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 13, 2026
…imated push (#40135)

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

### Issue details

Issue reports that immediately popping an Android modal after a
non-animated push removes the page from `Navigation.ModalStack`, but
leaves its native `ModalFragment` dialog on screen:

```csharp
await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);
```

Expected: the modal closes and the previous page becomes visible.
Actual: the logical modal stack is empty, but a full-screen native
dialog remains, leaving logical and native navigation out of sync. The
author reports working behavior in **10.0.20**, failure in **10.0.30**,
and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes
are not affected by the reported reproduction because the animation
gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on
**Android 15/API 35**: before the fix, `Loaded at pop: False; stack: 0;
dialogs: 1`.

### Root cause

`ModalFragment.OnResume` can run before the modal page's platform view
is attached and `Loaded` has fired. Previously, it unconditionally
raised `PresentationCompleted`, allowing `PushModalAsync(animated:
false)` to return before the modal was ready for an immediate native
pop.

The subsequent `PopModalAsync` checks `IsModalReady`. When the current
platform page is not loaded, it skips `PopModalPlatformAsync` and defers
stack synchronization, but still removes the modal's logical parent and
disconnects its handler. The native modal remains in
`_platformModalPages`. Deferred synchronization then waits for that same
modal to have a handler and loaded platform view, a condition that
cannot recover after disconnection. Consequently, the native dialog is
never dismissed.

### Regression reason

The **likely introducing change** is [PR
#32479](#32479), which fixed a
related hang involving `Task.Yield()` by making non-animated pushes
await a new `PresentationCompleted` event. That event was raised
synchronously from `OnResume`, which is not sufficient proof that the
modal page is loaded. An awaiting immediate pop can therefore continue
inside this lifecycle timing window.

Release-source tracing supports this attribution:

- The Android modal-manager source in **10.0.20** exactly matches the
parent of the [shipped change
`5214279`](5214279).
- The source in **10.0.30** exactly matches both the original PR merge
and that shipped change, integrated through
[#33363](#33363).
- The shared modal-manager source is identical between those releases,
locating the relevant behavioral difference in Android presentation
timing.

This is **likely**, not confirmed introduction: no same-environment
runtime comparison of the candidate and its parent was performed. The
release histories diverge, so the version comparison was not treated as
a linear bisect.

### Fix details

In `ModalNavigationManager.Android.cs`, complete presentation only when
**both** the page is loaded and the fragment is resumed:

- Subscribe to the modal page's `Loaded` event when constructing the
fragment.
- If `Loaded` happens first, `OnResume` completes presentation only when
`IsLoaded` is true.
- If resume happens first, the `Loaded` handler completes presentation
only when `IsResumed` is true.
- Unsubscribe `Loaded` when presentation completes or the dialog is
dismissed.
- Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding
delays or changing shared modal-stack cleanup. No public API changes are
introduced, and other platform implementations are unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40134

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 16, 2026
…imated push (#40135)

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

### Issue details

Issue reports that immediately popping an Android modal after a
non-animated push removes the page from `Navigation.ModalStack`, but
leaves its native `ModalFragment` dialog on screen:

```csharp
await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);
```

Expected: the modal closes and the previous page becomes visible.
Actual: the logical modal stack is empty, but a full-screen native
dialog remains, leaving logical and native navigation out of sync. The
author reports working behavior in **10.0.20**, failure in **10.0.30**,
and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes
are not affected by the reported reproduction because the animation
gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on
**Android 15/API 35**: before the fix, `Loaded at pop: False; stack: 0;
dialogs: 1`.

### Root cause

`ModalFragment.OnResume` can run before the modal page's platform view
is attached and `Loaded` has fired. Previously, it unconditionally
raised `PresentationCompleted`, allowing `PushModalAsync(animated:
false)` to return before the modal was ready for an immediate native
pop.

The subsequent `PopModalAsync` checks `IsModalReady`. When the current
platform page is not loaded, it skips `PopModalPlatformAsync` and defers
stack synchronization, but still removes the modal's logical parent and
disconnects its handler. The native modal remains in
`_platformModalPages`. Deferred synchronization then waits for that same
modal to have a handler and loaded platform view, a condition that
cannot recover after disconnection. Consequently, the native dialog is
never dismissed.

### Regression reason

The **likely introducing change** is [PR
#32479](#32479), which fixed a
related hang involving `Task.Yield()` by making non-animated pushes
await a new `PresentationCompleted` event. That event was raised
synchronously from `OnResume`, which is not sufficient proof that the
modal page is loaded. An awaiting immediate pop can therefore continue
inside this lifecycle timing window.

Release-source tracing supports this attribution:

- The Android modal-manager source in **10.0.20** exactly matches the
parent of the [shipped change
`5214279`](5214279).
- The source in **10.0.30** exactly matches both the original PR merge
and that shipped change, integrated through
[#33363](#33363).
- The shared modal-manager source is identical between those releases,
locating the relevant behavioral difference in Android presentation
timing.

This is **likely**, not confirmed introduction: no same-environment
runtime comparison of the candidate and its parent was performed. The
release histories diverge, so the version comparison was not treated as
a linear bisect.

### Fix details

In `ModalNavigationManager.Android.cs`, complete presentation only when
**both** the page is loaded and the fragment is resumed:

- Subscribe to the modal page's `Loaded` event when constructing the
fragment.
- If `Loaded` happens first, `OnResume` completes presentation only when
`IsLoaded` is true.
- If resume happens first, the `Loaded` handler completes presentation
only when `IsResumed` is true.
- Unsubscribe `Loaded` when presentation completes or the dialog is
dismissed.
- Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding
delays or changing shared modal-stack cleanup. No public API changes are
introduced, and other platform implementations are unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40134

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 16, 2026
…imated push (#40135)

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

### Issue details

Issue reports that immediately popping an Android modal after a
non-animated push removes the page from `Navigation.ModalStack`, but
leaves its native `ModalFragment` dialog on screen:

```csharp
await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);
```

Expected: the modal closes and the previous page becomes visible.
Actual: the logical modal stack is empty, but a full-screen native
dialog remains, leaving logical and native navigation out of sync. The
author reports working behavior in **10.0.20**, failure in **10.0.30**,
and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes
are not affected by the reported reproduction because the animation
gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on
**Android 15/API 35**: before the fix, `Loaded at pop: False; stack: 0;
dialogs: 1`.

### Root cause

`ModalFragment.OnResume` can run before the modal page's platform view
is attached and `Loaded` has fired. Previously, it unconditionally
raised `PresentationCompleted`, allowing `PushModalAsync(animated:
false)` to return before the modal was ready for an immediate native
pop.

The subsequent `PopModalAsync` checks `IsModalReady`. When the current
platform page is not loaded, it skips `PopModalPlatformAsync` and defers
stack synchronization, but still removes the modal's logical parent and
disconnects its handler. The native modal remains in
`_platformModalPages`. Deferred synchronization then waits for that same
modal to have a handler and loaded platform view, a condition that
cannot recover after disconnection. Consequently, the native dialog is
never dismissed.

### Regression reason

The **likely introducing change** is [PR
#32479](#32479), which fixed a
related hang involving `Task.Yield()` by making non-animated pushes
await a new `PresentationCompleted` event. That event was raised
synchronously from `OnResume`, which is not sufficient proof that the
modal page is loaded. An awaiting immediate pop can therefore continue
inside this lifecycle timing window.

Release-source tracing supports this attribution:

- The Android modal-manager source in **10.0.20** exactly matches the
parent of the [shipped change
`5214279`](5214279).
- The source in **10.0.30** exactly matches both the original PR merge
and that shipped change, integrated through
[#33363](#33363).
- The shared modal-manager source is identical between those releases,
locating the relevant behavioral difference in Android presentation
timing.

This is **likely**, not confirmed introduction: no same-environment
runtime comparison of the candidate and its parent was performed. The
release histories diverge, so the version comparison was not treated as
a linear bisect.

### Fix details

In `ModalNavigationManager.Android.cs`, complete presentation only when
**both** the page is loaded and the fragment is resumed:

- Subscribe to the modal page's `Loaded` event when constructing the
fragment.
- If `Loaded` happens first, `OnResume` completes presentation only when
`IsLoaded` is true.
- If resume happens first, the `Loaded` handler completes presentation
only when `IsResumed` is true.
- Unsubscribe `Loaded` when presentation completes or the dialog is
dismissed.
- Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding
delays or changing shared modal-stack cleanup. No public API changes are
introduced, and other platform implementations are unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40134

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 17, 2026
…imated push (#40135)

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

### Issue details

Issue reports that immediately popping an Android modal after a
non-animated push removes the page from `Navigation.ModalStack`, but
leaves its native `ModalFragment` dialog on screen:

```csharp
await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);
```

Expected: the modal closes and the previous page becomes visible.
Actual: the logical modal stack is empty, but a full-screen native
dialog remains, leaving logical and native navigation out of sync. The
author reports working behavior in **10.0.20**, failure in **10.0.30**,
and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes
are not affected by the reported reproduction because the animation
gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on
**Android 15/API 35**: before the fix, `Loaded at pop: False; stack: 0;
dialogs: 1`.

### Root cause

`ModalFragment.OnResume` can run before the modal page's platform view
is attached and `Loaded` has fired. Previously, it unconditionally
raised `PresentationCompleted`, allowing `PushModalAsync(animated:
false)` to return before the modal was ready for an immediate native
pop.

The subsequent `PopModalAsync` checks `IsModalReady`. When the current
platform page is not loaded, it skips `PopModalPlatformAsync` and defers
stack synchronization, but still removes the modal's logical parent and
disconnects its handler. The native modal remains in
`_platformModalPages`. Deferred synchronization then waits for that same
modal to have a handler and loaded platform view, a condition that
cannot recover after disconnection. Consequently, the native dialog is
never dismissed.

### Regression reason

The **likely introducing change** is [PR
#32479](#32479), which fixed a
related hang involving `Task.Yield()` by making non-animated pushes
await a new `PresentationCompleted` event. That event was raised
synchronously from `OnResume`, which is not sufficient proof that the
modal page is loaded. An awaiting immediate pop can therefore continue
inside this lifecycle timing window.

Release-source tracing supports this attribution:

- The Android modal-manager source in **10.0.20** exactly matches the
parent of the [shipped change
`5214279`](5214279).
- The source in **10.0.30** exactly matches both the original PR merge
and that shipped change, integrated through
[#33363](#33363).
- The shared modal-manager source is identical between those releases,
locating the relevant behavioral difference in Android presentation
timing.

This is **likely**, not confirmed introduction: no same-environment
runtime comparison of the candidate and its parent was performed. The
release histories diverge, so the version comparison was not treated as
a linear bisect.

### Fix details

In `ModalNavigationManager.Android.cs`, complete presentation only when
**both** the page is loaded and the fragment is resumed:

- Subscribe to the modal page's `Loaded` event when constructing the
fragment.
- If `Loaded` happens first, `OnResume` completes presentation only when
`IsLoaded` is true.
- If resume happens first, the `Loaded` handler completes presentation
only when `IsResumed` is true.
- Unsubscribe `Loaded` when presentation completes or the dialog is
dismissed.
- Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding
delays or changing shared modal-stack cleanup. No public API changes are
introduced, and other platform implementations are unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40134

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…imated push (#40135)

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

### Issue details

Issue reports that immediately popping an Android modal after a
non-animated push removes the page from `Navigation.ModalStack`, but
leaves its native `ModalFragment` dialog on screen:

```csharp
await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);
```

Expected: the modal closes and the previous page becomes visible.
Actual: the logical modal stack is empty, but a full-screen native
dialog remains, leaving logical and native navigation out of sync. The
author reports working behavior in **10.0.20**, failure in **10.0.30**,
and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes
are not affected by the reported reproduction because the animation
gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on
**Android 15/API 35**: before the fix, `Loaded at pop: False; stack: 0;
dialogs: 1`.

### Root cause

`ModalFragment.OnResume` can run before the modal page's platform view
is attached and `Loaded` has fired. Previously, it unconditionally
raised `PresentationCompleted`, allowing `PushModalAsync(animated:
false)` to return before the modal was ready for an immediate native
pop.

The subsequent `PopModalAsync` checks `IsModalReady`. When the current
platform page is not loaded, it skips `PopModalPlatformAsync` and defers
stack synchronization, but still removes the modal's logical parent and
disconnects its handler. The native modal remains in
`_platformModalPages`. Deferred synchronization then waits for that same
modal to have a handler and loaded platform view, a condition that
cannot recover after disconnection. Consequently, the native dialog is
never dismissed.

### Regression reason

The **likely introducing change** is [PR
#32479](#32479), which fixed a
related hang involving `Task.Yield()` by making non-animated pushes
await a new `PresentationCompleted` event. That event was raised
synchronously from `OnResume`, which is not sufficient proof that the
modal page is loaded. An awaiting immediate pop can therefore continue
inside this lifecycle timing window.

Release-source tracing supports this attribution:

- The Android modal-manager source in **10.0.20** exactly matches the
parent of the [shipped change
`5214279`](5214279).
- The source in **10.0.30** exactly matches both the original PR merge
and that shipped change, integrated through
[#33363](#33363).
- The shared modal-manager source is identical between those releases,
locating the relevant behavioral difference in Android presentation
timing.

This is **likely**, not confirmed introduction: no same-environment
runtime comparison of the candidate and its parent was performed. The
release histories diverge, so the version comparison was not treated as
a linear bisect.

### Fix details

In `ModalNavigationManager.Android.cs`, complete presentation only when
**both** the page is loaded and the fragment is resumed:

- Subscribe to the modal page's `Loaded` event when constructing the
fragment.
- If `Loaded` happens first, `OnResume` completes presentation only when
`IsLoaded` is true.
- If resume happens first, the `Loaded` handler completes presentation
only when `IsResumed` is true.
- Unsubscribe `Loaded` when presentation completes or the dialog is
dismissed.
- Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding
delays or changing shared modal-stack cleanup. No public API changes are
introduced, and other platform implementations are unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40134

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…imated push (#40135)

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

### Issue details

Issue reports that immediately popping an Android modal after a
non-animated push removes the page from `Navigation.ModalStack`, but
leaves its native `ModalFragment` dialog on screen:

```csharp
await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);
```

Expected: the modal closes and the previous page becomes visible.
Actual: the logical modal stack is empty, but a full-screen native
dialog remains, leaving logical and native navigation out of sync. The
author reports working behavior in **10.0.20**, failure in **10.0.30**,
and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes
are not affected by the reported reproduction because the animation
gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on
**Android 15/API 35**: before the fix, `Loaded at pop: False; stack: 0;
dialogs: 1`.

### Root cause

`ModalFragment.OnResume` can run before the modal page's platform view
is attached and `Loaded` has fired. Previously, it unconditionally
raised `PresentationCompleted`, allowing `PushModalAsync(animated:
false)` to return before the modal was ready for an immediate native
pop.

The subsequent `PopModalAsync` checks `IsModalReady`. When the current
platform page is not loaded, it skips `PopModalPlatformAsync` and defers
stack synchronization, but still removes the modal's logical parent and
disconnects its handler. The native modal remains in
`_platformModalPages`. Deferred synchronization then waits for that same
modal to have a handler and loaded platform view, a condition that
cannot recover after disconnection. Consequently, the native dialog is
never dismissed.

### Regression reason

The **likely introducing change** is [PR
#32479](#32479), which fixed a
related hang involving `Task.Yield()` by making non-animated pushes
await a new `PresentationCompleted` event. That event was raised
synchronously from `OnResume`, which is not sufficient proof that the
modal page is loaded. An awaiting immediate pop can therefore continue
inside this lifecycle timing window.

Release-source tracing supports this attribution:

- The Android modal-manager source in **10.0.20** exactly matches the
parent of the [shipped change
`5214279`](5214279).
- The source in **10.0.30** exactly matches both the original PR merge
and that shipped change, integrated through
[#33363](#33363).
- The shared modal-manager source is identical between those releases,
locating the relevant behavioral difference in Android presentation
timing.

This is **likely**, not confirmed introduction: no same-environment
runtime comparison of the candidate and its parent was performed. The
release histories diverge, so the version comparison was not treated as
a linear bisect.

### Fix details

In `ModalNavigationManager.Android.cs`, complete presentation only when
**both** the page is loaded and the fragment is resumed:

- Subscribe to the modal page's `Loaded` event when constructing the
fragment.
- If `Loaded` happens first, `OnResume` completes presentation only when
`IsLoaded` is true.
- If resume happens first, the `Loaded` handler completes presentation
only when `IsResumed` is true.
- Unsubscribe `Loaded` when presentation completes or the dialog is
dismissed.
- Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding
delays or changing shared modal-stack cleanup. No public API changes are
introduced, and other platform implementations are unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40134

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 18, 2026
…imated push (#40135)

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

### Issue details

Issue reports that immediately popping an Android modal after a
non-animated push removes the page from `Navigation.ModalStack`, but
leaves its native `ModalFragment` dialog on screen:

```csharp
await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);
```

Expected: the modal closes and the previous page becomes visible.
Actual: the logical modal stack is empty, but a full-screen native
dialog remains, leaving logical and native navigation out of sync. The
author reports working behavior in **10.0.20**, failure in **10.0.30**,
and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes
are not affected by the reported reproduction because the animation
gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on
**Android 15/API 35**: before the fix, `Loaded at pop: False; stack: 0;
dialogs: 1`.

### Root cause

`ModalFragment.OnResume` can run before the modal page's platform view
is attached and `Loaded` has fired. Previously, it unconditionally
raised `PresentationCompleted`, allowing `PushModalAsync(animated:
false)` to return before the modal was ready for an immediate native
pop.

The subsequent `PopModalAsync` checks `IsModalReady`. When the current
platform page is not loaded, it skips `PopModalPlatformAsync` and defers
stack synchronization, but still removes the modal's logical parent and
disconnects its handler. The native modal remains in
`_platformModalPages`. Deferred synchronization then waits for that same
modal to have a handler and loaded platform view, a condition that
cannot recover after disconnection. Consequently, the native dialog is
never dismissed.

### Regression reason

The **likely introducing change** is [PR
#32479](#32479), which fixed a
related hang involving `Task.Yield()` by making non-animated pushes
await a new `PresentationCompleted` event. That event was raised
synchronously from `OnResume`, which is not sufficient proof that the
modal page is loaded. An awaiting immediate pop can therefore continue
inside this lifecycle timing window.

Release-source tracing supports this attribution:

- The Android modal-manager source in **10.0.20** exactly matches the
parent of the [shipped change
`5214279`](5214279).
- The source in **10.0.30** exactly matches both the original PR merge
and that shipped change, integrated through
[#33363](#33363).
- The shared modal-manager source is identical between those releases,
locating the relevant behavioral difference in Android presentation
timing.

This is **likely**, not confirmed introduction: no same-environment
runtime comparison of the candidate and its parent was performed. The
release histories diverge, so the version comparison was not treated as
a linear bisect.

### Fix details

In `ModalNavigationManager.Android.cs`, complete presentation only when
**both** the page is loaded and the fragment is resumed:

- Subscribe to the modal page's `Loaded` event when constructing the
fragment.
- If `Loaded` happens first, `OnResume` completes presentation only when
`IsLoaded` is true.
- If resume happens first, the `Loaded` handler completes presentation
only when `IsResumed` is true.
- Unsubscribe `Loaded` when presentation completes or the dialog is
dismissed.
- Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding
delays or changing shared modal-stack cleanup. No public API changes are
introduced, and other platform implementations are unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40134

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 19, 2026
…imated push (#40135)

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

### Issue details

Issue reports that immediately popping an Android modal after a
non-animated push removes the page from `Navigation.ModalStack`, but
leaves its native `ModalFragment` dialog on screen:

```csharp
await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);
```

Expected: the modal closes and the previous page becomes visible.
Actual: the logical modal stack is empty, but a full-screen native
dialog remains, leaving logical and native navigation out of sync. The
author reports working behavior in **10.0.20**, failure in **10.0.30**,
and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes
are not affected by the reported reproduction because the animation
gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on
**Android 15/API 35**: before the fix, `Loaded at pop: False; stack: 0;
dialogs: 1`.

### Root cause

`ModalFragment.OnResume` can run before the modal page's platform view
is attached and `Loaded` has fired. Previously, it unconditionally
raised `PresentationCompleted`, allowing `PushModalAsync(animated:
false)` to return before the modal was ready for an immediate native
pop.

The subsequent `PopModalAsync` checks `IsModalReady`. When the current
platform page is not loaded, it skips `PopModalPlatformAsync` and defers
stack synchronization, but still removes the modal's logical parent and
disconnects its handler. The native modal remains in
`_platformModalPages`. Deferred synchronization then waits for that same
modal to have a handler and loaded platform view, a condition that
cannot recover after disconnection. Consequently, the native dialog is
never dismissed.

### Regression reason

The **likely introducing change** is [PR
#32479](#32479), which fixed a
related hang involving `Task.Yield()` by making non-animated pushes
await a new `PresentationCompleted` event. That event was raised
synchronously from `OnResume`, which is not sufficient proof that the
modal page is loaded. An awaiting immediate pop can therefore continue
inside this lifecycle timing window.

Release-source tracing supports this attribution:

- The Android modal-manager source in **10.0.20** exactly matches the
parent of the [shipped change
`5214279`](5214279).
- The source in **10.0.30** exactly matches both the original PR merge
and that shipped change, integrated through
[#33363](#33363).
- The shared modal-manager source is identical between those releases,
locating the relevant behavioral difference in Android presentation
timing.

This is **likely**, not confirmed introduction: no same-environment
runtime comparison of the candidate and its parent was performed. The
release histories diverge, so the version comparison was not treated as
a linear bisect.

### Fix details

In `ModalNavigationManager.Android.cs`, complete presentation only when
**both** the page is loaded and the fragment is resumed:

- Subscribe to the modal page's `Loaded` event when constructing the
fragment.
- If `Loaded` happens first, `OnResume` completes presentation only when
`IsLoaded` is true.
- If resume happens first, the `Loaded` handler completes presentation
only when `IsResumed` is true.
- Unsubscribe `Loaded` when presentation completes or the dialog is
dismissed.
- Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding
delays or changing shared modal-stack cleanup. No public API changes are
introduced, and other platform implementations are unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40134

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 22, 2026
…imated push (#40135)

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

### Issue details

Issue reports that immediately popping an Android modal after a
non-animated push removes the page from `Navigation.ModalStack`, but
leaves its native `ModalFragment` dialog on screen:

```csharp
await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);
```

Expected: the modal closes and the previous page becomes visible.
Actual: the logical modal stack is empty, but a full-screen native
dialog remains, leaving logical and native navigation out of sync. The
author reports working behavior in **10.0.20**, failure in **10.0.30**,
and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes
are not affected by the reported reproduction because the animation
gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on
**Android 15/API 35**: before the fix, `Loaded at pop: False; stack: 0;
dialogs: 1`.

### Root cause

`ModalFragment.OnResume` can run before the modal page's platform view
is attached and `Loaded` has fired. Previously, it unconditionally
raised `PresentationCompleted`, allowing `PushModalAsync(animated:
false)` to return before the modal was ready for an immediate native
pop.

The subsequent `PopModalAsync` checks `IsModalReady`. When the current
platform page is not loaded, it skips `PopModalPlatformAsync` and defers
stack synchronization, but still removes the modal's logical parent and
disconnects its handler. The native modal remains in
`_platformModalPages`. Deferred synchronization then waits for that same
modal to have a handler and loaded platform view, a condition that
cannot recover after disconnection. Consequently, the native dialog is
never dismissed.

### Regression reason

The **likely introducing change** is [PR
#32479](#32479), which fixed a
related hang involving `Task.Yield()` by making non-animated pushes
await a new `PresentationCompleted` event. That event was raised
synchronously from `OnResume`, which is not sufficient proof that the
modal page is loaded. An awaiting immediate pop can therefore continue
inside this lifecycle timing window.

Release-source tracing supports this attribution:

- The Android modal-manager source in **10.0.20** exactly matches the
parent of the [shipped change
`5214279`](5214279).
- The source in **10.0.30** exactly matches both the original PR merge
and that shipped change, integrated through
[#33363](#33363).
- The shared modal-manager source is identical between those releases,
locating the relevant behavioral difference in Android presentation
timing.

This is **likely**, not confirmed introduction: no same-environment
runtime comparison of the candidate and its parent was performed. The
release histories diverge, so the version comparison was not treated as
a linear bisect.

### Fix details

In `ModalNavigationManager.Android.cs`, complete presentation only when
**both** the page is loaded and the fragment is resumed:

- Subscribe to the modal page's `Loaded` event when constructing the
fragment.
- If `Loaded` happens first, `OnResume` completes presentation only when
`IsLoaded` is true.
- If resume happens first, the `Loaded` handler completes presentation
only when `IsResumed` is true.
- Unsubscribe `Loaded` when presentation completes or the dialog is
dismissed.
- Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding
delays or changing shared modal-stack cleanup. No public API changes are
introduced, and other platform implementations are unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40134

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
kubaflo added a commit that referenced this pull request Nov 23, 2026
…imated push (#40135)

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

### Issue details

Issue reports that immediately popping an Android modal after a
non-animated push removes the page from `Navigation.ModalStack`, but
leaves its native `ModalFragment` dialog on screen:

```csharp
await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);
```

Expected: the modal closes and the previous page becomes visible.
Actual: the logical modal stack is empty, but a full-screen native
dialog remains, leaving logical and native navigation out of sync. The
author reports working behavior in **10.0.20**, failure in **10.0.30**,
and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes
are not affected by the reported reproduction because the animation
gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on
**Android 15/API 35**: before the fix, `Loaded at pop: False; stack: 0;
dialogs: 1`.

### Root cause

`ModalFragment.OnResume` can run before the modal page's platform view
is attached and `Loaded` has fired. Previously, it unconditionally
raised `PresentationCompleted`, allowing `PushModalAsync(animated:
false)` to return before the modal was ready for an immediate native
pop.

The subsequent `PopModalAsync` checks `IsModalReady`. When the current
platform page is not loaded, it skips `PopModalPlatformAsync` and defers
stack synchronization, but still removes the modal's logical parent and
disconnects its handler. The native modal remains in
`_platformModalPages`. Deferred synchronization then waits for that same
modal to have a handler and loaded platform view, a condition that
cannot recover after disconnection. Consequently, the native dialog is
never dismissed.

### Regression reason

The **likely introducing change** is [PR
#32479](#32479), which fixed a
related hang involving `Task.Yield()` by making non-animated pushes
await a new `PresentationCompleted` event. That event was raised
synchronously from `OnResume`, which is not sufficient proof that the
modal page is loaded. An awaiting immediate pop can therefore continue
inside this lifecycle timing window.

Release-source tracing supports this attribution:

- The Android modal-manager source in **10.0.20** exactly matches the
parent of the [shipped change
`5214279`](5214279).
- The source in **10.0.30** exactly matches both the original PR merge
and that shipped change, integrated through
[#33363](#33363).
- The shared modal-manager source is identical between those releases,
locating the relevant behavioral difference in Android presentation
timing.

This is **likely**, not confirmed introduction: no same-environment
runtime comparison of the candidate and its parent was performed. The
release histories diverge, so the version comparison was not treated as
a linear bisect.

### Fix details

In `ModalNavigationManager.Android.cs`, complete presentation only when
**both** the page is loaded and the fragment is resumed:

- Subscribe to the modal page's `Loaded` event when constructing the
fragment.
- If `Loaded` happens first, `OnResume` completes presentation only when
`IsLoaded` is true.
- If resume happens first, the `Loaded` handler completes presentation
only when `IsResumed` is true.
- Unsubscribe `Loaded` when presentation completes or the dialog is
dismissed.
- Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding
delays or changing shared modal-stack cleanup. No public API changes are
introduced, and other platform implementations are unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes #40134

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>
@kubaflo kubaflo added this to the .NET 11 SR2 milestone Nov 24, 2026
KarthikRajaKalaimani pushed a commit to KarthikRajaKalaimani/maui that referenced this pull request Nov 26, 2026
…imated push (dotnet#40135)

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

### Issue details

Issue reports that immediately popping an Android modal after a
non-animated push removes the page from `Navigation.ModalStack`, but
leaves its native `ModalFragment` dialog on screen:

```csharp
await Navigation.PushModalAsync(new ContentPage { BackgroundColor = Colors.Yellow }, animated: false);
await Navigation.PopModalAsync(animated: false);
```

Expected: the modal closes and the previous page becomes visible.
Actual: the logical modal stack is empty, but a full-screen native
dialog remains, leaving logical and native navigation out of sync. The
author reports working behavior in **10.0.20**, failure in **10.0.30**,
and continued failure in 10.0.40, 10.0.110 and 10.0.130. Animated pushes
are not affected by the reported reproduction because the animation
gives the page time to load.

The immediate push/pop sequence was reproduced in the Sandbox sample on
**Android 15/API 35**: before the fix, `Loaded at pop: False; stack: 0;
dialogs: 1`.

### Root cause

`ModalFragment.OnResume` can run before the modal page's platform view
is attached and `Loaded` has fired. Previously, it unconditionally
raised `PresentationCompleted`, allowing `PushModalAsync(animated:
false)` to return before the modal was ready for an immediate native
pop.

The subsequent `PopModalAsync` checks `IsModalReady`. When the current
platform page is not loaded, it skips `PopModalPlatformAsync` and defers
stack synchronization, but still removes the modal's logical parent and
disconnects its handler. The native modal remains in
`_platformModalPages`. Deferred synchronization then waits for that same
modal to have a handler and loaded platform view, a condition that
cannot recover after disconnection. Consequently, the native dialog is
never dismissed.

### Regression reason

The **likely introducing change** is [PR
dotnet#32479](dotnet#32479), which fixed a
related hang involving `Task.Yield()` by making non-animated pushes
await a new `PresentationCompleted` event. That event was raised
synchronously from `OnResume`, which is not sufficient proof that the
modal page is loaded. An awaiting immediate pop can therefore continue
inside this lifecycle timing window.

Release-source tracing supports this attribution:

- The Android modal-manager source in **10.0.20** exactly matches the
parent of the [shipped change
`5214279`](dotnet@5214279).
- The source in **10.0.30** exactly matches both the original PR merge
and that shipped change, integrated through
[dotnet#33363](dotnet#33363).
- The shared modal-manager source is identical between those releases,
locating the relevant behavioral difference in Android presentation
timing.

This is **likely**, not confirmed introduction: no same-environment
runtime comparison of the candidate and its parent was performed. The
release histories diverge, so the version comparison was not treated as
a linear bisect.

### Fix details

In `ModalNavigationManager.Android.cs`, complete presentation only when
**both** the page is loaded and the fragment is resumed:

- Subscribe to the modal page's `Loaded` event when constructing the
fragment.
- If `Loaded` happens first, `OnResume` completes presentation only when
`IsLoaded` is true.
- If resume happens first, the `Loaded` handler completes presentation
only when `IsResumed` is true.
- Unsubscribe `Loaded` when presentation completes or the dialog is
dismissed.
- Preserve the existing early-start/destroy completion safeguards.

This strengthens the presentation-readiness guarantee without adding
delays or changing shared modal-stack cleanup. No public API changes are
introduced, and other platform implementations are unchanged.


### Issues Fixed

<!-- Please make sure that there is a bug logged for the issue being
fixed. The bug should describe the problem and how to reproduce it. -->

Fixes dotnet#40134

<!--
Verify the target branch follows the release workflow in
docs/ReleaseBranchWorkflow.md.
Infrastructure and documentation changes should target the branch where
they apply.
-->

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Jakub Florkowski <42434498+kubaflo@users.noreply.github.com>

This branch was previously deployed

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

Labels

area-controls-modal area-navigation NavigationPage community ✨ Community Contribution partner/syncfusion Issues / PR's with Syncfusion collaboration platform/android s/agent-gate-passed AI verified tests catch the bug (fail without fix, pass with fix)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Android] PopModalAsync right after PushModalAsync(animated: false) leaves the modal dialog on screen (regression in 10.0.30)

4 participants