Skip to content
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
Closed
@msageryd

Description

@msageryd

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

Activity

furkancelik

furkancelik commented on Sep 26, 2016

@furkancelik

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

msageryd

msageryd commented on Sep 26, 2016

@msageryd
Author

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

JoschaP

JoschaP commented on Sep 27, 2016

@JoschaP

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

andrerfneves commented on Sep 27, 2016

@andrerfneves

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

ibussieres commented on Sep 27, 2016

@ibussieres
Contributor

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

andrerfneves

andrerfneves commented on Sep 27, 2016

@andrerfneves

@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

msageryd commented on Sep 28, 2016

@msageryd
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

JoschaP commented on Sep 28, 2016

@JoschaP

@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

ibussieres commented on Sep 28, 2016

@ibussieres
Contributor

@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

chrisnojima commented on Sep 28, 2016

@chrisnojima

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

comountainclimber commented on Sep 28, 2016

@comountainclimber

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

miclaus commented on Oct 1, 2016

@miclaus

+1 also have permissions in Info.plist

1 remaining item

RGBz

RGBz commented on Oct 15, 2016

@RGBz

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

shahen94

shahen94 commented on Oct 18, 2016

@shahen94

@RGBz It works for me

rgoldiez

rgoldiez commented on Nov 4, 2016

@rgoldiez

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

uncle-T0ny

uncle-T0ny commented on Nov 11, 2016

@uncle-T0ny

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

baskan commented on Nov 11, 2016

@baskan

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

theturboboy commented on Nov 11, 2016

@theturboboy

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

kesha-antonov

kesha-antonov commented on Nov 12, 2016

@kesha-antonov
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

uncle-T0ny commented on Nov 13, 2016

@uncle-T0ny

@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

kesha-antonov commented on Nov 13, 2016

@kesha-antonov
Contributor

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

rgoldiez

rgoldiez commented on Nov 13, 2016

@rgoldiez

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

jqn

jqn commented on Nov 16, 2016

@jqn

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

Okipa commented on May 11, 2017

@Okipa

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

Geforceyu commented on Sep 5, 2017

@Geforceyu

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @ibussieres@RGBz@chrisnojima@theturboboy@andrerfneves

        Issue actions

          Crash on second invocation · Issue #426 · react-native-camera/react-native-camera