Repository navigation
fix(ci): wait longer for the Android keyguard and repeat a dropped dismissal - #2612
michal-e2e wants to merge 3 commits into
Conversation
… dropped dismissal The readiness script failed 16 of 481 finished Android jobs since #2394, all at its single five-second budget. Two causes, both reproduced on a loaded local API 36 emulator: - The keyguard service reports secure=true until it connects, which can take most of the five seconds. The script now waits up to 30 seconds for non-secure state; a healthy CI run still finishes in under five. - The emulator can drop `wm dismiss-keyguard` sent right after that: the keyguard stays up, non-secure, for at least 30 seconds, and a second request dismisses it at once. The script now repeats the request once a second while the keyguard still shows and is known to be non-secure, within its own ten-second budget that starts before the first request. A secure keyguard still stops the script without a dismissal, and it never enters credentials. The tests run on a fake clock that moves only on waits and adb calls, so a refusal is the script's own exit, not the test timeout, and the request spacing and deadlines are asserted directly. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… requests after a late settle Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Every fake adb call starts a real process. The two late-settle cases made about 53 and 72 of them inside a 15-second limit, which a slow runner could miss. They now make about 10 and 17, assert that the first request comes after five seconds, and the limit is 60 seconds. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
There was a problem hiding this comment.
1 issue found across 2 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name=".github/scripts/prepare-android-emulator.mjs">
<violation number="1" location=".github/scripts/prepare-android-emulator.mjs:70">
P2: A slow retry resets this timer only after `shell()` returns, adding its full latency before the next one-second wait. Record the timestamp before `shell()` so retries follow request-start cadence.</violation>
</file>
Reply with feedback, questions, or to request a fix.
View guided diff | Turn on auto-fix | Re-trigger cubic
| shell('wm', 'dismiss-keyguard'); | ||
| dismissedAt = Date.now(); |
There was a problem hiding this comment.
P2: A slow retry resets this timer only after shell() returns, adding its full latency before the next one-second wait. Record the timestamp before shell() so retries follow request-start cadence.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. When an issue isn't valid or won't be fixed in this PR, reply in its thread with the reason and then resolve the thread. At .github/scripts/prepare-android-emulator.mjs, line 70:
<comment>A slow retry resets this timer only after `shell()` returns, adding its full latency before the next one-second wait. Record the timestamp before `shell()` so retries follow request-start cadence.</comment>
<file context>
@@ -39,22 +47,29 @@ shell('svc', 'power', 'stayon', 'true');
- if (Date.now() >= deadline) throw new Error('Emulator keyguard did not dismiss with the screen on');
+ if (Date.now() >= readinessDeadline) throw new Error('Emulator keyguard did not dismiss with the screen on');
+ if (state.showing === 'true' && Date.now() - dismissedAt >= REDISMISS_MS) {
+ shell('wm', 'dismiss-keyguard');
+ dismissedAt = Date.now();
+ }
</file context>
| shell('wm', 'dismiss-keyguard'); | |
| dismissedAt = Date.now(); | |
| dismissedAt = Date.now(); | |
| shell('wm', 'dismiss-keyguard'); |
|
No actionable comments were generated in the recent review. Walkthrough
Change: Bug fix Merge Risk:
|
okwasniewski
left a comment
There was a problem hiding this comment.
Automated review (AI triage pass), not yet read by a maintainer.
Reviewed 97604c5f7. The script logic is sound: the secure-lock refusal is intact, every failure still exits 1 with a named error, and the tests catch the regressions they claim to. Blocking item: CI never ran on this head.
Must fix
- No
specormobilerun exists for97604c5f7. Onlypr-policyandreview-verdictran (gh api actions/runs?head_sha=...), and the labeler never added size or team labels either, so thepull_requestevent seems lost. The Android jobs inmobile.ymlare the only real check of this change, and the PR body lists them as not verified. Push again or close and reopen so they run.
Verified
- Secure refusal: a re-dismiss at :69-72 only runs after the same iteration's fresh read passed :66 and the deadline check at :68. No credentials are entered.
- Fails loudly: every exit path throws.
shell()still caps each adb call at the remaining deadline (:19-24). Worst case is about 45 s of setup calls + 30 s settle + 10 s dismissal, and that is bounded. - Tests: 18/18 pass locally. With main's script in place 9 fail. With only the re-dismiss mutated out, 3 fail (locked, dropped, slow-dropped).
Should fix
- The PR shows that a dismissal gets dropped, but not why. AOSP drops it silently when the delegate is not yet showing (PhoneWindowManager.dismissKeyguardLw:
if (mKeyguardDelegate != null && mKeyguardDelegate.isShowing()), no else for a null callback). It also drops it with a log line in KeyguardViewMediator (Ignoring request to DISMISS because mShowing=false,Ignoring dismiss because we're already going away). The first request at :57-59 goes out onsecure=falsealone, without checkingshowing. If the stuck boots are themShowing=falsecase, the fix is to send the first dismissal only once a read showsshowing=true. The repeat is still acceptable as-is, since it only fires after a freshshowing=true, secure=falseread. But please runlogcat -d -s KeyguardViewMediatoron one stuck boot and name the cause in the comment at :61-63.
For the maintainer
- Is a state-gated repeat of
wm dismiss-keyguardacceptable under the no-heuristics policy, or should it wait until the drop cause is named (Should fix 1)?
What
The Android emulator readiness step in
mobile.ymlno longer fails a job because the emulator is slow. It waits up to 30 seconds for the lock screen to report non-secure, and it sendswm dismiss-keyguardagain when the emulator drops the request. A secure lock screen still stops the job before any dismissal, and the script never enters credentials.Why
Since #2394 merged, 16 of 481 finished Android jobs failed in
.github/scripts/prepare-android-emulator.mjs, counted on 2 December. All 16 used up the script's single five-second budget and ended 6.5 to 9.7 seconds after the script started. The 29 passing jobs I sampled finished the whole script in 1.6 to 4.6 seconds.On a loaded local API 36 emulator I reproduced the two places it failed.
dumpsys window policyreportssecure=trueuntil the keyguard service connects, which took up to about 15 seconds. It then turnssecure=falseby itself, anddumpsys lock_settingsshowsCredentialType: NONE.wm dismiss-keyguard. I kept 6 stuck boots alive. In each one the lock screen still showed, non-secure, 30 seconds later, and a secondwm dismiss-keyguardcleared it at once.#2394 never repeats the dismissal. Its safety rules are that the script never dismisses a secure lock screen and never enters credentials. A repeat sent only after a fresh non-secure read keeps those two rules.
How it works
.github/scripts/prepare-android-emulator.mjs:5-12replaces the one five-second budget with four limits. The lock screen has 30 seconds to report non-secure, the dismissal has 10 seconds, requests are 1 second apart, and each setup call before the keyguard checks has 15 seconds. One setup call took 4.6 seconds locally. The budget error now readsEmulator readiness exceeded its budget, where it saidexceeded five seconds.:50-56waits forsecure=falseas before, with the 30-second limit.:57-59starts the 10-second dismissal budget before the first request, so a late non-secure read leaves the dismissal its full time.:64-74polls as before. While the lock screen still shows and reads non-secure, the script sends the request again once a second. Once the lock screen is hidden, the script only waits for the screen to turn on. A secure read still fails at once at:66.scripts/android-emulator-readiness.test.tsruns the workflow's real command against a stateful fakeadb, on a fake clock that moves only on waits andadbcalls. Each refusal asserts exit code 1 and its error, so a test timeout cannot pass a case. Every refusal but the still-locked one also asserts its exact number of requests. The two late cases use three secure reads of 2.5 seconds each, which keeps every case to at most 45adbprocesses inside a 60-second limit. The new cases are:The still-locked case checks that requests are 1.0 to 1.4 seconds apart and stop before the 10-second limit.
Issue
None filed. This follows #2394.
Verified
Ran it locally: yes, on an API 36
google_apisarm64 emulator with thepixel_7profile and CI's emulator options. I slowed it to one emulator core and kept half the host's CPUs busy.mainmainpassed 12 of 12. The failures come from load, as on CI.node --test scripts/android-emulator-readiness.test.tspasses 18 of 18. Withmain's script in place, 9 of the 18 fail. With only the budget error reworded inmain's script, 6 still fail, so 3 of the 9 fail on the error text alone.throwinside a loop, at:53and:68.shell()at:19-24still stops the script at the same deadline, as it does onmain, and only the error text changes.Not verified: a hosted CI run of this head, which this PR's mobile workflow provides, and an x86 KVM emulator like CI's.
Checklist
pnpm changeset) for any change to a published package, or the change is testbed, docs, or CI only.!, the changeset body names what breaks and what replaces it, and the deprecation warning landed a window earlier (stability policy in CONTRIBUTING.md).docs/**/*.mdxpage for the behavior, andskills/e2e/if the skill describes it..d.tsreviewed,tests/types/sdk-types.tsupdated; wire change edits the schema and both fixtures.e2e/engine): changesets fore2e,@e2e-dev/web, and@e2e-dev/mobile.🤖 Generated with Claude Code
Summary by CodeRabbit