question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Expo Barcode Scanner native crash

See original GitHub issue

Summary

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:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:14 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
Alta1recommented, Jul 9, 2021

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.

0reactions
lukmccallcommented, Mar 28, 2022

@Joshandrews43, please open a new issue for that. Thanks 😉

Read more comments on GitHub >

github_iconTop Results From Across the Web

BarCodeScanner intermittently crashes app on render
Summary When rendering the BarCodeScanner component from expo-barcode-scanner, the entire app sometimes locks up.
Read more >
App Crashes after using Expo Barcode scanner
App crashes when scanning a barcode using Expo's BarCodeScanner. I made an application using Expo 42.0.1 (react native).
Read more >
IOS Production build crashes directly after opening the app
Hello Everyone, I have a problem with the IOS part of my App. The Android part works fine. When I create an development...
Read more >
expo-barcode-scanner
Allows scanning variety of supported barcodes both as standalone module and as extension for expo-camera. It also allows scanning barcodes from existing images....
Read more >
Expo React Native BarCodeScanner crashes when I open ...
Coding example for the question Expo React Native BarCodeScanner crashes when I open it the second time-React Native.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found