MediaStream in Safari fails to release resources correctly
P粉106715703
2023-08-30 17:23:15
<p>I am using the AudioWorkletNode method to record and all browsers seem to be recording fine. </p>
<p>When I record, the recording icon appears on the tab and disappears when the recording ends. </p>
<p> However, in Safari, a small speaker icon (usually indicating that the tab is emitting sound) will appear on the tab instead of the microphone icon. </p>
<p>So I think I may not have closed something. </p>
<p>After the recording is completed I will do the following:</p>
<pre class="brush:php;toolbar:false;">//stream is a MediaStream type
if(stream)
stream.getTracks().forEach(track => track.stop());
stream = null</pre>
<p>The stream is created via: </p>
<pre class="brush:php;toolbar:false;">stream = await navigator.mediaDevices.getUserMedia({
audio: options
});</pre>
<p>Is there anything else needed to release all resources? </p>
To turn everything off, the following method seems to work. I just found this through trial and error because I couldn't figure out how to get Safari to tell me what it still holds: