jhuckaby / webcamjs

HTML5 Webcam Image Capture Library with Flash Fallback
MIT License
2.5k stars 1.11k forks source link

Images not captured after video feed hidden (iPhone Safari 11) #253

Closed ScottDellinger closed 7 years ago

ScottDellinger commented 7 years ago

After getting everything working pretty well, I've discovered an issue in Safari on both MacOS and iOS.

The application I use webcam.js in captures a frame from the user's webcam every minute. After the user permits access, I use "visibility: hidden" to hide the entire div that contains the webcam stuff. ONLY IN SAFARI using getUserMedia, if the div is set invisible (or display: none), the camera submits the last frame over and over again. No other browser does this.

Does anyone have any ideas on how to get around this?

ScottDellinger commented 7 years ago

I've also tried moving the feed off the side of the viewport to "hide" it to no avail. Capture happens as expected when video is showing.

positlabs commented 7 years ago

Try setting the opacity to a super low value like .00001

jhuckaby commented 7 years ago

This is probably some kind of "security" feature, to prevent people from capturing the camera when the user isn't aware. I agree with @positlabs, I think opacity is the only thing that may work here. Or maybe shrink it to 1x1 size.

ScottDellinger commented 7 years ago

Fantastic! Thanks, @positlabs and @jhuckaby! Using a combination of opacity: 00001; and pointer-events: none; appears to have worked :)