Skip to content

fix(emulator): preserve video replay integrity after overflow - #35490

Closed
OrcaWin wants to merge 1 commit into
mainfrom
audit/scrcpy-gop-replay-retirement
Closed

OrcaWin wants to merge 1 commit into
mainfrom
audit/scrcpy-gop-replay-retirement

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 29, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​62 $\color{#cf222e}{\Huge{\mathbf{−}}}$​2 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​60
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​14 $\color{#cf222e}{\Huge{\mathbf{−}}}$​6 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​8

LoC: +76/-8

Prevent corrupt Android video replay after the120-frame GOP cache overflows. Dropping intermediate delta pictures while retaining an old keyframe leaves a broken H.264 reference chain. Clear the incomplete replay and let new subscribers wait for the next keyframe; continue delivering every frame to existing subscribers. Complete cached groups still replay immediately, and subscriptions created before the first keyframe also skip unusable deltas.

The deliberate tradeoff is waiting for a fresh keyframe after overflow. Pinned scrcpy2.4 defaults to a10-second keyframe interval, so a changing stream can cross120 frames normally; actual device cadence and the renderer's10-second first-frame deadline are untested. No new timer, codec, registry, wire contract or cache limit.

Validation:21 focused tests/3 suites pass, including live delivery and cleanup. Exact baseline fails3 behavior regressions while2 controls pass. Focused strict TypeScript and normal hook tasks pass. Actual production registry bundles plus native FFmpeg decoding of generated270-picture H.264:join60 produces matching270 frames in both variants;join150 baseline produces209 incorrect frames, final waits forIDR240 and produces30 correct frames. N1/10 subscribers have identical delivery, and the pre-existing subscriber receives all270 frames. Final committed source compiles to the byte-identical executed bundle.78 sealed payloads, exact patch and bounded bundle independently verified.

Required aggregate queued after #35489; no aggregate pass or Claude takeover claimed. The stream is generated; no Android device, Electron/WebCodecs, full UI, macOS/Windows, CPU, GPU, heap or latency measurement. Waiting for a keyframe is an intentional behavior change. Existing frame-byte/total memory limits are outside this fix. Remote/mobile/folder/git identity contracts are unchanged; no install or dependency repair.

Frozen head 84147c5cbe9539c11f67130f280c5e8aa5f0c914, base 79dbada2c873bef3584a0c53b23ae98f2a84e536. Evidence with preserved failed and excluded attempts: /home/neil/.local/state/orca-electron-audit/scrcpy-gop-replay-retirement/report.md. Seal SHA256:7713c2101dc51772937c11bca6a47425947beda69d77c08f03cfa34cc89fc08b.

@OrcaWin

OrcaWin commented Oct 29, 2026

Copy link
Copy Markdown
Collaborator Author

Thanks for this. I'm closing it because it trades a brief smear (late subscribers see deltas until the next keyframe) for a blank wait of up to about 10s, since scrcpy's default i-frame interval is 10s. That wait can trip the renderer's 10s first-frame deadline and turn a cosmetic glitch into a fatal 'did not deliver a frame' teardown.

Closing per maintainer triage (low-risk / zero user trade-off / material-gain bar).

@OrcaWin OrcaWin closed this Oct 29, 2026
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.

1 participant