Repository navigation
Description
Part of #602.
Scope
After this PR an Android emulator's or a phone's stream sends a key frame at least every 5 seconds, also while the screen is still: the driver turns scrcpy's control channel on and sends reset video when no key frame came for 5 s.
If it goes wrong: Android streams fail to start (a control socket that hangs), or a still screen flickers every 5 s.
Technical spec
Commit 5e639b4.
Rows
- Behaviours: B3, B4, B5
- Interfaces: I4, I5
- Existing code: X7, X8, X9, X13, X18, X14 (the Android screen manual's lines)
Facts
| # | Fact | Source |
|---|---|---|
| F1 | Measured on an API 35 emulator with the vendored scrcpy-server 5.0.1, control=true, 2026-11-16: a still screen sent 0 frames in 12 s; one byte 0x11 on the control socket gave a session packet, a config packet and a key packet within 0.1 s; 16 s of scrolling at the default interval sent no key packet, and with video_codec_options=i-frame-interval:int=5 one after about 10 s. |
a probe run in the spec session (Node, adb forward to localabstract:scrcpy_<scid>), output lines 14.0 --- RESET_VIDEO / 14.1 SESSION 324 x 720 / 14.1 CONFIG 32 / 14.1 KEY 7933 |
| F2 | The input module already runs a control-only server and reads and discards its control socket. | src/drivers/android/input/device-input.ts:170-184, src/drivers/android/input/AGENTS.md |
| F3 | scrcpy 5.0.1 parses control, power_on, clipboard_autosync and video_codec_options. |
v5.0.1:server/src/main/java/com/genymobile/scrcpy/Options.java:42,62,65,422-468 |
| F4 | The slow Android stream test reads frames through readScreenFrames. |
e2e/slow-android-stream.test.ts:57, e2e/helpers/screen-frames.ts:14 |
Modules touched
src/drivers/android/screen (session.ts, scrcpy-link.ts, their tests, the shared fixture test-session.ts, whose fake adb server sends a zero byte on every accepted socket today (src/drivers/android/screen/test-session.ts:131), and AGENTS.md), e2e/slow-android-stream.test.ts. Searches: control=false, connectScrcpySocket, ALIVE_AFTER_MS, SCRCPY_SERVER_VERSION.
Rules in play
- ADR 0079 §5: Android's key-frame bound through reset video;
power_on=falseandclipboard_autosync=falsekeep "a stream changes no device setting" (src/drivers/android/screen/AGENTS.md), except a phone's existing stay-awake. src/drivers/android/screen/AGENTS.md: a stream touches only its ownscid; every adb command and connection goes through the target;closestays idempotent.
Tests
The seam is session.ts through session.test.ts, with a fake target, server and clock.
- B3: the server starts with the control channel on,
power_on=false,clipboard_autosync=falseandi-frame-interval:int=2: the arguments; the control socket connected after the video's zero byte and before the video is read, not asked for a zero byte; a failed control connect; a phone'sstay_awake; the control bytes discarded; the control socket ending beforeclose. - B4: no key frame for 4 s sends reset video, leaving about 1 s for the emulator to answer it inside the 5 s promise: a still screen (reset at 4 s and 8 s); a key frame at 3 s (no reset at 4 s); a failed write; the session after a reset writes meta, description, key frame. B5's still phase counts key frames, not
aliveframes, since a 4 s reset leaves no 5 s silence. (decided in delivery, confirmed by the maintainer) - B5: a viewer of a still Android emulator gets a key frame at least every 5 s: measured from 15 s after the first key frame, a still home screen gives at least 4 key frames, no gap over 5.5 s (slow lane). A freshly booted emulator answers its first resets 2 to 5 s late, so a joiner in its first 15 s can wait up to about 9 s; the Android screen manual lists it as a Known gap. (decided in delivery, pending the maintainer)
Done when
pnpm test:changedpasses, with the B3 and B4 cases insrc/drivers/android/screen/session.test.ts.- Slow lane:
scripts/slow-e2e.sh e2e/slow-android-stream.test.tspasses with the B5 case, on a real emulator, and its existing case still finds no server or jar left once the viewer goes. src/drivers/android/screen/AGENTS.mdnames the control socket and the reset, drops the gap "Key frames come at scrcpy's default interval", and rewrites the rule line "scrcpy sends nothing for a still screen" to name the reset, keeping itsaliveframe rule.
Out of scope
- The device input's own server: unchanged.
Depends on
Written by an agent.
Activity
test: no key frame for 5 s sends reset video (#1601)
feat(android-screen): a stream with no key frame for 5 s sends reset …
refactor(android-screen): keep the reset interval private (#1601)
test: the reset timer and the control socket go with the session (#1601)
fix: the control socket's order is pinned, and an abort names the sta…
docs: the screen manuals hold no copied value (#1601)
docs: the screen manuals fit the manual budgets (#1601)
chore(stack): merge task/1600 into the screen branch (#1601)
docs(android): trim the screen manual under the manuals budget (#1601)
V3RON commentedon Nov 16, 2026
Handoff
Done: #1610 is built, audited and reviewed (round 1 on 09c3a0b, round 2 on 74bc0c7). Three blocking findings were fixed: the control-before-video order test, the false "within 15 s" start error, and copied values in the Android screen manual. It merged task/1600, which carries the iOS manual decision on #1600. The PR is ready in the #602 stack and labelled
needs-hardware.Not done: Done when line 2, the slow-lane B5 case. Lane run 1 failed during lease setup (
PROVISION_FAILED "Timed out waiting for device to boot") before any assertion. Run 2 was refused at 15.0 GiB free, where the lane needs 15.Findings: none open.
Blocked on: a slow-lane run on a machine with room (
/verify-hardware 1610). A boot timeout there again would need a look at the emulator, not this diff.Written by an agent.
6 remaining items
fix(android): the reset video goes after 4 s without a key frame, and…
V3RON commentedon Nov 16, 2026
Handoff
Done: code, review (round 2 passed, 3 blocking fixed) and two hardware-fix runs on #1610 at 0395ac7. The reset fires after 4 s.
Not done: the Android slow-lane line (B5 bound of 5.5 s between key frames, and no server or jar left).
Findings: two lane runs on 2026-11-16 failed with the load average at 13 to 23, from
tscin another worktree and from Spotlight. Gaps were 7305/6419 ms and 8057/6547 ms; every other gap was 4.1 to 4.9 s. The hardware-fix run found no defect in the repo. The slow gaps are mostly the first one after the stream opens. If a quiet host still fails, look at the first reset.Blocked on: a slow-lane run on a quiet host (load under about 6):
scripts/slow-e2e.sh e2e/slow-android-stream.test.ts, then a fix-check over 38e87bb..head. #1614 and #1617 sit above it in the stack.Written by an agent.
test(e2e): the Android still-screen test measures key frame gaps afte…
docs: the ADR names the 4 s reset, and the screen manual drops copied…
docs: merge origin/task/1600 and keep one 4 s Android reset line in A…
docs: drop the passed slow-lane Known gap and state the 4 s reset wit…
feat(android-screen): Android streams send a key frame at least every…