react-native-vision-camera: šApp crashed after scanning a qrcode
Whatās happening?
I have a crash after scanning the QR code. I havenāt found the reason yet. I have released the relevant code and logs. I hope someone can answer it.
Reproduceable Code
const onAuth = async () => {
const grantedStatus = await Camera.requestCameraPermission();
if (grantedStatus === 'granted') {
setHasCameraPermit(true);
} else {
setHasCameraPermit(false);
}
};
useEffect(() => {
onAuth();
}, []);
const codeScanner = useCodeScanner({
codeTypes: ['qr'],
onCodeScanned: codeData => {
if (codeData[0].value) {
verificationCodeData.current = codeData[0].value;
if (source === 'fromScanIcon') {
scanCodeFromScanIcon();
} else if (source === 'fromBindButton') {
scanCodeFromBindButton();
}
}
},
});
{device != null && HasCameraPermit (
<Camera
photo={false}
video={false}
isActive={isFocused}
device={device}
codeScanner={codeScanner}
style={StyleSheet.absoluteFill}
torch={TorchMode}
/>
)}
Relevant log output
--------- beginning of crash
2023-11-21 11:34:14.044 18948-22275 libc com.scan A Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x77c20bc0f7 in tid 22275 (pool-10-thread-), pid 18948 (com.scan)
2023-11-21 11:34:14.078 18948-22278 BufferQueueProducer com.scan E [ImageReader-1280x720f23m2-18948-18](id:4a040000001e,api:4,p:1554,c:18948) queueBuffer: BufferQueue has been abandoned
2023-11-21 11:34:14.086 18948-22368 BufferQueueProducer com.scan E [ImageReader-1280x720f23m2-18948-18](id:4a040000001e,api:4,p:1554,c:18948) queueBuffer: BufferQueue has been abandoned
2023-11-21 11:34:14.117 18948-22368 BufferQueueProducer com.scan E [ImageReader-1280x720f23m2-18948-18](id:4a040000001e,api:4,p:1554,c:18948) queueBuffer: BufferQueue has been abandoned
2023-11-21 11:34:14.185 18948-18961 BufferQueueProducer com.scan E [ImageReader-1280x720f23m2-18948-18](id:4a040000001e,api:4,p:1554,c:18948) queueBuffer: BufferQueue has been abandoned
2023-11-21 11:34:14.189 18948-22278 BufferQueueProducer com.scan E [ImageReader-1280x720f23m2-18948-18](id:4a040000001e,api:4,p:1554,c:18948) queueBuffer: BufferQueue has been abandoned
2023-11-21 11:34:14.216 18948-22278 BufferQueueProducer com.scan E [ImageReader-1280x720f23m2-18948-18](id:4a040000001e,api:4,p:1554,c:18948) queueBuffer: BufferQueue has been abandoned
---------------------------- PROCESS STARTED (24847) for package com.scan ----------------------------
2023-11-21 11:34:14.249 18948-22278 BufferQueueProducer com.scan E [ImageReader-1280x720f23m2-18948-18](id:4a040000001e,api:4,p:1554,c:18948) queueBuffer: BufferQueue has been abandoned
2023-11-21 11:34:14.284 18948-22278 BufferQueueProducer com.scan E [ImageReader-1280x720f23m2-18948-18](id:4a040000001e,api:4,p:1554,c:18948) queueBuffer: BufferQueue has been abandoned
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A Cmdline: com.scan
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A pid: 18948, tid: 22275, name: pool-10-thread- >>> com.scan <<<
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #00 pc 00000000000ed660 /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/lib/arm64/libbarhopper_v3.so (BuildId: cf64ac3d5cfd71b04d3bc4112d678e48)
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #01 pc 00000000000d03c8 /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/lib/arm64/libbarhopper_v3.so (BuildId: cf64ac3d5cfd71b04d3bc4112d678e48)
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #02 pc 00000000000ca240 /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/lib/arm64/libbarhopper_v3.so (BuildId: cf64ac3d5cfd71b04d3bc4112d678e48)
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #03 pc 00000000000c9f64 /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/lib/arm64/libbarhopper_v3.so (BuildId: cf64ac3d5cfd71b04d3bc4112d678e48)
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #04 pc 00000000000ca4f0 /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/lib/arm64/libbarhopper_v3.so (BuildId: cf64ac3d5cfd71b04d3bc4112d678e48)
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #05 pc 00000000000c8aa4 /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/lib/arm64/libbarhopper_v3.so (BuildId: cf64ac3d5cfd71b04d3bc4112d678e48)
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #06 pc 00000000000c8b44 /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/lib/arm64/libbarhopper_v3.so (Java_com_google_android_libraries_barhopper_BarhopperV3_recognizeBufferNative+84) (BuildId: cf64ac3d5cfd71b04d3bc4112d678e48)
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #14 pc 00000000001e890c [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #20 pc 0000000000295758 [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #26 pc 000000000029585a [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #32 pc 00000000001ac93c [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #38 pc 00000000001ac12a [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #47 pc 0000000000187c8a [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #53 pc 00000000001a9f2e [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #59 pc 0000000000299036 [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #65 pc 00000000002983bc [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #71 pc 0000000000298388 [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #77 pc 000000000029ba2a [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #83 pc 000000000029bf20 [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #89 pc 0000000000290362 [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #95 pc 0000000000294f24 [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #101 pc 00000000002950f4 [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #107 pc 000000000029009a [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #110 pc 000000000029003c [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.531 24845-24845 DEBUG pid-24845 A #115 pc 0000000000294e0c [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.532 24845-24845 DEBUG pid-24845 A #126 pc 0000000000290068 [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
2023-11-21 11:34:14.532 24845-24845 DEBUG pid-24845 A #129 pc 0000000000294d90 [anon:dalvik-classes6.dex extracted in memory from /data/app/~~Pua-MPb3_YSekKggq0wYvw==/com.scan-GEIEq0XRBLMCfIwCAOPiMw==/base.apk!classes6.dex]
---------------------------- PROCESS ENDED (18948) for package com.scan ----------------------------
2023-11-21 11:34:14.683 3202-3600 DollieAdapterService pid-3202 E notifyActivityState pkg:com.scan/com.scan.MainActivity state:19 fg:false mUid:10304
---------------------------- PROCESS ENDED (24847) for package com.scan ----------------------------
Camera Device
{"hardwareLevel": "full", "hasFlash": true, "hasTorch": true, "id": "0", "isMultiCam": false, "maxZoom": 8, "minZoom": 1, "name": "BACK (0)", "neutralZoom": 1, "physicalDevices": ["wide-angle-camera"], "position": "back", "sensorOrientation": "landscape-right", "supportsFocus": true, "supportsLowLightBoost": true, "supportsRawCapture": true}
Device
honor 70
VisionCamera Version
v3.6.4
Can you reproduce this issue in the VisionCamera Example app?
Yes, I can reproduce the same issue in the Example app here
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 7 months ago
- Reactions: 4
- Comments: 71 (20 by maintainers)
Version: 3.6.8
It occurred to me as well. I tried to debug this, and it seems to be a race condition.
The issue is because of the function below. When I change
runBlocking
tolaunch(Dispatchers.Main)
to make it run on the main thread, it works.com.mrousavy.camera.core.CameraSession#destroyPreviewOutputSync
You should import
Dispatchers
by yourself.import kotlinx.coroutines.Dispatchers
I looked up issue 2090 and someone answered that changing react-native-vison-camera to version 3.5.1 works fine. So I tried lowering the version. Fortunately, I scanned the qrcode from afternoon to now, the app will not crash when scanning the qrcode.ļ¼(I tried upgrading to v3.6.6 and v3.6.8 yesterday, and also tried downgrading to v3.6.0, but there was always a crashļ¼
@sunnystarh I can confirm downgrading to
v.3.5.1
resolves this issue for now.can you guys please test if this change solves the issue for you? @yasirlateef @apadev666
node_modules
package.json
@apadev666 why?
Iāve added #2213 with more information there.
@Hector-Chong
Have you observed an ANR with your fix? I am now observing an ANR (Application Not Responding) when Camera Session is closed (after barcode scanning), and this has to do with
runBlocking
function.When
CameraView
is destroyed, it callscameraSession.close()
which has the following code block:We use sentry to log errors. Here is some of our sentry log:
Please change this locally and test it.
@apadev666 this could happen for a number of reasons. Firstly, it could happen if you donāt configure your camera properly. Try removing all the props except for the required ones and try adding them one-by-one to see what breaks.