Skip to content

ci(android): Dismiss the ANR dialog that steals the keyboard - #26118

Merged
MartinZikmund merged 1 commit into
unoplatform:masterfrom
ramezgerges:dev/rara/android-ci-dismiss-anr-dialog
Nov 17, 2026
Merged

MartinZikmund merged 1 commit into
unoplatform:masterfrom
ramezgerges:dev/rara/android-ci-dismiss-anr-dialog

Conversation

@ramezgerges

Copy link
Copy Markdown
Contributor

GitHub Issue: part of #9080

PR Type:

🏗️ Build or CI related changes

What changed? 🚀

The Android Given_TextBox touch-lock tests time out waiting for the keyboard on the API 36 lanes (When_Touch_Tap_Does_Not_Lock_ScrollViewer_Android and its siblings on Android Skia shards 0 and 4). Master worked around the symptom in c9abdea by continuing without a keyboard. This PR fixes the cause.

Cause. During the headless boot, System UI ANRs, and its "isn't responding" dialog keeps window focus while the launcher stays the focused app. android-uitest-wait-systemui.sh reads both mCurrentFocus and mFocusedApp, and matched Launcher (from mFocusedApp) before its Not Responding case. So it reported the launcher ready and left the dialog up for the whole run. The app is still the focused activity and tests inject pointers internally, so most tests pass. But the IME only serves the focused window: every showSoftInput from the app is ignored (Ignoring showSoftInput() as view=…UnoVulkanView… is not served, ImeTracker onFailed at PHASE_CLIENT_VIEW_SERVED), and the keyboard never shows.

Fix.

  • android-uitest-wait-systemui.sh sets hide_error_dialogs once the device has booted, checks for an ANR before the launcher, and closes it with CLOSE_SYSTEM_DIALOGS instead of blind D-pad presses.
  • android-run-skia-runtime-tests.sh closes system dialogs once more right before starting the app, and logs the focused window, so a stolen focus shows in the job log.

Both Android lanes use these scripts (API 36 Skia/WebGPU, API 34 NativeAOT).

Validation (local API 36 google_apis_playstore rev 7 emulator with CI's flags, CI's master APK from build 243930, which predates c9abdea so its tests still require the keyboard):

Given_TextBox showSoftInput not served Keyboard shown
As CI runs it today (ANR dialog focused) 307 passed, 5 failed (the touch-lock tests) 653 of 653 0
Dialogs closed before launch 312 passed, 0 failed 0 of 866 198
With these scripts (5 touch-lock tests) 5 passed 0 of 24 5

With the scripts, the dialog didn't appear at all: hide_error_dialogs was set right after boot, and the launcher held window focus before the app started. Once this is in, c9abdea's fallback could go back to failing when the keyboard doesn't show.

PR Checklist ✅

🤖 Generated with Claude Code

@github-actions github-actions Bot added the area/build Categorizes an issue or PR as relevant to build infrastructure label Nov 5, 2026

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

The scripts look mostly sound, but CI's own logs don't show the ANR this PR is fixing. I checked the job logs and device logcats of master build 243954 and of this PR's base build 243930 (the APK used for the local validation). Both predate c9abdea.

1. CI loses focus partway through the run, not at boot

  • Launcher check: on all 16 Android jobs of 243954, "Launcher is ready" fired because mCurrentFocus itself was NexusLauncherActivity. It wasn't the launcher as focused app behind a dialog.
  • No ANR: none of the shard-0 logcats I read (Skia, WebGPU and NativeAOT of 243954; Skia of 243930) has an ANR in or dispatching timed out line, and the system buffer covers the whole boot.
  • The keyboard works first:
    • In Skia shard 0 of 243954, the IME served the app for about 75 s after launch (several onStartInput for the app, keyboard shown).
    • At 12:08:30.8 a com.android.systemui window took input focus and kept it until the app exited.
    • From then on: ClipboardService: … application is not in focus, and every showSoftInput was "not served" (246 times).
    • 243930 is the same: about 2 minutes of normal IME use (keyboard shown 6 times), then "not served" from 11:35:17.
  • Fixed point in the test order: in Skia and WebGPU shard 0 of 243954, focus goes at the same place: after the CheckBox theme tests (When_App_Override_Checked_*, When_ThemeChanged_WithBrushBinding_AndColorPath), as the ComboBox tests start. That would explain why a job retry clears it: the retry runs only the failed tests, so whatever ran earlier doesn't.

So neither the CLOSE_SYSTEM_DIALOGS before launch nor the reordered ANR case can change the CI result. The local emulator seems to have hit a different problem than CI does.

2. hide_error_dialogs=1 turns an app ANR into a kill

android-uitest-wait-systemui.sh: with this setting, ActivityTaskManagerService.shouldShowDialogs returns false, so canShowErrorDialogs is false. AppErrors.handleShowAnrUi then sets doKill instead of showing the dialog ("Just kill the app if there is no dialog to be shown").

Today a SamplesApp ANR leaves a dialog up and the run continues. With this change the app is killed, the shard has no results XML and no failed-test list, and the retry reruns the whole suite. None of the logs above had an ANR, so this is a risk rather than something observed. Consider setting it back to 0 before am start, or dropping it: CLOSE_SYSTEM_DIALOGS already handles a boot-time dialog.

3. Keep c9abdea's fallback

Given the above, making those tests fail again when the keyboard doesn't show would bring back the shard 0/4 failures.

4. Suggestion: log focus during the run

The new focused-window line only runs before launch. Logging mCurrentFocus inside the existing 15 s wait loop in android-run-skia-runtime-tests.sh would name the System UI window that takes focus mid-run. Only the last interim screenshot survives, and it just shows the launcher after the app exits.

