Files
client/docs/evidence/audio-devices-0.1.2.md
T
omar 2cf63f5d88
ci / linux-x64 (push) Successful in 3m3s
ci / linux-arm64-cross (push) Successful in 2m34s
Evidence: packaged 0.1.2-rc.2 (ed2e123) smokes
2026-10-24 07:15:35 +03:00

6.4 KiB
Raw Permalink Blame History

0.1.2 audio devices: root cause, fix and evidence

Reported symptom

Settings → Audio listed only "System default device" for both microphone and output (user report, Windows 11, TeamsPeach 0.1.1).

Root cause (observed, real Electron, no fake-media flags, no capture)

Electron 44 calls the session permission check handler during enumerateDevices() with:

{ permission: "media", requestingOrigin: "app://teamspeach/", mediaType: "audio" | "video", securityOrigin: "app://teamspeach/" }
{ permission: "speaker-selection", requestingOrigin: "app://teamspeach/" }

The 0.1.1 handler compared requestingOrigin with "app://teamspeach" (no trailing slash), so every check was denied. Chromium then redacts the device list to one entry per kind with empty deviceId/label, and the renderer dropped entries with empty ids, leaving only the default option.

Fix

  • app/main/permissions.js: origins are parsed with WHATWG URL and rebuilt as protocol//host (the WHATWG origin of a non-special scheme is "null"); inputs with credentials, backslashes or no host never match. Checks allow media only for mediaType === "audio" and speaker-selection, for the app origin only; requests allow audio-only getUserMedia. Camera stays denied. Tests: test/permissions.test.js (observed arguments, lookalike origins app://teamspeach@evil/, app://teamspeach.evil/, app://teamspeach\@evil/, app://user:pass@teamspeach/, apps://teamspeach/, app:teamspeach).
  • app/renderer/js/audio/devices.js: default/communications aliases fold into one "system default ()" entry; an unnamed device keeps its real id with an honest label; a saved but absent device stays selectable and is marked missing. Tests: test/devices.test.mjs.
  • Settings and the new right-click menus on the footer microphone/headphones buttons share one path (voice.deviceChoices, chooseInputDevice, chooseOutputDevice). A choice is applied only after it was saved.

OS inventory (read-only, same machine)

6 capture endpoints (MiniFuse 4 Mic/Line/Inst 1-2 = default, Loopback Mix, Line 3-4, Oculus headset mic, DroidCam, Virtual Desktop) and 6 render endpoints (MiniFuse Main L/R = default, Virtual L/R, Aux L/R, Realtek Digital Output, LG ULTRAGEAR, Oculus).

Runtime evidence (runtime/2026-10-24-audio-devices/)

Real devices, no fake-media flags, disposable profiles, never connected, microphone never opened.

Run Result
result-settings.json, 60/61 png (dev tree) 6 inputs + 6 outputs with names; capturing=false, framesSent=0, disconnected; a non-default input and output persist across restart; no error toasts
result-menus.json, 62/63 png (dev tree) right-click on the microphone opens the input menu without muting; the choice shows in Settings; Shift+F10 + arrows + Escape on headphones restores focus without deafening; left click still mutes; choices persist across restart; with enumeration slowed to 600 ms, rapid microphone → headphones requests leave exactly one (output) menu, and a dismissal before the result leaves no menu and does not steal focus
packaged-41e90fb/ (packaged dist/win-unpacked/TeamsPeach.exe, core 0.1.2) same settings and menu results as above

The UI strings in these captures are the Russian UI of that build and are kept as recorded.

Capture lifecycle

AudioEngine.startCapture is cancelable: a stop or a newer start while getUserMedia is pending stops the late stream's tracks immediately; voice.syncCapture always cancels when capture is not wanted. Tests: test/audio-engine.test.mjs.

Voice diagnostics (no behaviour change)

Default log level records one line per capture start (device label, sample rate, channel count, EC/NS/AGC, track muted) and OS mute/unmute of the track. With TEAMSPEACH_LOG=debug, push-to-talk presses (source, window focus), each transmission burst (frames, peak dBFS) and the core's transmitting state are logged. The push-to-talk hint states when the window is unfocused (the key is read only in the focused window).

Not proven

That the official TeamSpeak 6 client hears TeamsPeach voice is not verified. The user's 0.1.1-era logs show a connection and an opened microphone, but no burst logging existed then. The pending check is user-controlled: hold the in-window push-to-talk button (or F8 with TeamsPeach focused) while the official client listens. Synthetic two-TeamsPeach voice tests (fake capture, empty channel) pass and are not hardware proof.

Packaged smoke harness: launch race (found and fixed)

runtime/2026-10-24-packaged-launch-race/ keeps the first packaged run of 0.1.2-rc.1 (7afce5a): theme and menus passed; devices and ui failed with electron.launch: Timeout. Cause: with executablePath Playwright cannot inject its -r loader.js (which in a dev run holds ready until it has attached); when it attaches to the packaged app while the first page is committing, it loses its utility world and the launch never completes (6 of 6 isolated probes hung; passing -r loader.js to the packaged exe is ignored, 5 of 5 hung). CI run #21 failed the same way. Fix: dev runs use Playwright's own loader (no executablePath); packaged runs start with TEAMSPEACH_TEST_HOLD_WINDOW=1, which defers window creation until the harness calls the main-process hook (scripts/lib/electron-app.mjs). Without that variable the app starts as before.

Device choice and capture safety (rc.1 additions)

  • A saved microphone that no longer exists fails closed (device_unavailable): no second getUserMedia without the device id, no default microphone, nothing sent. Choosing an available device restarts capture only while connected or during the microphone test. Tests: test/voice-capture.test.mjs, test/audio-engine.test.mjs.
  • A failure while building the capture graph after the microphone opened stops its tracks and disconnects the partial nodes before rethrowing.
  • A failed enumerateDevices() replaces the cached choices, so the menus show the failure, not an older list.

Packaged release candidates

  • runtime/2026-10-24-rc1-packaged/: build of 2a71d63 (application tree of tag v0.1.2-rc.1 at d505890).
  • runtime/2026-10-24-rc2-packaged/: build of ed2e123 (tag v0.1.2-rc.2), the same build as the attached Windows assets. Theme (fresh profile dark, onboarding mark = decoded assets/icon.png 256×256 shown at 56 px, light persists), 6 + 6 real devices without capture, menus incl. races, offline UI: all pass, 0 page errors.