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

video is blank when granted camera permissions for the first time #7

Open
kaushalyap opened this issue Dec 23, 2022 · 8 comments
Open
Labels
bug Something isn't working

Comments

@kaushalyap
Copy link

I notice that in dev mode (my case Nextjs) newly granting camera permission result in empty <video> (white box),
but in production mode things work fine.

@adamalfredsson
Copy link
Owner

Is there just a delay or does the stream not start at all? Have you got any clues?

@kaushalyap
Copy link
Author

@nomadoda streaming not starting at all (square with the green border is the video element)

Screenshot from 2023-01-05 11-07-20

@kaushalyap
Copy link
Author

@nomadoda I noticed if you change something in the DOM, which causes a HMR, after that video feed is visible.

@kaushalyap
Copy link
Author

Also getting following in the console.

Screenshot from 2023-01-05 15-08-36

@adamalfredsson adamalfredsson added the bug Something isn't working label Mar 20, 2023
@DonKoko
Copy link

DonKoko commented Apr 1, 2024

Just giving my 2 cents. I had this same issue and i believe its because of the timing of how things happen. The way I solved it is I made a separate component with the video and useZxing and I only render this component if there are permissions already given. This completely resolved the issue.

@lenard-a
Copy link

Just giving my 2 cents. I had this same issue and i believe its because of the timing of how things happen. The way I solved it is I made a separate component with the video and useZxing and I only render this component if there are permissions already given. This completely resolved the issue.

Could you please share your code? I tried getting the permissions in advance with navigator.mediaDevices.getUserMedia({ video: true }), and then conditionally show the scanner component, but it still gave me the error above, and then a bunch of "No MultiFormat Readers were able to detect the code." errors.
If the scanner is rendered on app start, it works correctly.

@DonKoko
Copy link

DonKoko commented Oct 18, 2024

@lenard-a there it is: https://github.com/Shelf-nu/shelf.nu/blob/main/app/routes/_layout%2B/scanner.tsx#L51-L91
Hope that helps.

@lenard-a
Copy link

Thank you! I realized that disabling StrictMode makes it happen much less frequent, but I will check your code to fully fix the issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants