After I end a WebRTC call, nothing I seem to do removes the red icon on the browser tab that says the camera or microphone are in use.
I iterate the tracks from videoElement.srcObject.getTracks()
and call track.stop()
on each one. I then delete the videoElement from the DOM, but still I have the red icon.
In my case, the problem was caused by a bug in my code due to my misunderstanding WebRTC and getUserMedia(). I was actually calling getUserMedia() twice, once for the local <video>
element and a second time for adding to the RTCPeerConnection.
The fix was of course to only call getuserMedia() once and use the returned stream in both places.