Skip to content
Source
Sign inSign up
pingdotgg/t3code

fix(device): stop stream and clear first-frame timer on unsupported Simlock AVCC codec #48247

Opensaphid(GitHub profile, opens in a new tab)wants to merge 1 commit intomain fromrefs/pull/48247/headopened View on GitHub

Problem

In packages/client-runtime/src/device/stream.ts (readIosVideo), the serveSimOnly unsupported H.264 codec branch called setStatus("error", detail) and returned without calling fail(detail). Because start() arms frameTimer for FIRST_FRAME_TIMEOUT_MS (15 s), the timer stayed armed, left the input WebSocket open, and 15 seconds later fired fail("No video received from the device. Reconnect to try again."). On web and desktop (Electron), DeviceWorkspace.tsx (serveSimOnly={props.hostKind === "simlock"}) and ThreadPreviewMiniPlayer.tsx pass serveSimOnly: true for Simlock hosts, deviceStreamSession.ts stores each onStatus update, and DeviceStreamView.tsx renders the latest detail, overwriting the specific codec error after 15 seconds. (Mobile's DeviceStreamWebView.tsx already latches the first error, ignores later messages, and stops the WebView stream, so mobile shares the createDeviceStreamClient cleanup without reproducing the visible overwrite.)

Deterministic repro on origin/main (9a08ffb84084c441dcf4a2f595682a44632ecc89):

  • Start createDeviceStreamClient with { platform: "ios", deviceId: "test-device", serveSimOnly: true, access: { httpBase: "https://test/api/device-hub", wsBase: "wss://test/api/device-hub", credentials: true, query: {} } }, mock VideoDecoder.isConfigSupported to resolve { supported: false }, enqueue a valid AVCC description envelope (tag = 1, avcC for avc1.64001f), and advance fake timers by 15_000 ms.
  • Command: vp test run packages/client-runtime/src/device/stream.test.ts -t "stops the stream and clears the first-frame timer on unsupported Simlock AVCC codec"
  • Observed on origin/main: sockets[0].close is called 0 times, vi.getTimerCount() remains 1, and after 15_000 ms onStatus receives a second "error" with "No video received from the device. Reconnect to try again.".
  • Expected: fail(detail) stops the client (closing the input WebSocket and clearing frameTimer), notifies onInputConnected(false, detail), and emits the specific codec error once.

Change

Replaced setStatus("error", ...) with fail(...) in the serveSimOnly unsupported-codec branch of readIosVideo (packages/client-runtime/src/device/stream.ts), matching the other terminal errors in createDeviceStreamClient. Web, desktop, and mobile all share createDeviceStreamClient from packages/client-runtime, so web/Electron no longer overwrite the visible codec error and mobile shares the immediate client cleanup, with no contract, i18n, or UI changes required. Added one focused regression test in packages/client-runtime/src/device/stream.test.ts with a complete avcC record.

Scope

Small fix for an obvious bug; no issue needed under CONTRIBUTING.md.

Verification

  • Base (9a08ffb84084c441dcf4a2f595682a44632ecc89): serveSimOnly unsupported-codec regression test failed because sockets[0].close was called 0 times and the 15 s frameTimer remained armed.
  • Head (f4990e525e5859ce42fd55c71f0b304ca7d96ffa): vp test run packages/client-runtime/src/device/stream.test.ts passed (29/29), including stops the stream and clears the first-frame timer on unsupported Simlock AVCC codec.
  • Checks: vp run check:changed exited 0 (vp format, vp lint, vp knip, vp typecheck across 7 packages, and packages/client-runtime/src/device/stream.test.ts 29/29 passed).
  • Before/after transcript & SHA-stamped check summary: https://gist.github.com/saphid/bab5d97162f2e5a63bfa16feed8d7582
  • Not shown: Browser scenario rendering the live Simlock Device panel alert past the 15 s first-frame deadline against a real Simlock host (verified via createDeviceStreamClient runtime unit test with fake timers, a complete avcC record, and stubbed VideoDecoder.isConfigSupported rejection).

Authored by Gemini 4 Neon (Antigravity); reviewed by GPT-6.2 Sol (Codex).

Not shown

  • .github/pull_request_template.md:27 — Replace the evidence link or update the gist: it shows the superseded three-branch patch and a filtered 30-test suite, not the 29/29 run or check:changed result at f4990e525e58. Attach the exact-head logs, or say that the linked transcript does not verify them.
  • packages/client-runtime/src/device/stream.test.ts:646 — The linked base run stops at the socket-close assertion, before measuring the timer or observing a second status. Label those effects as source-traced unless a separate transcript records them, and describe the decoder stub as resolving { supported: false }, not rejecting.
  • apps/web/src/components/device/DeviceStreamView.tsx:491 — No runnable scenarios:prove fixture or live-client proof exercises the visible alert past 15 seconds; the current Not shown disclosure is accurate. If adding a fixture, assert that the codec message remains visible after the deadline.
    1. tanstack-source added labelsbug

    2. Approvability

      Verdict: Approved at d3dbe18

      Macroscope's review found this PR approvable — Unsupported Simlock AVCC codecs now stop the affected stream and clear its timers while preserving the codec-specific error. The change is limited to an existing failure path and uses established cleanup behavior.

      You can add or adjust custom eligibility rules. [Learn more](https://docs.macroscope.com/approvability#example-custom-eligibility-rules).
    3. Explain Change →

      No actionable comments were generated in the recent review.

      Walkthrough

      When AVCC decoder configuration fails on a serveSimOnly host, readIosVideo now calls fail with the device-stream decode error. A regression test checks the error and resulting stream cleanup.

      Changes: Simlock AVCC decoder failure

      Layer / File(s)Summary
      Route decoder failure through fail
      packages/client-runtime/src/device/stream.ts, packages/client-runtime/src/device/stream.test.ts
      For serveSimOnly hosts, the decoder failure branch now calls fail. The test checks the codec-specific error, socket closure, input disconnection, timer cleanup, and absence of a duplicate error after 15 seconds.

      Estimated code review effort: 2 (Simple) | ~8 minutes

      Change: Bug fix

      Merge Risk: Minimal · up to d3dbe

      Unsupported H.264 codec failures on simulator-only hosts now stop the stream and keep the specific codec error instead of a later timeout error. The change is small and tested, and the risk of merging it is low.

      Pre-merge checks: Passed 4

      Check nameStatusExplanation
      Title checkPassedThe title is a conventional commit that names the main change: the Simlock AVCC unsupported-codec path now stops the stream and clears the first-frame timer. It matches the raw summary, which describe…
      Description checkPassedThe description follows the template's Problem, Change, Scope, and Verification sections and gives concrete detail. The Problem section names the faulty branch, the timer behavior, and the 15 s overwr…
      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.
      Full details: Title check

      Explanation

      The title is a conventional commit that names the main change: the Simlock AVCC unsupported-codec path now stops the stream and clears the first-frame timer. It matches the raw summary, which describes replacing setStatus with fail in readIosVideo, and the objectives, which describe the same terminal-path behavior. It is specific and does not rely on vague terms.

      Full details: Description check

      Explanation

      The description follows the template's Problem, Change, Scope, and Verification sections and gives concrete detail. The Problem section names the faulty branch, the timer behavior, and the 15 s overwrite. The Change section explains the fail() replacement and the regression test. Scope states why no issue is needed. Verification gives a base-versus-head comparison and a check summary, and it discloses what was not shown. Some evidence is weak. The linked gist reportedly shows a superseded patch and a filtered suite, and the base run stops before the timer and second-status assertions. The description's own review notes flag these gaps. The template also asks for the agent model and harness at the end, and the description includes that line. Overall the description is mostly complete, so it passes, but the evidence link should be corrected.

      Finishing Touches

      Generate unit tests (beta)

      • Create a new PR
      • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
      Recent review info

      Run configuration

      Commits

      Reviewing files that changed from the base of the PR and between 7b6a2c96f646830f10183339c2031141dd2801ca and d3dbe18219e086f086bdcc868f9ee02594644db6.

      Files selected for processing: 2

      • 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; 3 remain after this review.

Sign in to join this conversation.