{"action":"created","issue":{"url":"https://api.github.com/repos/react-native-community/react-native-camera/issues/1708","repository_url":"https://api.github.com/repos/react-native-community/react-native-camera","labels_url":"https://api.github.com/repos/react-native-community/react-native-camera/issues/1708/labels{/name}","comments_url":"https://api.github.com/repos/react-native-community/react-native-camera/issues/1708/comments","events_url":"https://api.github.com/repos/react-native-community/react-native-camera/issues/1708/events","html_url":"https://github.com/react-native-community/react-native-camera/issues/1708","id":344389496,"node_id":"MDU6SXNzdWUzNDQzODk0OTY=","number":1708,"title":"takePictureAsync leads to a crash on android 21/22","user":{"login":"TBouder","id":9974362,"node_id":"MDQ6VXNlcjk5NzQzNjI=","avatar_url":"https://avatars3.githubusercontent.com/u/9974362?v=4","gravatar_id":"","url":"https://api.github.com/users/TBouder","html_url":"https://github.com/TBouder","followers_url":"https://api.github.com/users/TBouder/followers","following_url":"https://api.github.com/users/TBouder/following{/other_user}","gists_url":"https://api.github.com/users/TBouder/gists{/gist_id}","starred_url":"https://api.github.com/users/TBouder/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/TBouder/subscriptions","organizations_url":"https://api.github.com/users/TBouder/orgs","repos_url":"https://api.github.com/users/TBouder/repos","events_url":"https://api.github.com/users/TBouder/events{/privacy}","received_events_url":"https://api.github.com/users/TBouder/received_events","type":"User","site_admin":false},"labels":[{"id":418407111,"node_id":"MDU6TGFiZWw0MTg0MDcxMTE=","url":"https://api.github.com/repos/react-native-community/react-native-camera/labels/Android","name":"Android","color":"bfe5bf","default":false},{"id":194397263,"node_id":"MDU6TGFiZWwxOTQzOTcyNjM=","url":"https://api.github.com/repos/react-native-community/react-native-camera/labels/Bug","name":"Bug","color":"fc2929","default":false},{"id":194397266,"node_id":"MDU6TGFiZWwxOTQzOTcyNjY=","url":"https://api.github.com/repos/react-native-community/react-native-camera/labels/Help%20Wanted","name":"Help Wanted","color":"5319e7","default":false}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2018-07-25T10:39:46Z","updated_at":"2018-12-22T13:10:34Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"### Which implementation are you using\r\nRNCamera\r\n\r\n### Steps to reproduce\r\n1. Open a simulator with Lollipop (android 5.1.1 for instance)\r\n2. Open the Camera\r\n3. Take the picture\r\n\r\n### Expected behaviour\r\nShould not crash\r\n\r\n### Actual behaviour\r\nCrash\r\n\r\n### Environment\r\n- **React version**:  16.4.1\r\n- **React Native version**: 0.56.0\r\n- **React Native platform + platform version**: Android 5.1.1\r\n\r\n### react-native-camera\r\n**Version**: ^1.1.4 || master\r\n\r\nHere is the code we are using. Basicaly it's working perfectly on the newest version of Android/IOS, but on android Lollipop (v21/22) everytime `takePictureAsync` is called, we have a crash (both on simulator and on physical device)\r\n```\r\ntakePicture = async () =>\r\n{\r\n\tif (!this.camera)\r\n\t\treturn;\r\n\r\n\tconst\toptions = {width: 1080, base64: false, quality: 1};\r\n\tconst\tdata = await this.camera.takePictureAsync(options); //CRASH HERE\r\n\t//DO STUFF\r\n}\r\n\r\nrender = () =>\r\n{\r\n\treturn (\r\n\t\t<RNCamera\r\n\t\t\tkey={'CAMERA'}\r\n\t\t\tref={ref => this.camera = ref}\r\n\t\t\tstyle={cameraStyle}\r\n\t\t\tmirrorImage={this.state.cameraType === 'front'} />\r\n\t);\r\n}\r\n```\r\n\r\n![screenshot_1532515081](https://user-images.githubusercontent.com/9974362/43196239-9c7e421c-9007-11e8-824d-a49ff1e20205.png)\r\n```\r\n07-25 10:37:58.801 6746-11210/com.shokimap E/unknown:ReactNative: Exception in native call\r\n    java.lang.NullPointerException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference\r\n        at com.facebook.react.bridge.ReadableNativeArray.getDouble(ReadableNativeArray.java:114)\r\n        at com.facebook.react.bridge.JavaMethodWrapper$4.extractArgument(JavaMethodWrapper.java:64)\r\n        at com.facebook.react.bridge.JavaMethodWrapper$4.extractArgument(JavaMethodWrapper.java:60)\r\n        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:359)\r\n        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)\r\n        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)\r\n        at android.os.Handler.handleCallback(Handler.java:739)\r\n        at android.os.Handler.dispatchMessage(Handler.java:95)\r\n        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)\r\n        at android.os.Looper.loop(Looper.java:135)\r\n        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)\r\n        at java.lang.Thread.run(Thread.java:818)\r\n```"},"comment":{"url":"https://api.github.com/repos/react-native-community/react-native-camera/issues/comments/449569076","html_url":"https://github.com/react-native-community/react-native-camera/issues/1708#issuecomment-449569076","issue_url":"https://api.github.com/repos/react-native-community/react-native-camera/issues/1708","id":449569076,"node_id":"MDEyOklzc3VlQ29tbWVudDQ0OTU2OTA3Ng==","user":{"login":"darekg11","id":11317951,"node_id":"MDQ6VXNlcjExMzE3OTUx","avatar_url":"https://avatars2.githubusercontent.com/u/11317951?v=4","gravatar_id":"","url":"https://api.github.com/users/darekg11","html_url":"https://github.com/darekg11","followers_url":"https://api.github.com/users/darekg11/followers","following_url":"https://api.github.com/users/darekg11/following{/other_user}","gists_url":"https://api.github.com/users/darekg11/gists{/gist_id}","starred_url":"https://api.github.com/users/darekg11/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/darekg11/subscriptions","organizations_url":"https://api.github.com/users/darekg11/orgs","repos_url":"https://api.github.com/users/darekg11/repos","events_url":"https://api.github.com/users/darekg11/events{/privacy}","received_events_url":"https://api.github.com/users/darekg11/received_events","type":"User","site_admin":false},"created_at":"2018-12-22T13:10:34Z","updated_at":"2018-12-22T13:10:34Z","author_association":"NONE","body":"@n1ru4l \r\nForked repo with easy reproduction:\r\nhttps://github.com/darekg11/react-native-camera/tree/reproduce-the-crash\r\n\r\nReproduction steps:\r\n1. Install the app (notice the permissions are not listed, as any new app should not ask for permissions upon startup when targeting devices with Android 23+)\r\n2. Launch app\r\n3. Decline permissions.\r\n4. Click `REC` button\r\n5. Crash\r\n\r\n# What have I changed:\r\n1. Bumped the version in `AndroidManifest.xml` and `build.gradle` to use sdk in version `23` where Permissions are not shown by default when launching it on device with Android 6.0+:  \r\nhttps://developer.android.com/distribute/best-practices/develop/target-sdk#prelollipop  \r\n2. Moved the rec button to always be visible in order to be able to click `Rec` even when the Camera component fails to initialize\r\n\r\n# Logcat stack trace:\r\n```\r\n12-22 13:55:58.770 27995-31188/com.rncameraexample V/AudioManager: playSoundEffect   effectType: 0\r\n    querySoundEffectsEnabled...\r\n12-22 13:55:58.776 27995-31188/com.rncameraexample E/unknown:ReactNative: Exception in native call\r\n    java.lang.NullPointerException: Attempt to invoke virtual method 'double java.lang.Double.doubleValue()' on a null object reference\r\n        at com.facebook.react.bridge.ReadableNativeArray.getDouble(ReadableNativeArray.java:114)\r\n        at com.facebook.react.bridge.JavaMethodWrapper$4.extractArgument(JavaMethodWrapper.java:64)\r\n        at com.facebook.react.bridge.JavaMethodWrapper$4.extractArgument(JavaMethodWrapper.java:60)\r\n        at com.facebook.react.bridge.JavaMethodWrapper.invoke(JavaMethodWrapper.java:359)\r\n        at com.facebook.react.bridge.JavaModuleWrapper.invoke(JavaModuleWrapper.java:160)\r\n        at com.facebook.react.bridge.queue.NativeRunnable.run(Native Method)\r\n        at android.os.Handler.handleCallback(Handler.java:743)\r\n        at android.os.Handler.dispatchMessage(Handler.java:95)\r\n        at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:29)\r\n        at android.os.Looper.loop(Looper.java:150)\r\n        at com.facebook.react.bridge.queue.MessageQueueThreadImpl$3.run(MessageQueueThreadImpl.java:192)\r\n        at java.lang.Thread.run(Thread.java:833)\r\n```\r\nUnfortunately this is everything that there is in log when this error occurs :(\r\nI have attached the debugger in Android Studio and my results:\r\nIt must be somewhere n in React-Native bridge because my breakpoints in `react-native-camera` Android code are not reached when that error happens.\r\nAs soon as I enable permissions, breakpoints work correctly.\r\n\r\n# My system and device info:\r\n```\r\nReact Native Environment Info:\r\n    System:\r\n      OS: macOS High Sierra 10.13.6\r\n      CPU: (4) x64 Intel(R) Core(TM) i7-7660U CPU @ 2.50GHz\r\n      Memory: 1.52 GB / 16.00 GB\r\n      Shell: 5.3 - /bin/zsh\r\n    Binaries:\r\n      Node: 8.11.3 - /usr/local/bin/node\r\n      npm: 5.6.0 - /usr/local/bin/npm\r\n    SDKs:\r\n      iOS SDK:\r\n        Platforms: iOS 12.1, macOS 10.14, tvOS 12.1, watchOS 5.1\r\n      Android SDK:\r\n        API Levels: 22, 23, 25, 26, 27, 28\r\n        Build Tools: 23.0.1, 25.0.2, 25.0.3, 26.0.1, 26.0.2, 26.0.3, 27.0.3, 28.0.1\r\n        System Images: android-22 | Google APIs Intel x86 Atom, android-25 | Google APIs Intel x86 Atom, android-26 | Google APIs Intel x86 Atom, android-27 | Google APIs Intel x86 Atom, android-28 | Google APIs Intel x86 Atom\r\n    IDEs:\r\n      Android Studio: 3.1 AI-173.4819257\r\n      Xcode: 10.1/10B61 - /usr/bin/xcodebuild\r\n    npmPackages:\r\n      react: 16.5.0 => 16.5.0\r\n      react-native: 0.57.1 => 0.57.1\r\n    npmGlobalPackages:\r\n      react-native-git-upgrade: 0.2.7\r\n      react-native-svg: 7.1.2\r\n```\r\nDevice that is crashing:  \r\n`Huawei P8 Lite, running Android 6.0`\r\n\r\n# How I have solved it in project?\r\nI have used FaCC and conditional rendering based on `status` coming from Camera - solution similar to that posted by @chmartinez "}}
{"actor":{"display_login":"darekg11"}}