This repository was archived by the owner on Jun 16, 2023. It is now read-only.
This repository was archived by the owner on Jun 16, 2023. It is now read-only.
Crash on second invocation #426
Closed
Description
Steps to reproduce
- Open a view with react-native-camera
- N.B. Not necessary to capture picture
- Close view
- 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
Activity
furkancelik commentedon Sep 26, 2016
I'm having the same problem too...!
msageryd commentedon Sep 26, 2016
N.B. the problem only exists in the simulator. Works fine on device.
JoschaP commentedon 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 commentedon Sep 27, 2016
This is relating to iOS 10.0. I fixed the issue with this inside Info.plist
The string can really be anything you want, it'll display when the app launches and asks for permissions to use the camera.
ibussieres commentedon Sep 27, 2016
@andrerfneves it does not fix for me. The second invocation crashes. I have the the NSCameraUsageDescription key set in my .plist files.
andrerfneves commentedon Sep 27, 2016
@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.
Not sure if this will fix your issue, but this is what helped me solve it.
msageryd commentedon Sep 28, 2016
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 commentedon 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 commentedon 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 commentedon Sep 28, 2016
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
comountainclimber commentedon Sep 28, 2016
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 commentedon Oct 1, 2016
+1 also have permissions in Info.plist
1 remaining item
RGBz commentedon Oct 15, 2016
@shahen94 did that work for you? I'm still getting a crash at the same line.
shahen94 commentedon Oct 18, 2016
@RGBz It works for me
rgoldiez commentedon Nov 4, 2016
Added a
<View />
inside of<Camera>
and it still crashes in the simulator on the second invocation.uncle-T0ny commentedon Nov 11, 2016
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.
IOS camera crash.txt
And I don't know how to solve it, could anyone help me, please?
baskan commentedon 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 commentedon Nov 11, 2016
Not sure how and why it works, but @shahen94 fix helped me
kesha-antonov commentedon Nov 12, 2016
Got this too. Sadly I don't have enough knowledge for now to fix this(
Hoping you can fix this guys.
uncle-T0ny commentedon Nov 13, 2016
@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 commentedon Nov 13, 2016
@uncle-T0ny Thanks!
And maybe
captureAudio={false}
will be good when use camera only for photos. Hence do not need microphone permissions.rgoldiez commentedon Nov 13, 2016
I did not add the microphone permission because I set video to false. I use it just for still images. No crashes here.
jqn commentedon 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 commentedon 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 commentedon Sep 5, 2017
I'm having the same problem too...! I add this key to info.plist ,was Iphone