Skip to content
This repository has been archived by the owner on Jun 16, 2023. It is now read-only.

Crash on second invocation #426

Closed
msageryd opened this issue Sep 26, 2016 · 26 comments
Closed

Crash on second invocation #426

msageryd opened this issue Sep 26, 2016 · 26 comments

Comments

@msageryd
Copy link

Steps to reproduce

  1. Open a view with react-native-camera
  2. N.B. Not necessary to capture picture
  3. Close view
  4. Open view again

Expected behaviour

I'd expect the same behavior as at the first invocation.

Actual behaviour

Crash.

- (void)setCaptureQuality:(NSString *)quality
{
    if (quality) {
        [self.session beginConfiguration];
        if ([self.session canSetSessionPreset:quality]) {
            self.session.sessionPreset = quality;
        }
        [self.session commitConfiguration];
    }
}

At [self.session commitConfiguration] XCode reports "EXC_BAD_ACCESS"

Environment

  • Node.js 6.4:
  • React Native 0.33:
  • **iOS 10.0, simulator

react-native-camera

Version: lwansbrough/react-native-camera (6074ec3)
This is the version with the simulator fix

@furkancelik
Copy link

I'm having the same problem too...!

@msageryd
Copy link
Author

N.B. the problem only exists in the simulator. Works fine on device.

@JoschaP
Copy link

JoschaP commented Sep 27, 2016

same problem here:

[access] This app has crashed because it attempted to access privacy-sensitive data without a usage description. The app's Info.plist must contain an NSCameraUsageDescription key with a string value explaining to the user how the app uses this data.

Its fixed by adding the NSCameraUsageDescription key in Info.plist with a description of what u use the camera access for. its displayed in the popup when you request the camera access the first time

But another problem:
after u've given the camera access, u can use the camera only one time. the second time the app crashes again with the same error as before -.-

Error: Error setting property 'captureAudio' of RCTCamera with tag #342: capturing audio

@andrerfneves
Copy link

This is relating to iOS 10.0. I fixed the issue with this inside Info.plist

<key>NSCameraUsageDescription</key>
<string>This app uses the camera.</string>

The string can really be anything you want, it'll display when the app launches and asks for permissions to use the camera.

@ibussieres
Copy link
Contributor

@andrerfneves it does not fix for me. The second invocation crashes. I have the the NSCameraUsageDescription key set in my .plist files.

@andrerfneves
Copy link

@ibussieres I didn't run into second invocation issues. But whenever I flipped the camera to the front camera the app crashed. I had to add the same key and string pair on the .plist file but for the Microphone native properties.

<key>NSCameraUsageDescription</key>
<string>This app uses the camera.</string>
<key>NSMicrophoneUsageDescription</key>
<string>This app uses the microphone.</string>

Not sure if this will fix your issue, but this is what helped me solve it.

@msageryd
Copy link
Author

As this only happens in the simulator I'm guessing that there is something more that needs to be wrapped in an #if !(TARGET_IPHONE_SIMULATOR) (see 6074ec3). Maybe there is something that should be initialized only once per session. Unfortunately I don't know Objective C, so I can't look into it.

@JoschaP
Copy link

JoschaP commented Sep 28, 2016

@andrerfneves it does not fix it for me, too.

I've added both to the plist file:
<key>NSCameraUsageDescription</key> <string>This app uses the camera.</string> <key>NSMicrophoneUsageDescription</key> <string>This app uses the microphone.</string>

breaks at line: 988 of RCTCameraManager
[self.session commitConfiguration];

2016-09-28 14:16:48.562 [info][tid:main][RCTCameraManager.m:270] Error setting property 'captureAudio' of RCTCamera with tag #342: capturing audio

@ibussieres
Copy link
Contributor

ibussieres commented Sep 28, 2016

@andrerfneves thanks for the hinters, unfortunately it does not work. Besides, I am using this package only for barcode scanning so I had disabled the microphone. I think @MichaelSWE has put the finger on the type of problem that we need to surface up. I'm not too good with Objective-C either, but I'll try to look into something (yet hoping someone with better Objective-C skills will, too ;) )

@chrisnojima
Copy link

I have the same problem. It renders fine but if I switch screens and come back it'll crash. I'm running the iPhone 7 iOS 10.0 simulator. I have only the NSCameraUsageDescription as i have autoCapture turned off (and changing the microphone setting seems to change nothing regarding this issue).

For me it crashes at: https://github.com/lwansbrough/react-native-camera/blob/master/ios/RCTCameraManager.m#L988

screen shot 2016-09-28 at 5 52 34 pm

@comountainclimber
Copy link

I am experiencing a crash at the same place @chrisnojima have permission in info.plist for both camera and microphone...

This crash appears to only occur on simulator as others have stated above

@miclaus
Copy link

miclaus commented Oct 1, 2016

+1 also have permissions in Info.plist

@shahen94
Copy link

shahen94 commented Oct 14, 2016

@MichaelSWE try to put into <Camera /> component empty <View />.
Like this.

<Camera>
  <View />
</Camera>

@RGBz
Copy link

RGBz commented Oct 15, 2016

@shahen94 did that work for you? I'm still getting a crash at the same line.

@shahen94
Copy link

@RGBz It works for me

@rgoldiez
Copy link

rgoldiez commented Nov 4, 2016

Added a <View /> inside of <Camera> and it still crashes in the simulator on the second invocation.

@uncle-T0ny
Copy link

I have crash on setCaptureQuality and this bug reproduces on real device.
I tried to use different component properties, but this has not any effect.
screen shot 2016-11-11 at 5 39 35 pm

IOS camera crash.txt

And I don't know how to solve it, could anyone help me, please?

@baskan
Copy link

baskan commented Nov 11, 2016

I dunno if its releated but I put camera inside a wrapping container and add a shouldComponentUpdate() { return false; } now working fine on actual android device havent tested on an actual iOS device but its worth a try.

@theturboboy
Copy link

Not sure how and why it works, but @shahen94 fix helped me

@kesha-antonov
Copy link
Contributor

screen shot 2016-11-12 at 16 36 48

Got this too. Sadly I don't have enough knowledge for now to fix this(

Hoping you can fix this guys.

@uncle-T0ny
Copy link

@kesha-antonov I've just fixed the issue. The problem really was with NSMicrophoneUsageDescription permission. Check that application has camera and microphone permissions before you render the Camera component. Also be aware that microphone permission request not work on iPhone simulators. Good luck to you.

@kesha-antonov
Copy link
Contributor

@uncle-T0ny Thanks!
And maybe captureAudio={false} will be good when use camera only for photos. Hence do not need microphone permissions.

@rgoldiez
Copy link

I did not add the microphone permission because I set video to false. I use it just for still images. No crashes here.

@jqn
Copy link

jqn commented Nov 16, 2016

Same here I have captureAudio={false} because I don't need to capture audio. Everything works fine in iOS but the Android version crashes.

@Okipa
Copy link

Okipa commented May 11, 2017

I am experiencing the same issue this issue on Android with the v0.6.
I have specified captureAudio={false} and this is still crashing on Android.
I tried to add <uses-permission android:name="android.permission.RECORD_AUDIO" /> on my AndroidManifest.xml file and the crash still happens.
Is there a way to avoid this problem ?

@Geforceyu
Copy link

I'm having the same problem too...! I add this key to info.plist ,was Iphone

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

No branches or pull requests