Repository navigation
ci(android): Dismiss the ANR dialog that steals the keyboard - #26118
MartinZikmund merged 1 commit into
Conversation
Xiaoy312
left a comment
There was a problem hiding this comment.
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
mCurrentFocusitself wasNexusLauncherActivity. 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 inordispatching timed outline, 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
onStartInputfor the app, keyboard shown). - At 12:08:30.8 a
com.android.systemuiwindow took input focus and kept it until the app exited. - From then on:
ClipboardService: … application is not in focus, and everyshowSoftInputwas "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.
- In Skia shard 0 of 243954, the IME served the app for about 75 s after launch (several
- 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 RespondingbeforeLauncheris correct, since the first match wins. CLOSE_SYSTEM_DIALOGSdoes close ANR dialogs:BaseErrorDialogregisters a receiver that callscloseDialog(). Note this force-closes the hung process, which is fine for System UI at boot.- The new
echo "…$(…)"line is safe underset -euo pipefail.
6c31a0b to
f04b02e
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
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:
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]>
f04b02e to
430615e
Compare
|
🤖 Your WebAssembly Sample App stage site is ready! Visit it here: |
|
Queue requested — the merge queue status continues in this comment ↓. |
|
/azp run |
|
Azure Pipelines: Successfully started running 1 pipeline(s). 1 pipeline(s) were filtered out due to trigger conditions. |
|
The build 245217 found UI Test snapshots differences: Details
|
|
@Mergifyio queue |
❌ Left the queue ·
|
GitHub Issue: part of #9080
PR Type:
🏗️ Build or CI related changes
What changed? 🚀
The Android
Given_TextBoxtouch-lock tests time out waiting for the keyboard on the API 36 lanes (When_Touch_Tap_Does_Not_Lock_ScrollViewer_Androidand 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.shreads bothmCurrentFocusandmFocusedApp, and matchedLauncher(frommFocusedApp) before itsNot Respondingcase. 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: everyshowSoftInputfrom 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.shsetshide_error_dialogsonce the device has booted, checks for an ANR before the launcher, and closes it withCLOSE_SYSTEM_DIALOGSinstead of blind D-pad presses.android-run-skia-runtime-tests.shcloses 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_playstorerev 7 emulator with CI's flags, CI's master APK from build 243930, which predates c9abdea so its tests still require the keyboard):Given_TextBoxshowSoftInputnot servedWith the scripts, the dialog didn't appear at all:
hide_error_dialogswas 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 ✅
Screenshots Compare Test Runresults.🤖 Generated with Claude Code