Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(devices): refresh backlogged iOS video and require input admission #18326

Mergedjuliusmarmingemerged 1 commit intomain fromrefs/pull/18326/headmerged by juliusmarminge View on GitHub

juliusmarmingecommented

An 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.

Before: frozen Settings. After: current Home screen with 3D retained.

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.


Devin Review
    1. github-actions[bot](GitHub profile, opens in a new tab) added labelsvouch:trusted

    2. juliusmarminge added labelsmacroscope-review

    3. Approvability

      Verdict: Approved at 550d9a0

      Macroscope'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).
    4. Review in Change Stack →

      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.ts
      • apps/server/src/device/deviceToolVersions.json
      • apps/web/src/components/device/DeviceStreamView.test.tsx
      • packages/client-runtime/src/device/duoStream.test.ts
      • packages/client-runtime/src/device/stream.test.ts
      • packages/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.json
      The 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-device version changes to 0.21.25.
      Decoder backlog recovery
      packages/client-runtime/src/device/stream.ts, packages/client-runtime/src/device/stream.test.ts
      When 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 550d9

      The 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 | Passed 4
      ✅ Passed checks (4 passed)
      Check nameStatusExplanation
      Title checkPassedThe title clearly summarizes both primary changes: iOS video backlog recovery and input admission enforcement.
      Description checkPassedThe 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 checkPassedCheck skipped because no linked issues were found for this pull request.
      Out of Scope Changes checkPassedCheck 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.
    5. Thread transfer impact

      ✅ Thread transfer remains within every enforced ceiling.

      ProviderMetricMain baselineThis PRImpactPR ceiling
      CodexTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      CodexThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      CodexLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      CodexLive turn WebSocket decoded20.9 KiB20.9 KiB0 B (0.0%)29.3 KiB✅
      CodexLive turn messages220 (0.0%)8✅
      ClaudeTotal thread wire5.0 KiB5.0 KiB0 B (0.0%)6.8 KiB✅
      ClaudeThread snapshot wire3.8 KiB3.8 KiB0 B (0.0%)4.9 KiB✅
      ClaudeLive turn WebSocket wire1.2 KiB1.2 KiB0 B (0.0%)2.0 KiB✅
      ClaudeLive turn WebSocket decoded21.2 KiB21.2 KiB0 B (0.0%)29.3 KiB✅
      ClaudeLive turn messages110 (0.0%)8✅

      Baseline: bed9239 · PR result: 550d9a0 · Source CI: success

      Scenario 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.

    6. juliusmarminge merged this5cbe82a

    7. juliusmarminge closed this

Sign in to join this conversation.