Skip to content

Commit

Permalink
Fix Android 11 freezing issues
Browse files Browse the repository at this point in the history
Following this thread twilio/twilio-video-app-react#355

Calling the `stream.removeTrack` before `.stop()` fixes the freezing issues in Android 11.
  • Loading branch information
BrendonSled authored May 17, 2021
1 parent 5cd4869 commit bfdac5a
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/react-webcam.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,14 @@ export default class Webcam extends React.Component<WebcamProps, WebcamState> {
private static stopMediaStream(stream: MediaStream | null) {
if (stream) {
if (stream.getVideoTracks && stream.getAudioTracks) {
stream.getVideoTracks().map(track => track.stop());
stream.getAudioTracks().map(track => track.stop());
stream.getVideoTracks().map(track => {
stream.removeTrack(track);
track.stop();
});
stream.getAudioTracks().map(track => {
stream.removeTrack(track);
track.stop()
});
} else {
((stream as unknown) as MediaStreamTrack).stop();
}
Expand Down

0 comments on commit bfdac5a

Please sign in to comment.