Repository navigation
[net11] Restart a wedged Android emulator before retrying UI test setup - #40381
Merged
Merged
Conversation
uitest-prepare retries reused the same emulator after a boot timeout, so every setup attempt waited on the same wedged instance. Restart the script-launched emulator when it is not booted before each setup retry. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
kubaflo
temporarily deployed
to
copilot-pat-pool
November 18, 2026 13:08 — with
GitHub Actions
Inactive
Contributor
|
🚀 Dogfood this PR with:
curl -fsSL https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.sh | bash -s -- 40381Or
iex "& { $(irm https://raw.githubusercontent.com/dotnet/maui/main/eng/scripts/get-maui-pr.ps1) } 40381" |
kubaflo
temporarily deployed
to
copilot-pat-pool
November 18, 2026 13:08 — with
GitHub Actions
Inactive
This comment has been minimized.
This comment has been minimized.
kubaflo
temporarily deployed
to
copilot-pat-pool
November 18, 2026 13:09 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
November 18, 2026 13:12 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
November 18, 2026 13:14 — with
GitHub Actions
Inactive
kubaflo
temporarily deployed
to
copilot-pat-pool
November 18, 2026 13:14 — with
GitHub Actions
Inactive
1 task
SuthiYuvaraj
pushed a commit
to SuthiYuvaraj/maui
that referenced
this pull request
Nov 23, 2026
…up (dotnet#40381) <!-- 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 Android UI test jobs can lose all tests when the emulator wedges before it finishes booting. `uitest-prepare` already retries five times (`RunUITestSetupWithRetry`), but each retry reuses the same emulator. Every attempt waits another 600 s on that wedged instance. The restart added in dotnet#40273 runs only before test attempts, not before setup retries. Examples: - net11 UI build 1687571, Android API30 Shadow (log 6089): the emulator shows `offline` and then "no devices" for about an hour. All 5 setup attempts wait on the same process, which stays alive until final cleanup. No tests run. - Candidate UI build 1686311 CV2 (log 3682) has the same five attempts with no relaunch. There the device was stuck `unauthorized`. Change (`eng/devices/android.cake`): - I extracted the existing dotnet#40273 restart logic into `RestartEmulatorIfNotBooted(nextStep)`. - `uitest-prepare` calls it before setup attempts 2–5. - It restarts only an emulator this script launched, and only when `sys.boot_completed` is not set. Booted devices and externally provided devices are untouched. - `EnsureDeviceForUITestAttempt` keeps its behavior. The root cause of the emulator wedge is unknown. This change only lets the retries recover from it. ### Validation Local, API30 `google_apis_playstore` arm64 AVD, with CI retries enabled (`AGENT_NAME` set) and an isolated ADB server and home directory. To simulate the wedge, a watcher sends SIGSTOP to the emulator process 2 s after launch. This reproduces the CI shape: adb shows `device offline` and the boot wait fails at 600 s. - **Baseline (net11 `android.cake`):** attempt 1 failed with "The emulator did not finish booting in time". Attempt 2 waited again on the same stopped PID, with no relaunch. **Red.** - **This PR:** attempt 1 failed the same way. Then "The Android emulator is not booted; restarting it before retrying UI test setup." The emulator was killed and relaunched, booted in 15 s, and the APK installed. Exit 0. **Green.** - **Control (no wedge):** normal boot, no restart. Exit 0. The `unauthorized` mode (log 3682) was not reproduced locally. A relaunch is expected to help it as well, but that is not validated. ### Issues Fixed Fixes net11 Android UI test jobs lost to an emulator that wedges during boot (no tracking issue). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
SuthiYuvaraj
pushed a commit
to SuthiYuvaraj/maui
that referenced
this pull request
Nov 23, 2026
…up (dotnet#40381) <!-- 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 Android UI test jobs can lose all tests when the emulator wedges before it finishes booting. `uitest-prepare` already retries five times (`RunUITestSetupWithRetry`), but each retry reuses the same emulator. Every attempt waits another 600 s on that wedged instance. The restart added in dotnet#40273 runs only before test attempts, not before setup retries. Examples: - net11 UI build 1687571, Android API30 Shadow (log 6089): the emulator shows `offline` and then "no devices" for about an hour. All 5 setup attempts wait on the same process, which stays alive until final cleanup. No tests run. - Candidate UI build 1686311 CV2 (log 3682) has the same five attempts with no relaunch. There the device was stuck `unauthorized`. Change (`eng/devices/android.cake`): - I extracted the existing dotnet#40273 restart logic into `RestartEmulatorIfNotBooted(nextStep)`. - `uitest-prepare` calls it before setup attempts 2–5. - It restarts only an emulator this script launched, and only when `sys.boot_completed` is not set. Booted devices and externally provided devices are untouched. - `EnsureDeviceForUITestAttempt` keeps its behavior. The root cause of the emulator wedge is unknown. This change only lets the retries recover from it. ### Validation Local, API30 `google_apis_playstore` arm64 AVD, with CI retries enabled (`AGENT_NAME` set) and an isolated ADB server and home directory. To simulate the wedge, a watcher sends SIGSTOP to the emulator process 2 s after launch. This reproduces the CI shape: adb shows `device offline` and the boot wait fails at 600 s. - **Baseline (net11 `android.cake`):** attempt 1 failed with "The emulator did not finish booting in time". Attempt 2 waited again on the same stopped PID, with no relaunch. **Red.** - **This PR:** attempt 1 failed the same way. Then "The Android emulator is not booted; restarting it before retrying UI test setup." The emulator was killed and relaunched, booted in 15 s, and the APK installed. Exit 0. **Green.** - **Control (no wedge):** normal boot, no restart. Exit 0. The `unauthorized` mode (log 3682) was not reproduced locally. A relaunch is expected to help it as well, but that is not validated. ### Issues Fixed Fixes net11 Android UI test jobs lost to an emulator that wedges during boot (no tracking issue). 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
…up (dotnet#40381) <!-- 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 Android UI test jobs can lose all tests when the emulator wedges before it finishes booting. `uitest-prepare` already retries five times (`RunUITestSetupWithRetry`), but each retry reuses the same emulator. Every attempt waits another 600 s on that wedged instance. The restart added in dotnet#40273 runs only before test attempts, not before setup retries. Examples: - net11 UI build 1687571, Android API30 Shadow (log 6089): the emulator shows `offline` and then "no devices" for about an hour. All 5 setup attempts wait on the same process, which stays alive until final cleanup. No tests run. - Candidate UI build 1686311 CV2 (log 3682) has the same five attempts with no relaunch. There the device was stuck `unauthorized`. Change (`eng/devices/android.cake`): - I extracted the existing dotnet#40273 restart logic into `RestartEmulatorIfNotBooted(nextStep)`. - `uitest-prepare` calls it before setup attempts 2–5. - It restarts only an emulator this script launched, and only when `sys.boot_completed` is not set. Booted devices and externally provided devices are untouched. - `EnsureDeviceForUITestAttempt` keeps its behavior. The root cause of the emulator wedge is unknown. This change only lets the retries recover from it. ### Validation Local, API30 `google_apis_playstore` arm64 AVD, with CI retries enabled (`AGENT_NAME` set) and an isolated ADB server and home directory. To simulate the wedge, a watcher sends SIGSTOP to the emulator process 2 s after launch. This reproduces the CI shape: adb shows `device offline` and the boot wait fails at 600 s. - **Baseline (net11 `android.cake`):** attempt 1 failed with "The emulator did not finish booting in time". Attempt 2 waited again on the same stopped PID, with no relaunch. **Red.** - **This PR:** attempt 1 failed the same way. Then "The Android emulator is not booted; restarting it before retrying UI test setup." The emulator was killed and relaunched, booted in 15 s, and the APK installed. Exit 0. **Green.** - **Control (no wedge):** normal boot, no restart. Exit 0. The `unauthorized` mode (log 3682) was not reproduced locally. A relaunch is expected to help it as well, but that is not validated. ### Issues Fixed Fixes net11 Android UI test jobs lost to an emulator that wedges during boot (no tracking issue). Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
This branch was previously deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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
mainnet11, for reviewFor .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
Android UI test jobs can lose all tests when the emulator wedges before it finishes booting.
uitest-preparealready retries five times (RunUITestSetupWithRetry), but each retry reuses the same emulator. Every attempt waits another 600 s on that wedged instance. The restart added in #40273 runs only before test attempts, not before setup retries.Examples:
offlineand then "no devices" for about an hour. All 5 setup attempts wait on the same process, which stays alive until final cleanup. No tests run.unauthorized.Change (
eng/devices/android.cake):RestartEmulatorIfNotBooted(nextStep).uitest-preparecalls it before setup attempts 2–5.sys.boot_completedis not set. Booted devices and externally provided devices are untouched.EnsureDeviceForUITestAttemptkeeps its behavior.The root cause of the emulator wedge is unknown. This change only lets the retries recover from it.
Validation
Local, API30
google_apis_playstorearm64 AVD, with CI retries enabled (AGENT_NAMEset) and an isolated ADB server and home directory. To simulate the wedge, a watcher sends SIGSTOP to the emulator process 2 s after launch. This reproduces the CI shape: adb showsdevice offlineand the boot wait fails at 600 s.android.cake): attempt 1 failed with "The emulator did not finish booting in time". Attempt 2 waited again on the same stopped PID, with no relaunch. Red.The
unauthorizedmode (log 3682) was not reproduced locally. A relaunch is expected to help it as well, but that is not validated.Issues Fixed
Fixes net11 Android UI test jobs lost to an emulator that wedges during boot (no tracking issue).