Expo Barcode Scanner native crash
See original GitHub issueSummary
Random Android users in production report crashing and 90% of our crashes come from the error below in the standalone production build.
Important to note it crashes without the user even navigating to the screen.
This is the entirety of the code I use, and I am only scanning QR codes:
import { BarCodeScanner } from 'expo-barcode-scanner';
...
const [hasPermission, setHasPermission] = useState(false);
useEffect(() => {
const requestPermissions = async () => {
const { status } = await BarCodeScanner.requestPermissionsAsync();
setHasPermission(status === 'granted');
};
requestPermissions();
}, []);
if (!hasPermission) return null;
return (
<BarCodeScanner
onBarCodeScanned={() => Analytics.logEvent('KioskScan')}
style={{ width: '100%', height: '100%', position: 'absolute' }}
/>
);
Pasting crash from Google Play Crashes & ANR’s:
java.lang.RuntimeException:
at android.os.AsyncTask$4.done (AsyncTask.java:399)
at java.util.concurrent.FutureTask.finishCompletion (FutureTask.java:383)
at java.util.concurrent.FutureTask.setException (FutureTask.java:252)
at java.util.concurrent.FutureTask.run (FutureTask.java:271)
at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:289)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
at java.lang.Thread.run (Thread.java:919)
Caused by: java.lang.RuntimeException:
at android.hardware.Camera.native_getParameters (Native Method)
at android.hardware.Camera.getParameters (Camera.java:2132)
at expo.modules.barcodescanner.BarCodeScannerViewFinder$BarCodeScannerAsyncTask.doInBackground (BarCodeScannerViewFinder.java:198)
at expo.modules.barcodescanner.BarCodeScannerViewFinder$BarCodeScannerAsyncTask.doInBackground (BarCodeScannerViewFinder.java:179)
at android.os.AsyncTask$3.call (AsyncTask.java:378)
at java.util.concurrent.FutureTask.run (FutureTask.java:266)
at android.os.AsyncTask$SerialExecutor$1.run (AsyncTask.java:289)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:641)
at java.lang.Thread.run (Thread.java:919)
Managed or bare workflow? If you have ios/
or android/
directories in your project, the answer is bare!
managed
What platform(s) does this occur on?
Android
SDK Version (managed workflow only)
41.0.0
Environment
Expo CLI 4.4.2 environment info: System: OS: macOS 11.2.3 Shell: 5.8 - /bin/zsh Binaries: Node: 12.18.1 - ~/.nvm/versions/node/v12.18.1/bin/node Yarn: 1.22.10 - /usr/local/bin/yarn npm: 6.14.5 - ~/.nvm/versions/node/v12.18.1/bin/npm Watchman: 4.9.0 - /usr/local/bin/watchman Managers: CocoaPods: 1.9.1 - /usr/local/bin/pod SDKs: iOS SDK: Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4 IDEs: Android Studio: 3.5 AI-191.8026.42.35.5977832 Xcode: 12.5/12E262 - /usr/bin/xcodebuild npmPackages: expo: ^41.0.0 => 41.0.0 react: 16.13.1 => 16.13.1 react-dom: 16.13.1 => 16.13.1 react-native: https://github.com/expo/react-native/archive/sdk-41.0.0.tar.gz => 0.63.2 npmGlobalPackages: expo-cli: 4.4.2 Expo Workflow: managed
Reproducible demo or steps to reproduce from a blank project
Can’t reliably reproduce, but it’s a native crash in the managed workflow so I’m fairly certain it is an SDK issue otherwise Sentry would have thrown something.
Issue Analytics
- State:
- Created 2 years ago
- Reactions:3
- Comments:14 (2 by maintainers)
Top GitHub Comments
Same problem here. Using expo managed workflow. Just scanning QR-Code, on iOS everything works fine, on android the app crashes (100%) before the camera screen is shown. I can´t see any error-message in debugger. Used the example code in documentation of “BarcodeScanner”. Tried the same with just expo-camera (for what we need expo-barcode-scanner while expo-camera provide the same functionality?) but with same result. => crash on android before opening camera.
@Joshandrews43, please open a new issue for that. Thanks 😉