CameraDetector in a iFrame

#1

My app stopped working this month and it took me a while to identify the root cause. I’m posting here in the hope of saving others time.

This month, Chrome 64 included a change to the permissions given to pages loaded in an iframe element. As a result, the Javascript SDK was triggering the onWebcamConnectFailure event every time I started the app. It wouldn’t display the webcam stream or return any results. The browser didn’t return any kind of error or warning message.

It seems this is due to the fact that the JS code that executes navigator.mediaDevices.getUserMedia() was loaded from Affectiva’s webserver, rather than the web server that the main page and iframe content was hosted on. This kind of cross-domain access is apparently rejected silently.

To fix this, I wrote my own code to display the webcam stream (using getUserMedia()), then used Affectia’s FrameDetector interface, instead of the CameraDetector one. This works in both a parent frame and an iframe.

1 Like

#2

Can you share the snippet that helped you go pass the cross-domain access failure so that others who run into the same issue can leverage that. Thanks!

0 Likes

#3

@ryan_carpenter feel free to send in PR on the youtube-sample app (https://github.com/Affectiva/youtube-demo)

0 Likes

#4

I can’t today, but I’ll give it a shot in a bit.

0 Likes

#5

I haven’t finished the changes yet, but feel free to see my draft. I’ll submit a pull request once I get the time to wrap this up.

0 Likes