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.

Android : Camera.recordAsync() doesn't work on front camera

See original GitHub issue

Calling Camera.recordAsync() on the back camera works fine. Calling it on the front camera resulting in error : recordAsync: Expected a Camera component

[Unhandled promise rejection: Error: recordAsync: Expected a Camera component]

  • node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:123:42 in createErrorFromErrorData
  • node_modules\react-native\Libraries\BatchedBridge\NativeModules.js:80:57 in <unknown>

screenshot_20180202-005538

Environment

I am testing it on actual devices, in the Expo app Expo 25.0.0 React-native 0.52.0

OnePlus One Android 7.1.2 (Lineage OS)

Samsung Galaxy S2 Android 6.0.1 (Lineage OS)

Steps to Reproduce

startVideo = async () => {
    if ( !this.camera ) return;
    try {
        const data = await this.camera.recordAsync({ });
        console.log( data);
    } catch ( error) {
        throw error;
    }
}

// Back : Works
<Camera
    ref   = { (cam) => { this.camera = cam; } }
    style = { styles.preview }
    type  = { Camera.Constants.Type.back }/>
<Text style={ styles.capture } onPress={ this.startVideo.bind(this) }>[START]</Text>

// Front : Error "Expected a Camera component"
<Camera
    ref   = { (cam) => { this.camera = cam; } }
    style = { styles.preview }
    type  = { Camera.Constants.Type.front}/>
<Text style={ styles.capture } onPress={ this.startVideo.bind(this) }>[START]</Text>

The only difference is the camera type In both case, the preview frame is working properly, I can see what the front camera see, but video recording not working from front camera

Snack

Press “Start” to start recording Press “Stop” to stop recording At the end, the message “Good” appear below the camera preview

Back Camera : OK https://snack.expo.io/SyB-LVZLG

Front Camera : Error (App Crash) when “Start” is pressed https://snack.expo.io/SyJaLEWIM

The only diffrence is on line 54

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Reactions:4
  • Comments:8 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
aalicescommented, Feb 19, 2018

Sorry for that, looking into the issue 🤔

1reaction
FrederickEngelhardtcommented, Oct 31, 2018

Bump…I have the same issue with Android Front facing camera calling a error: camera is not running.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Expo Camera recordAsync promise not resolving
Im starting to develop a mobile application with expo/react native, but I'm having some problems handling the ...
Read more >
Camera - Expo Documentation
Camera. expo-camera provides a React component that renders a preview for the device's front or back camera. The camera's parameters like zoom, auto...
Read more >
How to Fix Front Camera Not Working in Android Problem ...
How to Fix Front Camera Not Working in Android Problem Solved. 69K views 2 years ago. Howtofixit. Howtofixit. 55.7K subscribers. Subscribe.
Read more >
Capturing Photos and Videos with the Camera in React Native
Triggered by onLongPress callback of our capture component, we capture moments in form of videos with the help of the recordAsync method called ......
Read more >
react-native-camera - Issuehunt
Face detection not working on android front camera. Unfunded#2246created byChimaa123 ... AppState doesn't fire at the same time as recordAsync().
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