fix(devices): refresh backlogged iOS video and require input admission #18326
main fromrefs/pull/18326/head·merged by juliusmarminge View on GitHubAn iOS viewer that briefly falls behind can stay on an old frame while simulator input succeeds. The backlog recovery added in #17566 resets the decoder and waits for a natural keyframe, but native keyframes are spaced by frame count: an idle simulator can take minutes to produce the next one.
Reconnect only the AVCC video subscription when its decode queue backs up. The new subscription supplies a fresh keyframe, while the HID socket and 3D viewer remain connected. Also require native input admission on every socket, preserve an explicit input-unavailable state, and remove the invalid keyboard command previously sent on connection. Update agent-device to the released 0.21.25; expo-device-hub remains on the latest published 0.15.3.
Verified on a local iPhone 18 Pro simulator running iOS 27: press Home from Settings and block the browser renderer for three seconds. The baseline still displays Settings after eight seconds; the fix shows Home at the first sampled frame around 4.5 seconds and retains 3D. The temporary stall control is excluded from the change. Normal taps, swipes and navigation work in 3D; flat-view scrolling works, and switching between views retains the current screen.

Watch the eight-second before/after recording.
Validation:
- 67 focused stream, Duo, frame sink, viewer recovery, socket proxy and toolchain tests. Both new regressions fail on the baseline.
- Client-runtime and server typechecks; targeted lint and formatting.
- A five-second direct/proxied AVCC comparison delivered identical bytes, with first keyframes around 60 ms. Native input admission through T3 took 4 ms; the input barrier replied in 5 ms. This did not reproduce proxy buffering.
The stream and admission fixes live in client-runtime, shared by web/desktop and the mobile WebView. Mobile uses MJPEG on iOS, so only its input admission changes. Local browser verification covered the web viewer; native mobile and remote/relay were not exercised.
Upstream has unreleased recovery work in #296 and #297. The latter updates Expo's own client, so waiting for that release will not fix T3's custom decoder recovery.
Implemented with GPT-6.1-sol through the Codex harness.
- 1
github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted
juliusmarminge added labelsmacroscope-review
github-actions[bot](GitHub profile, opens in a new tab) added labelssize:M
Approvability#
Verdict: Approved at
550d9a0Macroscope's review found this PR approvable — This is a contained iOS device-stream fix that reconnects only stalled video feeds and requires explicit input admission while preserving existing Android and MJPEG paths. Regression tests cover the new admission and recovery behavior, with no schema, security, billing, deployment, or product-default changes.
You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).No actionable comments were generated in the recent review. 🎉
ℹ️ Recent review info
-
⚙️ Run configuration
-
- Configuration used: Path: .coderabbit.config.ts
- Review profile: CHILL
- Plan: Team
- Run ID:
2e1cb517-ad89-4aa6-a7be-6a1bcd2bebc1
📥 Commits
-
Reviewing files that changed from the base of the PR and between bed923986fbcbe8279f23b9367efde1596bde1f9 and 550d9a01854f87f28f60ef8b169ed29a20874cd9.
📒 Files selected for processing (6)
-
apps/server/src/device/DeviceHubProxy.stream.test.tsapps/server/src/device/deviceToolVersions.jsonapps/web/src/components/device/DeviceStreamView.test.tsxpackages/client-runtime/src/device/duoStream.test.tspackages/client-runtime/src/device/stream.test.tspackages/client-runtime/src/device/stream.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.
-
📝 Walkthrough
-
Walkthrough#
The stream client now requires iOS input-session admission before sending input or Duo controls. When the iOS decoder queue exceeds its limit, the AVCC feed reconnects for a fresh keyframe. Tests cover these changes and proxy frame ordering.
Changes#
Device stream behavior
Layer / File(s) Summary iOS input admission
packages/client-runtime/src/device/stream.ts,packages/client-runtime/src/device/stream.test.ts,packages/client-runtime/src/device/duoStream.test.ts,apps/web/src/components/device/DeviceStreamView.test.tsx,apps/server/src/device/DeviceHubProxy.stream.test.ts,apps/server/src/device/deviceToolVersions.jsonThe client records iOS input admission per socket and requires admission and available input before sending controls. Tests cover admission handling and proxy frame ordering. The configured agent-deviceversion changes to0.21.25.Decoder backlog recovery
packages/client-runtime/src/device/stream.ts,packages/client-runtime/src/device/stream.test.tsWhen the iOS decode queue exceeds its limit, the client aborts the AVCC request and closes the decoder. The tests check that a new feed decodes its keyframe and that output from the old decoder is not drawn. Priority: ➖ Normal
Estimated code review effort: 3 (Moderate) | ~20 minutes
Change: Bug fix
Sequence Diagram(s)#
sequenceDiagram participant DeviceStream participant IOSInputSocket participant IOSHelper IOSHelper->>IOSInputSocket: sends 0x83 admission message IOSInputSocket->>DeviceStream: delivers admission message DeviceStream->>DeviceStream: records session admission DeviceStream->>IOSInputSocket: sends input when admitted and available IOSInputSocket->>IOSHelper: forwards input command
Merge Risk: ⚪ Minimal · up to
550d9The change makes iOS video recover from a backlog by reconnecting for a fresh keyframe, and it requires input admission before sending input. No merge-blocking issue was identified. Native mobile and relay paths were not exercised by the author.
Pre-merge checks |
4-
✅ Passed checks (4 passed)
-
Check name Status Explanation Title check The title clearly summarizes both primary changes: iOS video backlog recovery and input admission enforcement. Description check The description clearly explains the problem, implementation, scope, verification results, limitations, visual evidence, and agent usage. It does not use the template headings or provide an explicit m… Linked Issues check Check skipped because no linked issues were found for this pull request. Out of Scope Changes check Check skipped because no linked issues were found for this pull request.
-
✨ Finishing Touches
-
📝 Generate docstrings
-
- Commit to this branch
- Create a new PR
🧪 Generate unit tests (beta)
-
- Commit to this branch
- Create a new PR
-
- Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment `@coderabbitai help` to get the list of available commands.-
Thread transfer impact#
✅ Thread transfer remains within every enforced ceiling.
Provider Metric Main baseline This PR Impact PR ceiling Codex Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Codex Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Codex Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Codex Live turn WebSocket decoded 20.9 KiB 20.9 KiB 0 B (0.0%) 29.3 KiB ✅ Codex Live turn messages 2 2 0 (0.0%) 8 ✅ Claude Total thread wire 5.0 KiB 5.0 KiB 0 B (0.0%) 6.8 KiB ✅ Claude Thread snapshot wire 3.8 KiB 3.8 KiB 0 B (0.0%) 4.9 KiB ✅ Claude Live turn WebSocket wire 1.2 KiB 1.2 KiB 0 B (0.0%) 2.0 KiB ✅ Claude Live turn WebSocket decoded 21.2 KiB 21.2 KiB 0 B (0.0%) 29.3 KiB ✅ Claude Live turn messages 1 1 0 (0.0%) 8 ✅ Baseline:
bed9239· PR result:550d9a0· Source CI: successScenario and decoded snapshot size
10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
- Codex decoded thread snapshot: 108.5 KiB
- Claude decoded thread snapshot: 108.8 KiB
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed.
juliusmarminge merged this5cbe82a
juliusmarminge closed this
Sign in to join this conversation.
macroscopeapp[bot](GitHub profile, opens in a new tab) approved these changes