dograh/ui/public/embed
Aymenbenpakiss 37c4bda0c7
fix(ui): release microphone stream on call teardown so a second test call works (#446)
* fix(ui): release microphone stream on call teardown

The browser "Call Voice Agent" test call worked only once per page load.
A second attempt failed (mic stuck / "Could not acquire media") until the
user reloaded the page or cleared site data and re-granted mic permission.

Root cause: the MediaStream from getUserMedia() was added to the peer
connection but never retained or explicitly stopped on teardown. On hangup
only sender.track.stop() (via pc.getSenders()) ran; browsers can keep the
microphone device held through the original MediaStream reference, so the
next getUserMedia() is blocked.

Fix: keep the stream in localStreamRef and stop all of its tracks in
cleanupConnection() (the shared teardown path) and in the unmount cleanup,
so the device is fully released between calls.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* fix(ui): harden microphone release in webrtc hook and embed widget

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: AYMENPAKISS2 <tech.nomatrade@gmail.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Co-authored-by: Abhishek Kumar <abhishek@a6k.me>
2026-06-18 12:47:14 +05:30
..
dograh-widget.js fix(ui): release microphone stream on call teardown so a second test call works (#446) 2026-06-18 12:47:14 +05:30