What looks right

  • Checking Not Responding before Launcher is correct, since the first match wins.
  • CLOSE_SYSTEM_DIALOGS does close ANR dialogs: BaseErrorDialog registers a receiver that calls closeDialog(). Note this force-closes the hung process, which is fine for System UI at boot.
  • The new echo "…$(…)" line is safe under set -euo pipefail.

@ramezgerges
ramezgerges force-pushed the dev/rara/android-ci-dismiss-anr-dialog branch from 6c31a0b to f04b02e Compare November 6, 2026 16:37
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@Xiaoy312

Xiaoy312 commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Friendly nudge on my comment from yesterday: the force-push today looks like a rebase only (the scripts match the version I reviewed). Could you reply to the points there before this moves forward? Mainly:

  1. CI's logcats show focus lost mid-run, after the CheckBox theme tests, and no ANR at boot. So it isn't clear that this changes the CI result.
  2. hide_error_dialogs=1 makes a SamplesApp ANR kill the app instead of showing a dialog.

Also, while c9abdea's keyboard fallback is on master, a green CI on this PR doesn't show the fix works. If you want CI to prove it, the fallback would need to go in the same PR, as long as point 1 holds up.

On the API 36 emulator, System UI ANRs during the headless boot and its
dialog keeps window focus. The launcher check matched the focused app
before the ANR case, so the dialog stayed, and every showSoftInput from
the app was ignored as "not served": the keyboard never showed.

Error dialogs are now hidden once booted, an ANR is checked before the
launcher and closed with CLOSE_SYSTEM_DIALOGS, and the focused window is
logged before the app starts.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
@MartinZikmund
MartinZikmund force-pushed the dev/rara/android-ci-dismiss-anr-dialog branch from f04b02e to 430615e Compare November 10, 2026 09:08
@unodevops

Copy link
Copy Markdown
Contributor

🤖 Your WebAssembly Sample App stage site is ready! Visit it here:

@mergify

mergify Bot commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Queue requested — the merge queue status continues in this comment ↓.

@ramezgerges

Copy link
Copy Markdown
Contributor Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 1 pipeline(s).
1 pipeline(s) were filtered out due to trigger conditions.

@nventive-devops

Copy link
Copy Markdown
Contributor

The build 245217 found UI Test snapshots differences: skia-linux-screenshots: 209, skia-windows-screenshots: 282

Details
  • skia-linux-screenshots: 209 changed over 2494

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • AutomationProperties_AutomationId.png
    • ButtonClippingTestsControl.png-dark
    • ButtonClippingTestsControl.png
    • Buttons.png-dark
    • Buttons.png
    • AppWindowTitleBar Properties.png
    • AutomationProperties_AutomationId.png-dark
    • BenchmarkDotNet.png-dark
    • BenchmarkDotNet.png
    • AutomationProperties_StructureAndProps.png-dark
    • AutomationProperties_StructureAndProps.png
    • Basics.png-dark
    • Basics.png
    • Border_CornerRadius_Binding.png-dark
  • skia-windows-screenshots: 282 changed over 2494

    🚨🚨 Comparison Details (first 20) 🚨🚨
    • AnimatedVisualsTestbedPage.png-dark
    • AutomationProperties_StructureAndProps.png-dark
    • Border_CornerRadius_Binding.png-dark
    • Border_CornerRadius_Binding.png
    • Border_CornerRadius_BorderThickness.png-dark
    • Border_CornerRadius_BorderThickness.png
    • BreadcrumbBarPage.png-dark
    • BreadcrumbBarPage.png
    • CalendarView_Theming.png-dark
    • CalendarView_Theming.png
    • AutomationProperties_StructureAndProps.png
    • BasicAcrylicBrushTest.png-dark
    • BasicAcrylicBrushTest.png
    • CompositionPath.png-dark
    • CompositionPath.png
    • AnimatedVisualsTestbedPage.png
    • AppWindowTitleBar Properties.png-dark
    • BasicAcrylicBrushTest2.png-dark
    • BasicAcrylicBrushTest2.png
    • ButtonClippingTestsControl.png-dark

@ramezgerges

Copy link
Copy Markdown
Contributor Author

@Mergifyio queue

@mergify

mergify Bot commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

❌ Left the queue · Uno.UI - CI (Tests - WinAppSDK Runtime Tests) fails with this pull request

3 h 43 min in the queue, 1 h 16 min of it CI.

So far

The failure is in this pull request. It failed tested alone on top of master.

Reason

The merge conditions cannot be satisfied due to failing checks

  • Uno.UI - CI

Failing checks:

To get back in the queue

  • Push a fix: the pull request is queued again once its queue conditions match.
  • If the failure is a flake, tick the box below to queue it again as it is.

Merge conditions not met when it left the queue

  • any of · required by GitHub repository ruleset rule master - PR requirements:
    • check-neutral = Uno.UI - CI
    • check-skipped = Uno.UI - CI
    • check-success = Uno.UI - CI

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request
3 merge conditions met
  • #review-threads-unresolved = 0 · required by GitHub repository ruleset rule Copilot
  • github-review-approved · required by GitHub repository ruleset rule Copilot and GitHub repository ruleset rule master - PR requirements
  • any of · required by GitHub repository ruleset rule master - PR requirements:
    • check-neutral = Uno.UI - docs
    • check-skipped = Uno.UI - docs
    • check-success = Uno.UI - docs

Times in UTC · dashboard · how the merge queue works

@mergify mergify Bot added the queued label Nov 16, 2026
@mergify mergify Bot added dequeued and removed queued labels Nov 16, 2026
@MartinZikmund
MartinZikmund merged commit 97b0b25 into unoplatform:master Nov 17, 2026
83 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/build Categorizes an issue or PR as relevant to build infrastructure dequeued

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants