Skip to content

flaky: slow-android-stream still-screen key frames stay fewer than 4 after the first 15 s on a slow-lane emulator #1762

Done

Description

@V3RON

e2e/slow-android-stream.test.ts, "streams a leased emulator's screen as meta, an avcC description and an H.264 key frame, … keeps a still screen open 15 s past the silence bound with a key frame at least every 5.5 s, …" fails in the slow lane with AssertionError: fewer than 4 key frames after the first 15 s of a still screen.

On 2026-11-19, on one macOS slow-lane machine, two runs in a row:

The test already leaves out the first 15 s because a just-booted emulator answers its first resets in 2 to 5 s. In these runs, the 30 s after that still did not settle to about one key frame per reset. It matches the screen module manual's known gap ("A fresh emulator answers its first resets slowly"), lasting longer than the test allows. Whether ADR 0079 §5's 5 s bound is missed on this emulator, or only the test's settle window is too short, is not measured yet.

Written by an agent.

Activity

  1. added
    bug:new
    flaky-test
    on Nov 19, 2026
  2. self-assigned this
    on Nov 24, 2026
  3. V3RON commented on Nov 24, 2026

    @V3RON
    ContributorAuthor

    Reproduction

    src/drivers/android/screen/session-body-and-close.test.ts, "relays a still screen's key frame 4 s plus the answer after the last one when the device takes 5 s to answer reset video" (bug/1762-repro). Its fake device acts as scrcpy v5.0.1 does: a reset that comes during an answer restarts it.

    pnpm exec vitest run --project unit src/drivers/android/screen/session-body-and-close.test.ts -t "takes 5 s to answer"
    AssertionError: key frames, in ms after the open, of a still screen: expected [] to deeply equal [ 9000, 18000 ]
    

    Independent answers under 4 s would give at least 3 key frames in 30 s; the lane saw 1 and 2.

    Root cause

    Defect. src/drivers/android/screen/session.ts:379: the reset timer re-arms itself, so a still screen gets reset video every 4 s, answered or not. scrcpy answers by building a new capture and encoder, and when another reset came meanwhile it sends nothing and builds again (SurfaceEncoder.java:142 at v5.0.1, if (!captureControl.isResetRequested())). On an emulator that answers in over 4 s (the e2e's comment measured 2 to 5 s after boot), our next reset cancels each answer, so key frames stop until one fits between two resets. The manual's known gap (slow first resets) is the trigger, not the cause.

    Simplest fix

    The callback writes the reset without re-arming (this.#resetTimer = undefined for this.#armReset()); the next key frame arms it. The existing 4 s reset test's second reset at 8 s becomes none. Update session.ts:52-54 and the screen manual.

    pnpm exec vitest run --project unit src/drivers/android/
    Tests  741 passed | 1 skipped (742)
    

    Alternatives rejected

    • Retry unanswered resets after 10 s: cancels slower answers too; scrcpy never drops a reset.
    • Widen the e2e's settle window: hides it; joiners still wait.
    • Raise RESET_VIDEO_AFTER_MS: breaks ADR 0079 §5.

    Risk

    • Slow lane not run. Gaps become 4 s plus the answer, so the e2e's 5.5 s check still fails while answers exceed 1.5 s. The fix PR needs a slow-lane line for e2e/slow-android-stream.test.ts.
    • A server that never answers gets one reset, not one per 4 s; alive frames keep it open, as today.

    Fast track

    • Defect: yes
    • Fix tried: yes
    • Nothing public added or broken: yes
    • No ADR or rule changed: yes
    • One fix: yes

    Written by an agent.

  4. removed their assignment
    on Nov 24, 2026
  5. V3RON commented on Nov 24, 2026

    @V3RON
    ContributorAuthor

    Maintainer decision on the triage report (2026-11-24):

    Approved as proposed: the reset timer no longer re-arms itself; the next key frame arms it.

    The maintainer approves a slow-lane run for this fix: the fix PR carries a Hardware Done when line for e2e/slow-android-stream.test.ts. If its 5.5 s key-frame check still fails because the emulator answers slowly, stop and ask the maintainer before changing the e2e's bound.

    Written by an agent.

  6. added
    bug:ready
    and removed
    bug:new
    on Nov 24, 2026
  7. self-assigned this
    on Nov 24, 2026
  8. V3RON commented on Nov 24, 2026

    @V3RON
    ContributorAuthor

    Delivery run

    Merged: #1828 (#1762)
    Parked: none
    Waiting: none
    Decided: #1762 — 5.5 s key-frame check failed at a 4 s reset → reset wait 3 s (maintainer, option 1)

    Written by an agent.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug:readyflaky-test

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions