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

Camera API - Cannot read property 'enumerateDevices' of undefined #1577

Closed
UlisesCeca opened this issue May 25, 2019 · 7 comments · Fixed by #1598
Closed

Camera API - Cannot read property 'enumerateDevices' of undefined #1577

UlisesCeca opened this issue May 25, 2019 · 7 comments · Fixed by #1598

Comments

@UlisesCeca
Copy link

Hello,

I am getting this error when trying to reproduce the same code as from the docs:

TypeError: Cannot read property 'enumerateDevices' of undefined
    at n.queryDevices (p-dp4kxc5o.entry.js:1)
    at n.componentDidLoad (p-dp4kxc5o.entry.js:1)
    at V (p-7a741ef8.js:1)
    at Z (p-7a741ef8.js:1)
    at Y (p-7a741ef8.js:1)
    at Array.<anonymous> (p-7a741ef8.js:1)
    at v (p-7a741ef8.js:1)
    at g (p-7a741ef8.js:1)
    at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invokeTask (zone.js:423)
    at Zone.push../node_modules/zone.js/dist/zone.js.Zone.runTask (zone.js:195)

This is when running in web from a mobile.

@jcesarmobile
Copy link
Member

In which device? OS version? Browser version?

@UlisesCeca
Copy link
Author

Device: mobile. Don't have a webcam to try on PC
OS: Android 9
Browser: Chrome App with version 74.0.3729.157

@andrew-motorcentral
Copy link

I get this same error on MacOS on:

  • Chrome 76.0.3805.0 canary
  • Microsoft Edge 76.0.166.0 canary
  • Chrome 73.0.3683.86 (Official Build)

Out of interest, perhaps this might be related to insecure origin request?

  • until I upgraded my Official Build version of Chrome, I was receiving the following error: "[Deprecation] getUserMedia() no longer works on insecure origins. To use this feature, you should consider switching your application to a secure origin, such as HTTPS. See https://goo.gl/rStTGz for more details." However, after upgrading this to 74.0.3729.169, I received the "enumateDevices" error.
  • On Samsung device, Chrome (65.0.3325.109), I get the error, "pwa-camera.entry.js:289 DOMException: Only secure origins are allowed (see: https://goo.gl/Y0ZkNV)."

@andrew-motorcentral
Copy link

Can confirm that it works when hosting on secure https... So possibly a security issue...

@jcesarmobile
Copy link
Member

I've sent a PR to PWA elements to return an error
ionic-team/pwa-elements#27

If that is merged, then Capacitor Camera plugin will have to be updated to detect the error and reject the getPicture promise with more information.

But the problem here is what Andrew said, getUserMedia only works when served from https.

@UlisesCeca
Copy link
Author

@jcesarmobile if I use the back camera it looks inverted from my phone, is this normal? You can check in the "aaaa" button @ https://ulisesceca.com

@jcesarmobile
Copy link
Member

there is an issue open ionic-team/pwa-elements#11

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

Successfully merging a pull request may close this issue.

3 participants