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

NSLog causes crash , if facingMode === 'user'. Ideal and exact values are ignored #450

Closed
derMani opened this issue Nov 19, 2019 · 7 comments
Assignees
Labels
Milestone

Comments

@derMani
Copy link

derMani commented Nov 19, 2019

I tried to use the facing mode and observed some interesting behavior:

It only works with

{video:{facingMode:'environment}}

It will crash with

{video:{facingMode:'user'}}

If we try to use:

video.facingMode.ideal or video.facingMode.exact, the "user mode" will always be selected.

If we just use

video.facingMode = 'user'

the app will crash

Bildschirmfoto 2019-11-19 um 16 41 30

The NSLog will cause a EXC_BAD_ACCESS code 1.

if we comment the NSLog out, it works like expected.

Expected behavior

We can use

video.facingMode
video.facingMode.ideal
video.facingMode.exact

with 'user' and 'environment'. The correct facing mode is used and the app will not crash.

Observed behavior

  • App will crash with facingMode = 'user'.
  • With ideal and exact, the algorithm will always fallback to 'user'

Steps to reproduce the problem

This snippet should do it:

var constraints = {
      audio: false,
      video: {
        width: {
          min: resolution.width,
          max: resolution.width
        },
        height: {
          min: resolution.height,
          max: resolution.height
        },
        facingMode: 'user'
      }
    }
  }
  navigator.mediaDevices.getUserMedia(constraints)
    .then(function (stream) {
       console.log(stream)
    })
    .catch(function (err) {
      console.log('### err', err);
    });
}

Platform information

  • Cordova version: 8.1.2
  • Cordova ios version: 4.5.5
  • Plugin version: 6.0.3
  • iOS version: 13.2.3
  • Xcode version: 11.2.1
@hthetiot hthetiot added the bug label Nov 19, 2019
@hthetiot hthetiot self-assigned this Nov 19, 2019
@hthetiot hthetiot added this to the 6.0.4 milestone Nov 19, 2019
@hthetiot
Copy link
Contributor

Thank you @derMani I will look into that and fix it on next release 6.0.4

@hthetiot
Copy link
Contributor

It's kind of weird as facingMode is a string in environment like it is in user. I will try to find what going on and improve exact and ideal support.

@hthetiot
Copy link
Contributor

@derMani This PR should fix the issue #451

Note: replacing NSLog "%s" by "%@" did also fix the NSLog crash.

@hthetiot
Copy link
Contributor

Let me know if #451 works and i will release on 6.0.4 @derMani

@derMani
Copy link
Author

derMani commented Nov 20, 2019

Hmm, I don't know if I am doing this correctly, but I replaced the files from 6.0.3 with the changed files from #451 :

On Page load, I am getting an error message in the dist js file:

Error: Cannot find module 'cordova/exec'

@hthetiot
Copy link
Contributor

@derMani That not going to work as cordova manipulate the iosrtc.js plugin and add line on top and end of the file.

cordova.define("cordova-plugin-iosrtc.Plugin", function(require, exports, module) {
...
});

I have added instruction on the PR #451 description for you to test.

Note: I found out that if you use webrtc-adater facingMode is not working cause they overrride getUserMedia and ignore it.

@hthetiot
Copy link
Contributor

merged #451 on master will test master then release 6.0.4

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

No branches or pull requests

2 participants