Skip to content

fix(android): require a nonzero chunk before a recorder counts as ready - #4559

Open
shahjahanpak wants to merge 1 commit into
callstack:mainfrom
shahjahanpak:fix/4550-android-rollover-zero-byte-chunk
Open

shahjahanpak wants to merge 1 commit into
callstack:mainfrom
shahjahanpak:fix/4550-android-rollover-zero-byte-chunk

Conversation

@shahjahanpak

@shahjahanpak shahjahanpak commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Fixes #4550. A rollover chunk counted as ready as soon as its file existed. When the device refuses a second concurrent screenrecord, the new recorder exits and leaves a 0-byte file. The rotation committed that chunk, the sequential fallback never ran, and record stop failed with artifact is not stable.

waitForReady now needs a non-zero size, as the readiness check did before #1724 moved it onto exists. A dead recorder with an empty file now fails the start, so the existing concurrent-start recovery runs. A recorder that stays alive still counts as ready after the bounded wait, as before. If the sequential start also fails, the rotation gives today's typed error.

Partial-recording return and the close/claim path are unchanged.

2 files: chunks.ts and runtime.test.ts (one new case; the SIGINT case now counts calls after start). No scope expansion.

Validation

Base d78be6c88, head 5630ceb28.

pnpm exec vitest run --project unit-core packages/platform-android/src/recording/runtime.test.ts: base 1 failed, 16 passed; head 17 passed.

pnpm check:quick: passed. pnpm check:affected --run --base upstream/main --head 5630ceb28 (exactCommit: true): format, lint, typecheck, layering, fallow and build passed. vitest-related failed by 5 s timeouts across 67 provider files on a heavily loaded host. android-recording.test.ts alone times out on base (6 of 10) and head (7 of 10), with no assertion failure. CI owns these.

No device run: the defect needs a device that refuses a second recorder, and I had none.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

View guided diff

A rollover chunk whose recorder exits without writing left a zero-byte
file. Its existence counted as readiness, so the sequential fallback never
ran and record stop later failed on the empty artifact.

Closes callstack#4550

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

You’re at about 93% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

View guided diff | Re-trigger cubic

@thymikee

Copy link
Copy Markdown
Member

The code change at 5630ceb looks right for the reported case, but there is no live Android run of the route it changes yet. All 14 checks pass at this head.

waitForReady is shared by every Android recorder launch through startChunkAt: the first start and every rotation. This PR swaps the exists probe for a size probe, which is a second adb call on the real transport, and a dead recorder with a 0-byte file now fails the start. That changes live device dispatch for all Android recordings. The tests use a mocked transport, so CI cannot show the real size probe working. Please attach a live run at 5630ceb: record start <file> --scope device on an emulator or device, then record stop, with the returned video playing, plus the device used. A run past about 175 s that shows a second chunk committed with nonzero bytes (ls /sdcard/agent-device-recording-*) would be ideal. If no device refuses a second recorder, please say the refusal path is only covered by mocks.

Not blocking, and you can take or leave these: waitForReady still returns true when the recorder stays alive at 0 bytes for all 3 polls, so a recorder rejected late, or one that never writes, would still be committed and record stop would still hit artifact is not stable. Do you know from a device whether the refused recorder exits promptly? If it can stay alive at 0 bytes, the rotation path could wait longer for size > 0 inside the same function, so the sequential fallback runs. If it exits promptly, no code change is needed. The first start now waits about 500 ms when the first write lags, which is a small latency change you could mention in the PR body. A test where an alive recorder reports size 0 on the first polls and then a positive size, asserting the chunk commits without the fallback, would pin the slow-first-write case in runtime.test.ts.

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Android device recording over ~170 s: rollover chunk stays 0 bytes, record stop and close fail, device claim is left behind

2 participants