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.
12 KiB
Audio and core lifecycle second audit — 2026-10-24
Scope, baseline and safety
Independent second-pass review of audio/engine.js, capture/playback processors, voice.js consumers, main/preload boundaries and core-process.js. Previous evidence and its limitations were read in nonstream-memory-audit-20261024.md and stream-pipeline-audit-20261024.md. Stream/media/chat changes belong to the separate second-pass report.
The unchanged packaged baseline was C:/Users/Admin/tmp/teamspeach-memory-audit-20261024/build/win-unpacked/TeamsPeach.exe, label 0.1.4; previous build evidence records resources/app.asar SHA-256 96ea250138ae0a83e09f333550760060bf3bdf953a76cae78eccae4750fac59c. This pass did not independently rehash that baseline or publish/build/tag/version-bump it.
Every runtime here used a disposable real Electron profile and remained disconnected. Capture was Chromium's explicitly enabled fake device, never a physical microphone. Playback input was generated silence. A separate native core used another directory inside that disposable profile. No normal client/profile restart, live server, private media, or physical-device routing experiment was performed. Profiles were removed after the test clients closed.
Raw timestamped machine-readable evidence: C:/Users/Admin/tmp/teamspeach-audit2-20261024/audio/. Reusable runtime: scripts/audit-audio-failures.mjs. Event dispatch, suppressed diagnostic replies and rejected context closure are explicitly harness fault injection, not evidence that Chromium spontaneously suffers those failures in normal use.
Confirmed defects and bounded fixes
High: diagnostic log failure could terminate main
A genuine directory-as-log-file write produced EISDIR, an unhandled WriteStream error and Node exit code 1 (core-open-failure-before.json, UTC 11:24:12). A controlled stalled writable similarly threw on ENOSPC; the existing lossless stderr pipe had no destination-failure owner (core-before.json).
core-process.js now owns destination error/premature-close handling. It reports the failure once through a warning/status, detaches the failed destination and resumes stderr consumption. Writes to an unusable log are not queued. Healthy logging retains its existing lossless backpressure. Once the destination fails, unavailable diagnostic bytes cannot be persisted: the explicit warning is intentional, not a claim of lossless disk-failure recovery. No generic logging framework or core-killing fallback was introduced.
In the final source real Electron main runtime, the same genuine EISDIR occurred while a real disconnected native core started. Main survived, the core reached ready, profile_get returned {ok:true, result:{exists:false,...}}, shutdown exited code 0, and ownership/pending count ended at running=false, pending=0. This exercises actual filesystem failure and actual child pipes, not only fake streams.
Medium: exited child remained available for new IPC until stdio close
The first audit moved cleanup from exit to close, correctly fixing failed spawn ownership, but also left status ready after process exit while pipes drained. A controlled child emitted exit without close; a new request remained pending instead of immediately returning core_unavailable.
Exit now revokes command availability/readiness immediately. Buffered stdout is not discarded: already-issued requests can still receive their final responses, and final events are delivered until stdio close. Close disposes readline/log/child ownership and resolves unanswered requests with core_exited; their existing command deadlines remain in force while draining. A late ready cannot resurrect the exited core. Failed spawn still receives close cleanup without requiring an exit event.
The final regression checks a successful response and a disconnected event arriving after exit, one unanswered request settled by close, a rejected new request and a suppressed late-ready resurrection. An intermediate blanket stdout gate was rejected during review and is not in the final implementation.
Medium: capture processor failure left the microphone open
The packaged baseline, after injected processorerror, still reported capturing=true, a live fake microphone track and no error notification. Final source reports capturing=false, ends the track immediately and reports a capture error; explicit subsequent capture produces frames. Processor listeners are removed on teardown, including partially constructed graphs.
The final code uses removable event listeners. An intermediate property-handler implementation passed its simplistic unit callback but did not respond to synthetic native event dispatch in this Electron runtime; that implementation was rejected. The real-Electron regression is why callback-only unit evidence was not treated as sufficient.
Medium: rejected capture closure was silently forgotten
With AudioContext.close() rejected by the harness, the baseline stopped the track but forgot its still-running context and acquired another microphone. The final engine retains the failed context and reports the failure. An explicit later start retries its closure before acquiring a new microphone; continued rejection rejects that start. No periodic/background retry or arbitrary resource cap was added.
Final real-context injection observed retryOutcome="injected close refusal", original track ended, original context still running; after restoring the real close operation, explicit recovery closed that original context and acquired capture successfully. The retained failed context is deliberate ownership, not evidence that the rejected operation magically freed native resources. Playback close rejection has an equivalent deterministic regression: no replacement context is created until the retained context can close. That playback rejection case is a controlled Web Audio stub test, not a hardware/native close-failure observation.
Medium: explicit playback initialization could succeed with unusable playback
The packaged baseline's successful init() left a deliberately suspended context suspended, and reused a deliberately closed context. It also did not handle a failed playback processor or settle diagnostics whose replies could no longer arrive.
Explicit initialization now resumes an interrupted/suspended context, or releases/rebuilds terminal playback resources. Failure closes partial resources; a rejected close retains the context and rejects recovery rather than silently creating overlapping contexts. Recovery initialization is single-flight. Processor failure resolves outstanding diagnostic waiters with null and prevents further writes to the failed processor; no automatic retry loop is installed.
Recreation preserves the last applied volume/output selection before connecting the replacement graph. This is engine state retention, not a second persisted-preferences layer. A regression discovered during this pass prevented the proposed recovery from resetting gain to 100%. Controlled tests prove 17% and a nondefault selected-output survive plain explicit init(), then a new sink selection retains gain. A separate test uses the actual voice.startAudio() / voice.chooseOutputDevice() consumer with saved out-1 → out-2 and verifies 0.17 gain. The real Electron smoke additionally measures gain 0.17000000178813934 and sink default; that runtime result alone is not proof of nondefault physical-device selection.
Paired runtime results
Final paired fixture, same reusable script:
- Baseline:
baseline-final/result.json, UTC 11:38:38.429–11:38:42.041, failed consumer assertions. - Source:
source-final/result.json, UTC 11:38:42.369–11:38:44.396, all assertions passed, zero page errors. - Both: Electron 44.9.3, Chromium 152.0.7977.167, Node 24.22.0.
| Observation | Packaged baseline | Final source |
|---|---|---|
| Capture processor-error track / capturing | live / true | ended / false |
| Error surfaced for capture failure | no | yes |
| Failed capture close followed by new start | acquired another microphone | rejected before acquisition |
| Explicit retry after restoring real close | original context still running until harness cleanup | original context closed |
| Explicit init after playback suspension | suspended | running |
| Explicit init after playback closure | same closed context | replacement running context |
| Failed-worklet diagnostic with suppressed reply | timed out in harness | settled null |
| Silent frames received after final output selection | 1/1 | 1/1 |
The unchanged one-second capture ACK fallback was exercised with a real suspended capture context, not just a fake timer: final source closed it after 1010.1 ms, with tracks ended immediately. The existing persistent playback context remained identical and running through that capture stop. This confirms the failure-path deadline and separation; it is not a new latency improvement or a heap/RSS savings measurement.
Other paths examined and evidence limits
- Existing generation checks still reject stale microphone/module/resume completion; failed or superseded starts cannot replace a newer capture. Focused behavior tests cover these paths and graph construction failure. A permission promise that never resolves is not claimed to be cancellable by the Web API; stale completion is cleaned up when it arrives.
- Stopping capture replaces its message callback with the stop-ACK handler, closes the port and removes graph/track listeners. The capture-specific context design and persistent healthy playback were preserved.
- Voice forwarding requires the current core transmit acknowledgement, including latest-request epochs; mute/deafen/disconnect gating remains intact. Rust
set_transmitclears its input queue and ends its burst before answering. These facts do not prove every cross-thread queued-PCM scheduling boundary. No causal consumer-visible privacy/mode-switch failure was established in this bounded pass, so no speculative timestamp/epoch protocol rewrite was shipped. - The selected-output recovery path and consumer reapplication are behavior-tested. Arbitrarily reordered native device switches and real device removal were not established as defects or exercised on physical hardware; no speculative output queue/retry abstraction was added.
- Main/preload source inspection found no new subscription ownership change needed. Main's trusted IPC/validation and preload unsubscribe boundaries were left unchanged. No main/preload source edits were required.
- Pending playback-stat requests on a live but indefinitely unresponsive worklet remain outside the terminal
processorerror/closed-context recovery guarantee. No polling, forced GC, or generic diagnostic timeout framework was added. - This pass does not repeat the previous native heap/RSS experiment and makes no new total-memory-savings claim. It proves specific failure ownership/settlement behavior, not absence of every leak, indefinite browser promise, driver interruption or live TS6 audio glitch.
Verification and reproduction
focused-final.json: 36/36 focused tests passed at UTC 11:38:36–11:38:38, covering audio-engine, core-process, voice-capture and voice-transmit.nondefault-routing-final.json: both selected-output and actual voice-consumer recovery tests passed at UTC 11:40:25.- Earlier
*-before.jsonrecords retain failing consumer assertions, including genuine filesystem failure. Intermediate unsuccessful runtime attempts are preserved as evidence, not reported as final passes. - Source real-Electron command:
node scripts/audit-audio-failures.mjs --out C:/Users/Admin/tmp/teamspeach-audit2-20261024/audio/source-final --core --verify. - Packaged integration command:
node scripts/audit-audio-failures.mjs --exe <new TeamsPeach.exe> --out C:/Users/Admin/tmp/teamspeach-audit2-20261024/audio/packaged --core --verify. - Full-suite/final-package integration belongs to the coordinating workstream; this report records only the focused/source verification actually exercised here.
Only reusable audit code and intentional evidence were kept. No throwaway product scaffolding, production fault injection, periodic GC, version bump, tag or publication was added.