Files
client/docs/evidence/stream-pipeline-audit-20261024.md
T
omar ceecbb790a docs: record source parity evidence and remaining acceptance gaps
Document accumulated interoperability findings and current source-backed design. Record build-specific visual results, matched acceleration policy, passing packaged behavior checks, and explicit native/ARM and strict visual acceptance limits. No complete 1:1 claim.
2026-11-01 19:47:52 +03:00

105 lines
13 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# Stream pipeline and lifecycle audit — 2026-10-24
## Outcome
The user's **20 fps** observation remains valid and unexplained for that live TS6 sender/session. No application-imposed 20 fps clamp was found or reproduced. The corrected, **visible** generated AV1 loopback decoded approximately **59 fps before and 56 fps after** at actual **2568×1402**, with no interval RTP decode drops or HTML video playback drops in those two samples. This is **not an FPS improvement claim**, a guaranteed 1440p60 capability, or official TS6 interoperability evidence. The generated sender itself did not consistently capture/send 60 fps.
Four concrete lifecycle/correctness defects were fixed without changing codec choice, production bitrate, hardware-decode preferences, background throttling, rendering policy, or the existing stream/fullscreen UX. They do not establish the cause of the user's 20 fps.
## Changes and severity
| Severity | File / section | Proven defect and change |
| --- | --- | --- |
| Medium | `app/renderer/js/stream/directory.js`, `_remove` | A duplicate/unknown **explicit stream ID** stop fell through to client-wide deletion and removed sibling shares. An explicit ID is now always scoped to that ID; client-wide removal requires no ID. Reproduced by a failing focused regression. |
| Low | `app/renderer/js/stream/session.js`, `_applyOffer`, `_flushRemoteCandidates`, `_addCandidate` | Cancellation while awaiting buffered ICE still attempted the next candidate and could continue answer creation. Cancellation during rollback could apply the replacement offer. Continuations now stop after closure; completed/rejected candidate work cannot update terminal-session counters. Reproduced using gated promises; all existing signaling behavior tests still pass. |
| Low | `app/renderer/js/stream/session.js`, `_finish` | An ended session retained its already-closed peer connection while the terminal UI stayed open. Release the peer field, detach callbacks, and close the captured local peer. Runtime WeakRef count at the terminal screen changed **one closed receiver wrapper → zero**. This was bounded retention, not an accumulating live-peer leak. |
| Low | `app/renderer/js/watch.js`, `startWatching` and first-frame overlay clearing | An empty dynamic text callback could retain a stopped session's lexical context, especially when stopping before the first stats poll. Replacing just the empty stats callback with the identical literal changed retained sessions **1 → 0** under the same test-only GC probe. Empty stats/overlay labels now use literal strings, not translation callbacks. Final runtime regression ends with **zero** retained sessions. No visible text or translation behavior changes. |
Focused coverage is in `test/stream-directory.test.mjs` and `test/stream-session.test.mjs`. Reproducible generated-media/runtime coverage is in `scripts/audit-stream-pipeline.mjs`. No unrelated source, version, release, or publication changes were made by this workstream.
## Corrected visible measurement
Raw artifacts are under `C:/Users/Admin/tmp/teamspeach-fps-diagnosis/`:
- `visible-before/result.json`: original local packaged build; UTC **10:41:51.836–10:42:23.114**.
- `visible-after/result.json`: source with stream fixes; UTC **10:42:37.864–10:43:09.421**.
- `visible-before/visible-2568.png` and `visible-after/visible-2568.png`: generated-only screenshots of the visible player.
- `stream-regressions.json`: unit reproduction/fix results.
- `label-probe-before/result.json`: bounded empty-label counterfactual.
- `measurement-scope.json`: explicit interpretation/counter corrections for every experiment.
- `stream-ui-after/result.json` and its generated-only screenshots: existing stream/fullscreen UI smoke.
The unchanged baseline package is `C:/Users/Admin/tmp/teamspeach-stream-qa-20261024/build/win-unpacked/TeamsPeach.exe`; its prior verified `app.asar` SHA256 is `3ffb5d2baedca40dc5f995a0cf81fb72cee6b39e759f1511a2366d6e4938757c`. Source/package identity before editing is documented in the adjacent `source-evidence.txt`. Both audit runtimes report Electron **44.9.3**, Chromium **152.0.7977.167**. The source run can include the separate memory workstream's changes: global heap/RSS differences are not attributed solely to stream changes.
The test sends a moving canvas and generated oscillator audio through real local RTCPeerConnections and the production `watch.js` session/player. Test sender parameters explicitly retain **6,000,000 bps maximum**, **60 fps maximum**, and `maintain-resolution`. Only the 2568×1402 test sender selects AV1 to exercise the reported codec; the other negotiated VP8. These settings are confined to the test sender. ICE uses local host candidates, no external STUN. The snapshot is synthetic and delivered through the normal main-to-renderer `core:event` path; the native core remains disconnected.
The benchmark windows were coordinated with the other worker to avoid its heavy runtime workloads. User/system background workload was not controlled, so differences between short samples are not treated as regressions or improvements.
### Actual 2568×1402 AV1, roughly five-second intervals
| Measurement | Original package | Source after fixes |
| --- | ---: | ---: |
| Interval seconds | 5.0126 | 5.0107 |
| Actual capture FPS (`media-source.frames` delta) | 58.65 | 56.48 |
| Encoded / sent FPS | 58.65 / 58.65 | 56.48 / 56.48 |
| Complete received / decoded FPS | 58.65 / 58.65 | 56.48 / 56.28 |
| rVFC callback / compositor-submitted FPS | 58.45 / 58.45 | 56.48 / 56.48 |
| RTP `framesDropped` delta | 0 | 0 |
| HTML video total / dropped frames delta | 294 / 0 | 282 / 0 |
| Lost packets delta | 0 | 0 |
| Mean decode ms per decoded frame | 0.481 | 0.539 |
| Mean encode ms per encoded frame | 4.391 | 5.198 |
| Received video kbit/s | 51.62 | 50.84 |
| Sender `qualityLimitationReason` at sample end | `none` | `none` |
These are **interval deltas**, not cumulative counters mislabeled as rates. Slight differences of one frame between stages are normal for sequential snapshot boundaries. Paint callbacks (~62/s) are not capture FPS. `getSettings().frameRate=60` is a setting, not the measured rate. The simple generated rectangle compresses to roughly 51 kbit/s; the 6 Mbit/s maximum was not raised, and this is not a full-complexity 6 Mbit/s screen-share stress test.
The 1280×720 VP8 control also retained its actual resolution: decoded **55.83 → 57.70 fps**, HTML playback drops **0 → 0**. Again, this is not a speedup conclusion.
The actual player and ancestors were visible, `sessionHidden=false`, document visible/focused, nonzero video rectangle fully inside the viewport (approximately 879×375 CSS pixels). This tests decoded 2568×1402 scaled into the inline production player, not native-resolution display scanout. Candidate pairs were host/UDP → host with reported RTT zero at the sample boundary. Addresses, private SDP, tokens, and real stream names were not exported. Generated SDP summaries contain only codec/framerate/bandwidth policy lines.
`decoderImplementation`, `encoderImplementation`, and `powerEfficientDecoder` were absent from these isolated raw RTC reports; they are **unknown**, not false/software. GPU feature policy reported video decoding enabled. The earlier live-client log naming `ExternalDecoder (D3D11VideoDecoder)` is separate timestamped evidence and must not be substituted for the isolated runtime's missing fields.
### Presentation measurement correction
The earlier `pipeline-before/after` and `fullres-before/after` experiments directly assigned `S.snap`, which left the **parent `#session-view` hidden**. Checking only `#stream-view.hidden` was insufficient. Those runs are retained as raw **decode-only** experiments and are not evidence of visible presentation. Their high `getVideoPlaybackQuality().droppedVideoFrames` counts were not RTP decode drops.
The corrected runs use the ordinary snapshot/render lifecycle, assert full ancestor visibility and a nonzero in-viewport rectangle, and record three distinct signals:
1. `inbound-rtp.framesDropped`: receive/decode-path drops.
2. `getVideoPlaybackQuality().droppedVideoFrames`: media playback drops.
3. `requestVideoFrameCallback` invocation count and `metadata.presentedFrames`: callbacks / frames submitted to the compositor, **not proof of every physical display scanout**.
The corrected visible sample has zero playback drops as well as zero decode drops. The hidden-parent/corrected-visible contrast explains the harness counter mismatch; it is not evidence that the user's real player was hidden. No production visibility policy was changed.
## Lifecycle evidence and behavior checks
- Before the fixes, three focused regressions failed: sibling deletion on duplicate stop, retained closed peer field, continued candidate processing after stop. After the fixes, **21/21** stream tests passed, including rollback cancellation.
- Each runtime exercised **12 stop/end/disconnect cycles**, **six switches while live**, and renegotiation in both codec/resolution cases. Generated audio packet counts and decoded frames advanced across renegotiation.
- On terminal transitions, both receive tracks were `ended`, the video `srcObject` was cleared, and no nonclosed receiver connection survived. Original terminal screens retained one closed JS receiver wrapper; fixed screens retained zero. The small session object can intentionally remain while an ended explanation is shown.
- After final Close, corrected source runtime retained **zero sessions, zero receiver wrappers, zero nonclosed receivers**. The original package retained one stopped session. The counterfactual changed only the empty-label binding and also produced zero, isolating that retention from unrelated memory changes.
- WeakRefs and explicit `HeapProfiler.collectGarbage` checkpoints are **test-only** and identical between compared lifecycle checks. They measure reachability of instrumented wrappers, not exact native/GPU memory reclaimed. No forced GC shipped in the application. No unbounded stream-object growth was observed in these bounded cycles; this is not a proof against every possible long-duration leak.
- Transient DOM growth during end toasts disappeared after their normal expiry. Final DOM nodes were **482 in both visible runs**; initial 487 includes transient startup UI. Whole-process heap/RSS trends are not a stream-only metric.
- The existing stream-view smoke passed all **21 recorded steps** with zero page errors and zero capture requests: selection does not join, multiple shares, disconnected-core join error, native fullscreen and Escape, keyboard toggle, generated-media continuity, promise rejection display, end/stop/decline/disconnect cleanup, and language/theme/layout fixtures. It ran after session/directory fixes; the final visible runtime additionally validates the later empty-label change and its ownership regression.
## No-defect findings and residual unknowns
- The receiver passes SDP through `setRemoteDescription` / `createAnswer` without rewriting frame-rate limits or forcing codecs. No 20 fps clamp was found. The 1500 ms stats polling interval refreshes the label, not frame delivery.
- The displayed FPS is rounded receiver `inbound-rtp.framesPerSecond` (decoded frames), not the sender's configured 60 fps or the monitor refresh rate. Source definitions: [W3C inbound FPS](https://w3c.github.io/webrtc-stats/#dom-rtcinboundrtpstreamstats-framespersecond), [rVFC API](https://developer.mozilla.org/en-US/docs/Web/API/HTMLVideoElement/requestVideoFrameCallback).
- Existing stats continuations reject stale sessions after switching. One media element/MediaStream is used; fullscreen is presentation-only and the existing smoke preserved stream identity and advancing audio/video.
- `backgroundThrottling=true` remained unchanged. Corrected samples were visible/focused; they neither demonstrate nor rule out a hidden/occluded-window issue in another runtime condition. No speculative throttling or GPU switch was applied.
- The original live client exposed no remote-debug listener or accessible raw stats transport during the read-only diagnosis. Its sender capture/encode rate, interval loss/decode timing, actual selected ICE route, and visible presentation deltas remain missing. A LAN/P2P label and 60 fps setting do not supply these measurements.
- Earlier global GPU 96% utilization and a D3D11 decoder log are not bottleneck proof. No conclusion about native TS6 encoder adaptation, static-window behavior, GPU contention, or real sender codec constraints follows from the generated fixture.
## Reproduction and safety
From the repository:
```text
node --test test/stream-directory.test.mjs test/stream-session.test.mjs
node scripts/audit-stream-pipeline.mjs --out C:/Users/Admin/tmp/stream-audit --maintain-resolution --expect-fixed
node scripts/smoke-stream-view.mjs --out C:/Users/Admin/tmp/stream-ui-audit
```
For an unchanged packaged baseline, pass `--exe <existing TeamsPeach.exe>` and omit `--expect-fixed`. `--lifecycle-only` skips throughput samples. The harness's temporary profile is deleted after its disposable application closes. `getUserMedia` and `getDisplayMedia` are denied/counted before injecting fixture state; final counts were **zero**. Generated tone is muted at playback. No real microphone/private stream capture, normal-profile restart, server operation, preference migration, build, install, tag, version bump, or publication was performed.