react-native-vision-camera
react-native-vision-camera copied to clipboard
🐛 takePhoto() intermittently failing with [unknown/unknown: Failed to submit capture request] on v4.0.0-beta.10
What's happening?
takePhoto() intermittently failing with [unknown/unknown: Failed to submit capture request] on v4.0.0-beta.10
"react-native": "0.72.7"
"react-native-vision-camera": "4.0.0-beta.10"
"node 18.12.0"
Reproduceable Code
const camera = useRef<RNVisionCamera>(null);
const takePhotoOptions = useMemo<TakePhotoOptions>(
() => ({
qualityPrioritization: 'speed',
flash: state.flashModeOn ? 'on' : 'off',
quality: options?.imageQuality || 50,
enableShutterSound: !!options?.playsound,
}),
[state.flashModeOn],
);
const takePicture = async () => {
try {
if (camera.current == null) {
return;
}
await RNVisionCamera.requestCameraPermission();
const data = await camera.current?.takePhoto(takePhotoOptions);
const { path, width, height } = data || {};
const uri = `file://${path}`;
} catch (e) {
ToastAndroid.show('Something went wrong with camera', ToastAndroid.SHORT);
}
};
Relevant log output
03-29 19:19:43.942 21260 21359 E BufferQueueConsumer: [ImageReader-4032x3024f22m9-21260-29](id:530c0000001d,api:4,p:1061,c:21260) detachBuffer: slot 1 is not owned by the consumer (state = DEQUEUED)
03-29 19:19:43.942 21260 21359 E ConsumerBase: [ImageReader-4032x3024f22m9-21260-29] Failed to detach buffer: -22
03-29 19:19:43.942 21260 21359 E ImageReader_JNI: Image detach failed: Invalid argument (-22)!!!
03-29 19:19:43.943 21260 21260 D TakePictureManager: Issue the next TakePictureRequest.
03-29 19:19:43.943 21260 21260 D TakePictureManager: No new request.
03-29 19:19:43.943 21260 21260 W CaptureNode: request aborted:t.o0@34a9cf7
03-29 19:19:43.943 21260 21355 W System.err: androidx.camera.core.w0: Failed to submit capture request
03-29 19:19:43.943 21260 21355 W System.err: at t.b1$a.onFailure(SourceFile:33)
03-29 19:19:43.943 21260 21355 W System.err: at w.l$e.run(SourceFile:37)
03-29 19:19:43.943 21260 21355 W System.err: at android.os.Handler.handleCallback(Handler.java:938)
03-29 19:19:43.943 21260 21355 W System.err: at android.os.Handler.dispatchMessage(Handler.java:99)
03-29 19:19:43.943 21260 21355 W System.err: at android.os.Looper.loop(Looper.java:223)
03-29 19:19:43.943 21260 21355 W System.err: at android.app.ActivityThread.main(ActivityThread.java:7656)
03-29 19:19:43.943 21260 21355 W System.err: at java.lang.reflect.Method.invoke(Native Method)
03-29 19:19:43.943 21260 21355 W System.err: at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
03-29 19:19:43.943 21260 21355 W System.err: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
03-29 19:19:43.943 21260 21355 W System.err: Caused by: java.lang.RuntimeException: nativeDetachImage failed for image!!!
03-29 19:19:43.943 21260 21355 W System.err: at android.media.ImageReader.nativeDetachImage(Native Method)
03-29 19:19:43.943 21260 21355 W System.err: at android.media.ImageReader.detachImage(ImageReader.java:731)
03-29 19:19:43.943 21260 21355 W System.err: at android.media.ImageWriter.queueInputImage(ImageWriter.java:372)
03-29 19:19:43.943 21260 21355 W System.err: at y.b.d(Unknown Source:0)
03-29 19:19:43.943 21260 21355 W System.err: at y.a.d(Unknown Source:0)
03-29 19:19:43.943 21260 21355 W System.err: at androidx.camera.camera2.internal.f5.f(SourceFile:12)
03-29 19:19:43.943 21260 21355 W System.err: at androidx.camera.camera2.internal.v0$c.p(SourceFile:80)
03-29 19:19:43.943 21260 21355 W System.err: at androidx.camera.camera2.internal.v0$c.m(Unknown Source:0)
03-29 19:19:43.944 21260 21355 W System.err: at androidx.camera.camera2.internal.v0$c.c(Unknown Source:0)
03-29 19:19:43.944 21260 21355 W System.err: at androidx.camera.camera2.internal.y0.apply(Unknown Source:8)
03-29 19:19:43.944 21260 21355 W System.err: at w.b.run(SourceFile:10)
03-29 19:19:43.944 21260 21355 W System.err: at androidx.camera.core.impl.utils.executor.SequentialExecutor$b.a(SourceFile:74)
03-29 19:19:43.944 21260 21355 W System.err: at androidx.camera.core.impl.utils.executor.SequentialExecutor$b.run(SourceFile:1)
03-29 19:19:43.944 21260 21355 W System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
03-29 19:19:43.944 21260 21355 W System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
03-29 19:19:43.944 21260 21355 W System.err: at java.lang.Thread.run(Thread.java:923)
03-29 19:19:43.946 21260 21345 E ReactNativeJS: { [unknown/unknown: Failed to submit capture request]
03-29 19:19:43.946 21260 21345 E ReactNativeJS: name: 'unknown/unknown',
03-29 19:19:43.946 21260 21345 E ReactNativeJS: _code: 'unknown/unknown',
03-29 19:19:43.946 21260 21345 E ReactNativeJS: _message: 'Failed to submit capture request',
03-29 19:19:43.946 21260 21345 E ReactNativeJS: _cause: undefined }
03-29 19:19:43.959 641 641 E SELinux : avc: denied { find } for pid=17248 uid=10183 name=tethering scontext=u:r:permissioncontroller_app:s0:c183,c256,c512,c768 tcontext=u:object_r:tethering_service:s0 tclass=service_manager permissive=0
03-29 19:19:43.959 641 641 E SELinux : avc: denied { find } for pid=16444 uid=1010183 name=tethering scontext=u:r:permissioncontroller_app:s0:c183,c256,c522,c768 tcontext=u:object_r:tethering_service:s0 tclass=service_manager permissive=0
03-29 19:19:43.968 881 24090 I mm-camera: <CPP >< INFO> 378: cpp_hardware_set_clock: Set clock 200000000 BW avg 194400000 BW inst 194400000
03-29 19:19:43.971 881 24112 E mm-camera: <ERROR> 831: dmlroc_init: dmlroc_init cfg: camif 3024x4032, elem 126x126, thres 0.002500, accur 8
03-29 19:19:43.971 881 24112 E mm-camera: <ERROR> 832: dmlroc_init: dmlroc_init cfg: offsetH 0, offsetV 0
03-29 19:19:43.971 881 24112 E mm-camera: <ERROR> 833: dmlroc_init: dmlroc_init mesh: rxc 13x17, subs 8, hxw 32x32, offset vert 24, horz 32
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: unknown/unknown: Failed to submit capture request, js engine: hermes, stack:
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: p@45:360
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: s@43:363
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: anonymous@2030:419
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: p@2030:863
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: anonymous@2030:419
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: n@2030:1701
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: anonymous@2030:2175
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: ?anon_0_@2029:1915
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: n@328:69
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: p@328:317
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: tryCallOne@53:15
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: anonymous@139:26
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: anonymous@142:1697
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: p@142:528
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: N@142:918
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: callReactNativeMicrotasks@142:3082
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: value@31:2942
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: anonymous@31:1051
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: value@31:2590
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: value@31:1009
03-29 19:19:43.976 21260 21346 E unknown:ReactNative: value@31:944
Camera Device
// Will update
Device
Produced in Pixel 2 XL (Android 11) Got reports of happening in other devices as well
VisionCamera Version
4.0.0-beta.10
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)
- [X] I have read the Troubleshooting Guide
- [X] I agree to follow this project's Code of Conduct
- [X] I searched for similar issues in this repository and found none.
Figured it out. await RNVisionCamera.requestCameraPermission(); was the problem. decoupling it from takePhoto thread solved the problem.