react-native-vision-camera: ๐ App Crashes When Navigating Back to Camera Screen
Whatโs happening?
The app crashes when I navigate back from the camera screen and then attempt to return to the camera screen.
Steps to Reproduce:
- Navigate to the camera screen within the app.
- Interact with the camera screen as needed.
- Use the appโs navigation to go back to the previous screen.
- Navigate back to the camera screen.
Error:
java.lang.IllegalArgumentException: Surface was abandoned
Reproduceable Code
function App() {
const codeScanner = useCodeScanner({
codeTypes: ['qr', 'ean-13'],
onCodeScanned: console.log,
});
const device = useCameraDevice('back', {
physicalDevices: ['wide-angle-camera'],
});
if (device == null) return null;
return (
<Camera
style={StyleSheet.absoluteFill}
device={device}
isActive={true}
enableZoomGesture
focusable
codeScanner={codeScanner}
/>
)
}
Relevant log output
10-12 15:20:57.082 9477 10289 E AndroidRuntime: FATAL EXCEPTION: mrousavy/VisionCamera.main
10-12 15:20:57.082 9477 10289 E AndroidRuntime: Process: com.dt.johnny.jdtmelhu, PID: 9477
10-12 15:20:57.082 9477 10289 E AndroidRuntime: java.lang.IllegalArgumentException: Surface was abandoned
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at android.hardware.camera2.utils.SurfaceUtils.getSurfaceSize(SurfaceUtils.java:135)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at android.hardware.camera2.params.OutputConfiguration.<init>(OutputConfiguration.java:563)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at android.hardware.camera2.params.OutputConfiguration.<init>(OutputConfiguration.java:345)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at com.mrousavy.camera.core.outputs.SurfaceOutput.toOutputConfiguration(SurfaceOutput.kt:38)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at com.mrousavy.camera.extensions.CameraDevice_createCaptureSessionKt.createCaptureSession(CameraDevice+createCaptureSession.kt:57)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at com.mrousavy.camera.core.CameraSession.getCaptureSession(CameraSession.kt:438)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at com.mrousavy.camera.core.CameraSession.startRunning(CameraSession.kt:532)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at com.mrousavy.camera.core.CameraSession.access$startRunning(CameraSession.kt:49)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at com.mrousavy.camera.core.CameraSession$startRunning$1.invokeSuspend(Unknown Source:14)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at kotlin.coroutines.jvm.internal.BaseContinuationImpl.resumeWith(ContinuationImpl.kt:33)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at kotlinx.coroutines.DispatchedTask.run(DispatchedTask.kt:106)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:958)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:99)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at android.os.Looper.loopOnce(Looper.java:205)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at android.os.Looper.loop(Looper.java:294)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: at android.os.HandlerThread.run(HandlerThread.java:67)
10-12 15:20:57.082 9477 10289 E AndroidRuntime: Suppressed: kotlinx.coroutines.DiagnosticCoroutineContextException: [StandaloneCoroutine{Cancelling}@9a35690, mrousavy/VisionCamera.main]
Camera Device
{
"sensorOrientation": "landscape-right",
"hardwareLevel": "full",
"maxZoom": 10,
"minZoom": 1,
"supportsLowLightBoost": false,
"neutralZoom": 1,
"physicalDevices": [
"wide-angle-camera"
],
"supportsFocus": true,
"supportsRawCapture": true,
"isMultiCam": false,
"name": "BACK (0)",
"hasFlash": true,
"hasTorch": true,
"position": "back",
"id": "0"
}
Device
Any Android Devices
VisionCamera Version
3.3.1
Can you reproduce this issue in the VisionCamera Example app?
I didnโt try (โ ๏ธ your issue might get ignored & closed if you donโt try this)
Additional information
- I am using Expo
- I have enabled Frame Processors (react-native-worklets-core)
- I have read the Troubleshooting Guide
- I agree to follow this projectโs Code of Conduct
- I searched for similar issues in this repository and found none.
About this issue
- Original URL
- State: closed
- Created 9 months ago
- Reactions: 9
- Comments: 16 (5 by maintainers)
I think this will get fixed with this: https://github.com/mrousavy/react-native-vision-camera/pull/1996
Yea basically I need to do a refactor on the Codebase - I now know exactly what I need for the session configuration, and need to do all of this fully atomically.
I just fixed this in #2049, and released it to npm (v3.6.0) ๐
If you appreciate my work and dedication to fix your issues and make VisionCamera better, please ๐ consider sponsoring me on GitHub ๐ to say thanks. Thanks!
i think i can fix this in #2049