Closed iliapnmrv closed 1 month ago
You can using try another version of MLKit by editing the build.gradle
of vision-camera.
I have no idea which (or if any) other version works so, good hunting.
I'm seeing the same issue appearing at random after scanning a QR code.
Perhaps unsurprisingly, this happens whether using the com.google.android.gms/play-services-mlkit-barcode-scanning@18.3.0
or the bundled com.google.mlkit:barcode-scanning@17.2.0
.
The frequency of this issue and the numbers being reported from the field are staggering. It appears that the problem lies within the MLKit itself, rather than this specific library, though. Let's hope Google gets their act together and deals with this soon.
Also same issue after upgrading to version 3
Java_com_google_android_libraries_barhopper_BarhopperV3_recognizeBufferNative
Another reported issue that i think is related
Java_com_google_android_gms_vision_barcode_internal_NativeBarcodeDetector_recognizeBufferNative
Any updates? Having same issue.
can you guys please test if this change solves the issue for you?
remove node_modules
modify vision-camera in package.json
to be like below and see what happens
"dependencies": {
"react-native-vision-camera": "github:rodgomesc/react-native-vision-camera#cad3699"
}
Appears to be working! I will run it on others devices to confirm.
Appears to be working! I will run it on others devices to confirm.
looking forward to know if it will work then i'll send a pr, @WitchMad qualquer coisa me chama no discord user: rodgomesc
can you guys please test if this change solves the issue for you?
remove
node_modules
modify vision-camera inpackage.json
to be like below and see what happens
Thank you for the fix! I've tested it on multiple devices, and it works perfectly. go ahead and create a pull request.
does anyone get an npm error once i set "github:rodgomesc/react-native-vision-camera#cad3699"
?
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /Users/user/.npm/_cacache/tmp/git-cloneOHBQrz/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/Users/user/.npm/_cacache/tmp/git-cloneOHBQrz/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
npm ERR! A complete log of this run can be found in: /Users/user/.npm/_logs/debug-0.log
@iliapnmrv Use gitpkg
"react-native-vision-camera": "https://gitpkg.now.sh/rodgomesc/react-native-vision-camera/package?cad3699"
@iliapnmrv Use gitpkg
"react-native-vision-camera": "https://gitpkg.now.sh/rodgomesc/react-native-vision-camera/package?cad3699"
it works, thanks a lot❤️
@rodgomesc It still crashes for me on android after scanning a qr code (same on latest): cannot open libmiuindbg.so: No such file or directory
. On my device, it works with 3.6.8, but we got error reports of the BarhopperV3_recognizeBufferNative crash
11-23 10:30:50.911 1195 2550 I CHIUSECASE: [INFO ] chxperf.cpp:850 ReleasePerfLock() Release perflock type: 16
11-23 10:30:50.911 1195 2550 I CHIUSECASE: [INFO ] chxperf.cpp:1138 ReleasePerfLock() Perflock already released or not acquired
11-23 10:30:50.911 1195 2550 I CHIUSECASE: [INFO ] chxextensionmodule.cpp:1198 GetCameraIdIndex() AppId => LogicalId:0 => 0
11-23 10:30:50.911 1195 2550 E CamX : [ERROR][HAL ] camxhal3module.cpp:149 ReleaseTorchForCamera() Facing = 0.
11-23 10:30:50.911 1195 2550 E CamX : [ERROR][HAL ] camxhal3module.cpp:155 ReleaseTorchForCamera() sensor: 0, logicalCameraId: 0, facing: 0
11-23 10:30:50.911 1195 2550 I CamX : [ INFO][HAL ] camxhal3module.cpp:377 SetTorchModeInternal() forbid torchStatus 1 3 0
11-23 10:30:50.911 1195 2550 I CamX : [ INFO][HAL ] camxhal3module.cpp:385 SetTorchModeInternal() Torch notify state is (inReleaseMode = 1, dropCallbacks
= 0, logicalCameraId = 0)
11-23 10:30:50.911 1748 25093 I CameraProviderManager: Camera device device@3.5/legacy/0 torch status is now AVAILABLE_OFF
11-23 10:30:50.911 1748 25093 I CameraService: onTorchStatusChangedLocked: Torch status changed for cameraId=0, newStatus=1
11-23 10:30:50.912 14976 15002 I BpBinder: onLastStrongRef automatically unlinking death recipients:
11-23 10:30:50.958 14976 15002 I OpenGLRenderer: Davey! duration=731ms; Flags=0, FrameTimelineVsyncId=5271905, IntendedVsync=475006579992478, Vsync=475006579992478, InputEventId=0, HandleInputStart=475006580657491, AnimationStart=475006580660772, PerformTraversalsStart=475007296530876, DrawStart=475007297202751, FrameDeadline=475006596659144, FrameInterval=475006580635043, FrameStartTime=16666666, SyncQueued=475007299674782, SyncStart=475007299972386, IssueDrawCommandsStart=475007303516918, SwapBuffers=475007308849365, FrameCompleted=475007312201240, DequeueBufferDuration=77292, QueueBufferDuration=2076510, GpuCompleted=475007312201240, SwapBuffersCompleted=475007312201240, DisplayPresentTime=0,
11-23 10:30:50.958 15483 15483 F DEBUG :
11-23 10:30:50.958 15483 15483 F DEBUG : Build fingerprint: 'Xiaomi/toco_global/toco:12/SKQ1.210908.001/V13.0.4.0.SFNMIXM:user/release-keys'
11-23 10:30:50.958 15483 15483 F DEBUG : Revision: '0'
11-23 10:30:50.958 15483 15483 F DEBUG : ABI: 'arm64'
11-23 10:30:50.958 15483 15483 F DEBUG : Timestamp: 2023-11-23 10:30:50.552294286+0100
11-23 10:30:50.958 15483 15483 F DEBUG : Process uptime: 0s
11-23 10:30:50.958 15483 15483 F DEBUG : Cmdline: com.fotologusmobile
11-23 10:30:50.958 15483 15483 F DEBUG : pid: 14976, tid: 15460, name: pool-20-thread- >>> com.fotologusmobile <<<
11-23 10:30:50.958 15483 15483 F DEBUG : uid: 10523
11-23 10:30:50.958 15483 15483 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x7968145370
11-23 10:30:50.958 15483 15483 F DEBUG : x0 00000079680e0de8 x1 00000000000000d0 x2 00000079680e0f08 x3 0000000000000002
11-23 10:30:50.958 15483 15483 F DEBUG : x4 00000079680e1140 x5 00000079680e11a8 x6 b400007b00000100 x7 00000079680e19e0
11-23 10:30:50.958 15483 15483 F DEBUG : x8 0000000000000000 x9 0000000000000068 x10 000000000000005f x11 b400007996db8800
11-23 10:30:50.958 15483 15483 F DEBUG : x12 0000000000000067 x13 0000000000058370 x14 0000007968145370 x15 0000007968144e70
11-23 10:30:50.958 15483 15483 F DEBUG : x16 00000079680ed000 x17 0000007bac0f8884 x18 00000000000e05fc x19 00000079680e0f08
11-23 10:30:50.958 15483 15483 F DEBUG : x20 00000079680e0ea8 x21 00000079680e1040 x22 0000000000000068 x23 000000000000005f
11-23 10:30:50.958 15483 15483 F DEBUG : x24 b400007b01d174fc x25 0000007b24e16000 x26 0000000000000007 x27 00000079680e16f8
11-23 10:30:50.958 15483 15483 F DEBUG : x28 00000079680e1738 x29 00000000000006ef
11-23 10:30:50.958 15483 15483 F DEBUG : lr 00000079763689ec sp 00000079680e0de0 pc 0000007976368ab4 pst 0000000080000000
11-23 10:30:50.958 15483 15483 F DEBUG : backtrace:
11-23 10:30:50.958 15483 15483 F DEBUG : NOTE: Function names and BuildId information is missing for some frames due
11-23 10:30:50.958 15483 15483 F DEBUG : NOTE: to unreadable libraries. For unwinds of apps, only shared libraries
11-23 10:30:50.958 15483 15483 F DEBUG : NOTE: found under the lib/ directory are readable.
11-23 10:30:50.958 15483 15483 F DEBUG : NOTE: On this device, run setenforce 0 to make the libraries readable.
11-23 10:30:50.958 15483 15483 F DEBUG : #00 pc 0000000000128ab4 /data/user_de/0/com.google.android.gms/app_chimera/m/00000583/dl-VisionBarcode.optional_234414100400.apk
11-23 10:30:50.958 15483 15483 F DEBUG : #01 pc 00000000000812d4 /data/user_de/0/com.google.android.gms/app_chimera/m/00000583/dl-VisionBarcode.optional_234414100400.apk
11-23 10:30:50.958 15483 15483 F DEBUG : #02 pc 000000000007af18 /data/user_de/0/com.google.android.gms/app_chimera/m/00000583/dl-VisionBarcode.optional_234414100400.apk
11-23 10:30:50.958 15483 15483 F DEBUG : #03 pc 000000000007ac18 /data/user_de/0/com.google.android.gms/app_chimera/m/00000583/dl-VisionBarcode.optional_234414100400.apk
11-23 10:30:50.958 15483 15483 F DEBUG : #04 pc 000000000007b1c8 /data/user_de/0/com.google.android.gms/app_chimera/m/00000583/dl-VisionBarcode.optional_234414100400.apk
11-23 10:30:50.958 15483 15483 F DEBUG : #05 pc 0000000000079554 /data/user_de/0/com.google.android.gms/app_chimera/m/00000583/dl-VisionBarcode.optional_234414100400.apk
11-23 10:30:50.958 15483 15483 F DEBUG : #06 pc 00000000000795f4 /data/user_de/0/com.google.android.gms/app_chimera/m/00000583/dl-VisionBarcode.optional_234414100400.apk
11-23 10:30:50.958 15483 15483 F DEBUG : #07 pc 000000000034aa30 /apex/com.android.art/lib64/libart.so (art_quick_generic_jni_trampoline+144) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
11-23 10:30:50.958 15483 15483 F DEBUG : #08 pc 0000000000333fa4 /apex/com.android.art/lib64/libart.so (art_quick_invoke_stub+612) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
11-23 10:30:50.958 15483 15483 F DEBUG : #09 pc 0000000000380e60 /apex/com.android.art/lib64/libart.so (art::interpreter::ArtInterpreterToCompiledCodeBridge(art::Thread, art::ArtMethod, art::ShadowFrame, unsigned short, art::JValue)+300) (BuildId: 4cfdaa9e5146c43e20ae36ee1caf9b7f)
11-23 10:30:50.958 15483 15483 F DEBUG : #10 pc 0000000000380684 /apex/com.android.art/lib64/libart.so (bool art::interpreter::DoCall
11-23 10:30:51.018 2052 2668 I DropBoxManagerService: add tag=SYSTEM_TOMBSTONE_PROTO isTagEnabled=true flags=0x4
@rodgomesc, thanks for the solution! I tried it, but it unfortunately didn't fix the issue on my end. Still, appreciate your help! 👍
I can confirm, though, that downgrading to v3.5.1 seems to do the trick. 🎉 Here's the commit diff between v3.5.1 and v3.6.4, for the interested. I'll dig into this and see if I can make progress.
For reference and posterity, you can also track this issue via #2189 in this project, while the root cause itself, which lies within the mlkit
package, can be tracked at googlesamples/mlkit#714.
Below is what I'm seeing:
11-24 08:04:04.444 29862 29862 F DEBUG : *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
11-24 08:04:04.445 29862 29862 F DEBUG : Build fingerprint: 'samsung/a71naeea/a71:13/TP1A.220624.014/A715FXXUADWH4:user/release-keys'
11-24 08:04:04.445 29862 29862 F DEBUG : Revision: '6'
11-24 08:04:04.445 29862 29862 F DEBUG : ABI: 'arm64'
11-24 08:04:04.445 29862 29862 F DEBUG : Processor: '2'
11-24 08:04:04.445 29862 29862 F DEBUG : Timestamp: 2023-11-24 08:04:03.941381277+0100
11-24 08:04:04.445 29862 29862 F DEBUG : Process uptime: 89s
11-24 08:04:04.445 29862 29862 F DEBUG : Cmdline: [redacted]
11-24 08:04:04.445 29862 29862 F DEBUG : pid: 29378, tid: 29614, name: pool-8-thread-8 >>> [redacted] <<<
11-24 08:04:04.445 29862 29862 F DEBUG : uid: 10439
11-24 08:04:04.445 29862 29862 F DEBUG : signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 0x00000075e01ad74c
[…]
11-24 08:04:04.445 29862 29862 F DEBUG : backtrace:
11-24 08:04:04.445 29862 29862 F DEBUG : #00 pc 00000000000ed660 /data/app/~~5ZTjAHjyw9v0-g7a8S1RxQ==/[redacted]-ND50NrMo9LMyMfhybnr8LA==/lib/arm64/libbarhopper_v3.so (BuildId: cf64ac3d5cfd71b04d3bc4112d678e48)
Same error happened to me on v3.6.9
. Going back to v3.5.1
seems to solve this issue.
Heyo! Does https://github.com/mrousavy/react-native-vision-camera/pull/2355 maybe fix your issue?
still seems to be an issue in 3.7.0 .. Tried both VisionCamera_enableCodeScanner=true and VisionCamera_enableCodeScanner=false Samsung device (SDK 33)
I have the same problem, happens to around 4% of my users - so pretty frequent. 3.7.0 did not solve this issue.
I'm seeing some reports of this crash coming from my prod app (vision-camera v3.6.17).
I can reproduce it on roughly 25% of my barcode scans...crashes right after the successful scan.
Update: Tried out 3.7.0...no difference.
@rodgomesc did you ever make a PR for this fix?
@parlet I just went thru the changes again and nothing seems to be related to the CodeScanner.
I don't know why this is happening, on my test devices it does not happen so I currently cannot reproduce this.
If you / your company absolutely needs this fixed, consider contracting me/my agency to fix this issue
@mrousavy, Yeah, I remember doing a cursory run through the code diffs before, and I didn't see anything that would attract my attention either, although of course I don't have an in-depth knowledge of the code base.
I hope I'll find some time to debug this issue and dig deeper into what within this library might help, although ultimately, the problem lies in the libbarhopper_v3.so
and that's where we'd ideally find the solution. Something tells me this might be a race condition.
Anyway, thank you very much for your attention to this issue. =) Just let me know If there is anything more I could assist with.
I might have found a way to avoid or minimize this. I'm curious if others are doing what I was and unmounting the camera component/navigating away right after they get a scan. I can't seem to reproduce the crash anymore after:
isActive={false}
on the camera after I get a scanGive this a shot in your apps. I'm on v3.8.0
now.
I might have found a way to avoid or minimize this. I'm curious if others are doing what I was and unmounting the camera component/navigating away right after they get a scan. I can't seem to reproduce the crash anymore after:
- Setting
isActive={false}
on the camera after I get a scan- Inserting a brief setTimeout delay of 500ms before calling my Navigation.dismiss
Give this a shot in your apps. I'm on
v3.8.0
now.
I will try this - we are using the camera in many different workflows - this means going from one camera instance to the next pretty rapidly. Currently i have minimised the errors by waiting 100 m/s on viewDidMount to initialise the camera.
I'm still getting reports of it in prod even on 3.5.1 for what it's worth, although definitely seems less frequent
By the way, for tracking purposes, this bug is logged in the Google's public issue tracker as #294890843 and #314930525. We may have better luck if we tackle this issue at its source.
I can also seem to reproduce this every once in a while by simply backgrounding the app while the camera view is active, then resuming the app. On the occasional resume, this crash will occur right away.
Agree that we should comment on the Google Issue Tracker instead - this does not seem like an issue on my end. See the issues #294890843 and #314930525.
Also this guy: https://github.com/googlesamples/mlkit/issues/714
I'm hitting this as well (tried both 3.8.2
and 3.9.0-beta.0
) when using my barcode scanner plugin that leverages a frame processor and that relies as well on Google MLKit. Can be reproduced pretty quickly with a hard mount/unmount interval, so I guess it's on MLKit side, but still interesting what changes lead to an increase in reports.
useEffect(() => {
const interval = setInterval(() => {
setIsMounted(prevIsMounted => {
console.log({isMounted: !prevIsMounted});
return !prevIsMounted;
});
}, 3000);
return () => {
clearInterval(interval);
};
}, []);
Java_com_google_android_libraries_barhopper_BarhopperV3_recognizeBufferNative. Getting the same issue in production, It occurs randomly while scanning and navigating between screens.
I didn't have time to look deeply into this, but FWIW react-native-camera-kit
uses the same MLKit version and doesn't crash in production while scanning QRs.
I've done some experimentation today:
This seem to indicate a race condition when closing down the code reader, or that it's trying to work with image buffers which are freed when closing the camera.
I open/close the camera using isActive
Google seems to recommend using acquireLatestImage()
instead of acquireNextImage()
, but this didn't seem make any difference in my testing (not sure that my changes actually compiled properly using Expo, so this is still untested).
This function is recommended to use over [acquireNextImage()](https://developer.android.com/reference/android/media/ImageReader#acquireNextImage()) for most use-cases, as it's more suited for real-time processing.
Might be worth trying the latest 4.0.0-beta.10
as it seems to have fixed this race condition issues when unmounting the camera, see https://github.com/mrousavy/react-native-vision-camera/issues/2341#issuecomment-2018139327.
Hey - I think this issue has been fixed in VisionCamera 4.0.0. 🥳
Please try V4 and let me know if you still experience this issue;
I haven't been able to crash v4 yet, this issue seems fixed! 🎉
@oscar-b did you upgrade your ReactNative version to use 4.0?
@oscar-b did you upgrade your ReactNative version to use 4.0?
RNVC v4.0.1 yes.
No I mean the React Native version to 0.72.3?
No I mean the React Native version to 0.72.3?
No Expo v50, using v0.73.6
What's happening?
I'm using react-native-vision-camera
v3.6.4
. On QR code scan I get google mlkit errorJava_com_google_android_libraries_barhopper_BarhopperV3_recognizeBufferNative
. I've found known issues in mlkit repository. Do you have any ideas?Did not have any issues on
v3.5.1
Sentry error here may be useful
Reproduceable Code
Relevant log output
Camera Device
Device
Android Samsung, Honor, Huawei, Redmi
VisionCamera Version
3.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