Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chrome on Android 11 freezes when closing the reader #185

Open
Stofkat opened this issue Jan 24, 2021 · 4 comments
Open

Chrome on Android 11 freezes when closing the reader #185

Stofkat opened this issue Jan 24, 2021 · 4 comments

Comments

@Stofkat
Copy link

Stofkat commented Jan 24, 2021

Steps to reproduce

  • Open the scanner in Chrome on Android 11
  • Hide the component or navigate away without a full page reload
  • Chrome will now seemingly freeze, pressing home and going back to the browser fixes this issue.

This appears to be a problem with the underlying MediaStreamTrack, the bug has already been reported in November 2020: https://bugs.chromium.org/p/chromium/issues/detail?id=1148532

I found out that introducing a small delay in MediaStreamTrack.stop helps as a workaround for this issue

I simply replaced line the this.stopCamera = streamTrack.stop.bind(streamTrack); with:

this.stopCamera = () => {
  setTimeout(() => {
    streamTrack.stop();
  }, 2000);
}
@nastassiadanilova
Copy link

nastassiadanilova commented Feb 25, 2021

Mostly the same issue https://bugs.chromium.org/p/chromium/issues/detail?id=1138823. Just to track how the progress is going.

One of the possible solutions twilio/twilio-video-app-react#355 (comment)

@joobacca
Copy link

joobacca commented Mar 8, 2021

@Stofkat Where do you define the streamTrack object?

@joobacca
Copy link

joobacca commented Mar 8, 2021

@Stofkat Where do you define the streamTrack object?

In case anyone stumbles upon the same problem, I solved it using the snippet @nastassiadanilova linked:

const video = qrReaderRef.current.els.preview;
video.srcObject = null;
navigator.mediaDevices
  .getUserMedia({
    video: true,
  })
  .then(mediaStream => {
     mediaStream.getVideoTracks().forEach(track => {
      mediaStream.removeTrack(track);
      track.stop();
    });
  });

@ZanekShaw
Copy link

I have this issue but need help implementing the patch you describe. Can you please explain further?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants