mrousavy / react-native-vision-camera

📸 A powerful, high-performance React Native Camera library.
https://react-native-vision-camera.com
MIT License
7.35k stars 1.07k forks source link

🐛 [Code Scanner][IOS] The codeType "qr" is not supported by the Code Scanner #2016

Closed iliapnmrv closed 11 months ago

iliapnmrv commented 11 months ago

What's happening?

I've updated to react-native-vision-camera@v3.4.0 but camera throws error

[code-scanner/code-type-not-supported: The codeType "qr" is not supported by the Code Scanner!]

I get the same error with other codeTypes

I use react-native v0.72.5

Reproduceable Code

const deviceBack = useCameraDevice('back');

const codeScanner: CodeScanner = {
   codeTypes: ['qr'],
   onCodeScanned: codes => {
     const [code] = codes;
     onBarcodeDetected?.(code.value);
   },
};

<Camera
  ref={camera}
  zoom={1}
  device={deviceBack}
  isActive={true}
  codeScanner={codeScanner}
  onError={e => console.log(e)}
/>

Relevant log output

No useful info in Xcode logs

Camera Device

basic IPhone 14 Pro JSON, takes too much space. I might create a json file link if needed

Device

iPhone 14 Pro (iOS 17.0.3)

VisionCamera Version

3.4.0

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

mrousavy commented 11 months ago

No useful info in Xcode logs

I need the logs.

mrousavy commented 11 months ago

This is where I parse QR: https://github.com/mrousavy/react-native-vision-camera/blob/3b1d8353a5b723e6ae488d23ad79e9f567f9ade8/package/ios/Parsers/AVMetadataObject.ObjectType%2Bdescriptor.swift#L43-L45

iliapnmrv commented 11 months ago

No useful info in Xcode logs

I need the logs.

Sorry, I could not find any, can you please explain where exactly are logs for RNVC located?

joacub commented 11 months ago

same here, this is introduced in the new update, it was working before

joacub commented 11 months ago

any coed is supported

joacub commented 11 months ago

@mrousavy this may be useful for you

default 19:48:26.654983-0400    sharingd    Lost IDS device DBDEA35E-6A14-40E9-8D26-771C74DF8917
default 19:48:26.655482-0400    sharingd    Starting Handoff CopyPaste scanning with duplicates:NO for peers [A41C86CC-D050-ADA7-0ED5-73EB8EFFC81B, BA7EF69E-5354-C276-5CBA-777E1BC76E24]
default 19:48:26.655781-0400    useractivityd   [SFContinuityScanManager] Lost device <SFPeerDevice: 0x6748299b0, uniqueID:DBDEA35E-6A14-40E9-8D26-771C74DF8917, modelIdentifier:MacBookPro18,2, name:Johan’s MacBook Pro>. Handled:YES
default 19:48:26.655834-0400    useractivityd   lostDevice, deviceIdentifier=<private> scanner=<SFActivityScanner: 0x674c068e0>
default 19:48:26.655890-0400    identityservicesd   startScanningForType:Activity withData:(null) mask:(null) peers:<private> boostedScan:NO duplicates:NO
default 19:48:26.656176-0400    identityservicesd   Continuity start scanning with data: scan request of type 12, blob: {length = 0, bytes = 0x}, mask {length = 0, bytes = 0x}, active: 0, duplicates: 0, screen on: 300, screen off: No Scan, locked: 1,  rssi: -90, peers: (
    "A41C86CC-D050-ADA7-0ED5-73EB8EFFC81B",
    "BA7EF69E-5354-C276-5CBA-777E1BC76E24"
) nearby scan mode: 10, advbuf: 0, priority critical: 0, range: 0, retain duplicates: 0, usecases:
default 19:48:26.656507-0400    bluetoothd  Start scanning for process identityservicesd (60) with scan request of type 12, blob: {length = 0, bytes = 0x}, mask {length = 0, bytes = 0x}, active: 0, duplicates: 0, screen on: 300, screen off: No Scan, locked: 1,  rssi: -90, peers: (
    "A41C86CC-D050-ADA7-0ED5-73EB8EFFC81B",
    "BA7EF69E-5354-C276-5CBA-777E1BC76E24"
) nearby scan mode: 10, advbuf: 0, priority critical: 0, range: 0, retain duplicates: 0, usecases:
default 19:48:26.656533-0400    bluetoothd  Adding scan request called
default 19:48:26.656646-0400    bluetoothd  Adding scan request scan request of type 12, blob: {length = 22, bytes = 0x00000000000000000000000000000000000000000000}, mask {length = 22, bytes = 0x00000000000000000000000000000000000000000000}, active: 0, duplicates: 0, screen on: 300, screen off: No Scan, locked: 1,  rssi: -90, peers: (
    "A41C86CC-D050-ADA7-0ED5-73EB8EFFC81B",
    "BA7EF69E-5354-C276-5CBA-777E1BC76E24"
) nearby scan mode: 10, advbuf: 0, priority critical: 0, range: 0, retain duplicates: 0, usecases:  for client 1BFC56AD-535D-4B80-9B12-2977E5626D03
default 19:48:26.656840-0400    bluetoothd  Passively scanning for devices of types: 4 7 12 15 16 (Window: 30/Interval: 300)
default 19:48:26.656894-0400    bluetoothd  About to scan for type: 16 - rssi: -75 - range: 0 - payload: {length = 22, bytes = 0x00000000000000000000000000000000000000000000} - mask: {length = 22, bytes = 0x00000000000000000000000000000000000000000000} - peers: 2, bundleID: <private>
default 19:48:26.657010-0400    bluetoothd  About to scan for type: 15 - rssi: -70 - range: 1 - payload: {length = 22, bytes = 0x00000000000000000000000000000000000000000000} - mask: {length = 22, bytes = 0x00000000000000000000000000000000000000000000} - peers: 0, bundleID: <private>
default 19:48:26.657133-0400    bluetoothd  About to scan for type: 7 - rssi: -70 - range: 0 - payload: {length = 22, bytes = 0x00000000000000000000000000000000000000000000} - mask: {length = 22, bytes = 0x00000000000000000000000000000000000000000000} - peers: 0, bundleID: <private>
default 19:48:26.657308-0400    bluetoothd  About to scan for type: 12 - rssi: -90 - range: 0 - payload: {length = 22, bytes = 0x00000000000000000000000000000000000000000000} - mask: {length = 22, bytes = 0x00000000000000000000000000000000000000000000} - peers: 2, bundleID: <private>
default 19:48:26.657392-0400    bluetoothd  About to scan for type: 4 - rssi: -40 - range: 0 - payload: {length = 22, bytes = 0x00000000000000000000000000000000000000000000} - mask: {length = 22, bytes = 0xff000000000000000000000000000000000000000000} - peers: 0, bundleID: (null)
default 19:48:26.657555-0400    bluetoothd  Scan options changed: 1
default 19:48:26.657660-0400    bluetoothd  Received XPC message "CBMsgIdStopScan" from session "com.apple.bluetoothd-central-91-2"
default 19:48:26.657905-0400    identityservicesd   calling continuityDidStartScanningForType:Activity
default 19:48:26.660546-0400    backboardd  BaselineHarmony: Current strength: 0.270000, ALSStrength: 0.270000, AppStrength: 0.270000
default 19:48:26.662301-0400    bluetoothd  BT Stats for metric '<private>' sent to CoreAnalytics with result 0
default 19:48:26.662342-0400    bluetoothd  BT Stats for metric '<private>' sent to CoreAnalytics with result 0
default 19:48:26.662380-0400    bluetoothd  BT Stats for metric '<private>' sent to CoreAnalytics with result 0
default 19:48:26.662420-0400    bluetoothd  Received 'stop scan' request from session "com.apple.bluetoothd-central-91-2" (Wiprox) updateScanParams:YES shouldUpdateState:YES
default 19:48:26.662467-0400    bluetoothd  ShouldScan=1 AnyValidScanRequests=1 anyValidScanRequestInPaused=0 fObserverState=Active ClientScanPowerAssertRequired=0 fScanFiltersNeedUpdagint=1
default 19:48:26.662487-0400    bluetoothd  updateADVBufferConfig current:03 new:03 configChanged:00
default 19:48:26.662508-0400    bluetoothd  enableObjectDiscoveryADVBuffersIfNeeded objectDiscoveryHwAdvBufferOnly:1 fScreenState:1
default 19:48:26.662528-0400    bluetoothd  AOPBTBUFF config current:0 new:0 configChanged:0
default 19:48:26.662549-0400    bluetoothd  enableAOPBTBuffersIfNeeded haveAnyHwAOPBTBufferRequests:0 fScreenState:1 fAOPBTBufferReadInProgress:0
default 19:48:26.662570-0400    bluetoothd  bomEnabled:1 chipset:23 usecase:FindMyNotOptedInBeepOnMoveWaking fScreenState:1
default 19:48:26.662614-0400    bluetoothd  updateAgentScanUseCaseEntry controllerSupportsScanRx:0 session:<private> usecase:FindMyNotOptedInBeepOnMoveWaking previous:<private> entry:<private>
default 19:48:26.662638-0400    bluetoothd  bomEnabled:1 chipset:23 usecase:FindMyNotOptedIn fScreenState:1
default 19:48:26.662676-0400    bluetoothd  updateAgentScanUseCaseEntry controllerSupportsScanRx:0 session:<private> usecase:FindMyNotOptedIn previous:<private> entry:<private>
default 19:48:26.662715-0400    bluetoothd  updateAgentScanUseCaseEntry controllerSupportsScanRx:0 session:<private> usecase:FindMyOptedIn previous:<private> entry:<private>
default 19:48:26.662754-0400    bluetoothd  updateAgentScanUseCaseEntry controllerSupportsScanRx:0 session:<private> usecase:FindMyOptedIn previous:<private> entry:<private>
default 19:48:26.662777-0400    bluetoothd  bomEnabled:1 chipset:23 usecase:FindMyNotOptedIn fScreenState:1
default 19:48:26.662797-0400    bluetoothd  updateAgentScanUseCaseEntry controllerSupportsScanRx:0 session:<private> usecase:FindMyNotOptedIn previous:<private> entry:<private>
default 19:48:26.663130-0400    bluetoothd  ObjectDiscovery Client (com.apple.locationd-central-69-61) HWADVBufferIntervalMs:300.000000 HWADVBufferWindowMs:30.000000 _interval:300 _window:30 _active:0 specifiedParams:1
default 19:48:26.663197-0400    bluetoothd  ObjectDiscovery Client (com.apple.locationd-central-69-43) HWADVBufferIntervalMs:300.000000 HWADVBufferWindowMs:30.000000 _interval:300 _window:30 _active:0 specifiedParams:1
default 19:48:26.663261-0400    bluetoothd  ObjectDiscovery Client (com.apple.locationd-central-69-53) HWADVBufferIntervalMs:300.000000 HWADVBufferWindowMs:30.000000 _interval:300 _window:30 _active:0 specifiedParams:1
default 19:48:26.663348-0400    bluetoothd  ObjectDiscovery Client (com.apple.locationd-central-69-68) HWADVBufferIntervalMs:300.000000 HWADVBufferWindowMs:30.000000 _interval:300 _window:30 _active:0 specifiedParams:1
default 19:48:26.663461-0400    bluetoothd  ObjectDiscovery Client (com.apple.locationd-central-69-41) HWADVBufferIntervalMs:300.000000 HWADVBufferWindowMs:30.000000 _interval:300 _window:30 _active:0 specifiedParams:1
default 19:48:26.663491-0400    bluetoothd  ScanParams: numScanAgents 7, combined params AD:0 RD:0 AS:0 PHYS:1 MSL:4 (30/300) PSV:0 Rg:0 Cri:0 pBT:0 pWiFi:0 pCfg:0 type:0
default 19:48:26.663515-0400    bluetoothd  ScanParams: [com.apple.sharingd-central-67-141] AP:0 AD:0(30/300) AS:0 RAS:0 DMN:1 FG:0 ADVBF:0(0/0) Rg:0 Cri:0 pBT:0 pwrAsrt:0 CT:0 type:0 level:3|[com.apple.locationd-central-69-61] AP:0 AD:1(0/0) AS:0 RAS:0 DMN:1 FG:0 ADVBF:1(30/300) Rg:0 Cri:0 pBT:0 pwrAsrt:0 CT:0 type:0 level:3|[com.apple.locationd-central-69-43] AP:0 AD:1(0/0) AS:0 RAS:0 DMN:1 FG:0 ADVBF:1(30/300) Rg:0 Cri:0 pBT:0 pwrAsrt:0 CT:0 type:0 level:3
default 19:48:26.663537-0400    bluetoothd  ScanParams: [com.apple.locationd-central-69-53] AP:0 AD:1(0/0) AS:0 RAS:0 DMN:1 FG:0 ADVBF:1(30/300) Rg:0 Cri:0 pBT:0 pwrAsrt:0 CT:0 type:0 level:3|[CBDaemon-0x82D20026] AP:0 AD:0(30/300) AS:0 RAS:0 DMN:1 FG:0 ADVBF:0(0/0) Rg:0 Cri:0 pBT:0 pwrAsrt:0 CT:0 type:0 level:1|[com.apple.locationd-central-69-68] AP:0 AD:1(0/0) AS:0 RAS:0 DMN:1 FG:0 ADVBF:1(30/300) Rg:0 Cri:0 pBT:0 pwrAsrt:0 CT:0 type:0 level:2
default 19:48:26.663557-0400    bluetoothd  ScanParams: [com.apple.locationd-central-69-41] AP:0 AD:1(0/0) AS:0 RAS:0 DMN:1 FG:0 ADVBF:1(30/300) Rg:0 Cri:0 pBT:0 pwrAsrt:0 CT:0 type:0 level:3
default 19:48:26.663625-0400    bluetoothd  Returning scan parameters: Main:30.00ms/300.00ms LP:0.00ms/300.00ms(supported) SC:0.00ms/50.00ms/non-concurrent(supported) Dm:(m:30/300) Cond:0:1:1:0:0 Sc:1 (passive) Dupfilter:Enabled minScanLevel:4 HD:Yes Comp:No(50,1) Pri:0/0
default 19:48:26.663670-0400    bluetoothd  needToRestart=1
default 19:48:26.663785-0400    bluetoothd  stopTrackingForSession: com.apple.bluetoothd-central-91-2 for tracking devices (null) from requests {
}
default 19:48:26.663826-0400    bluetoothd  Now tracking {
} with devices {(
)}
default 19:48:26.663883-0400    bluetoothd  Stopping scan for session "com.apple.bluetoothd" - 119 advertisements delivered
default 19:48:26.663937-0400    bluetoothd  Received XPC message "CBMsgIdScan" from session "com.apple.bluetoothd-central-91-2"
default 19:48:26.664083-0400    bluetoothd  Setting client list to <private>
default 19:48:26.664304-0400    bluetoothd  fShouldRetainDupsNextUpdate 0, screen? 1, retaindup? 0, EN scans? 0, created[EN]=0
default 19:48:26.664324-0400    bluetoothd  EN is not active - new retain dups value 0
default 19:48:26.664444-0400    bluetoothd  Creating a match table with handle 100 for type 15 and mask: 0
HaidarZ commented 11 months ago

Confirmed, QR code stopped working on iOS with v3.4.0

tmoran-stenoa commented 11 months ago

I don't know much about native iOS dev, but it appears the problem is that in the configureOutputs() function of CameraSession+Configuration.swift, the captureSession.addOutput(codeScannerOutput) line needs to come before checking the types, as per this SO post.

It works for me when I put the line above.

JeyongOh-MAASASIA commented 11 months ago

+1 @tmoran-stenoa Can you share me the diff of your work?

W1MMER commented 11 months ago

I'm having the same issue. When "qr" or "ean-13" is specified in the codeTypes array, the camera won't start.

Here's some logs from Xcode:

Screenshot 2023-10-17 at 8 10 01 PM Screenshot 2023-10-17 at 8 08 17 PM

Edit: Downgrading to 3.3.1 fixed it.

maslovay commented 11 months ago

Same issue

celik75 commented 11 months ago

Same on ios, camera won't start and shows white screen

tmoran-stenoa commented 11 months ago

+1 @tmoran-stenoa Can you share me the diff of your work?

@JeyongOh-MAASASIA I barely know any Swift and much less the iOS SDKs, so I wouldn't recommend this for a production app. Also, fortunately, this repo seems to be quite actively maintained, so it'll probably get properly fixed soon. But if you want a hotfix ASAP, this will work:

diff --git a/node_modules/react-native-vision-camera/ios/Core/CameraSession+Configuration.swift b/node_modules/react-native-vision-camera/ios/Core/CameraSession+Configuration.swift
index 0a12698..c48133b 100644
--- a/node_modules/react-native-vision-camera/ios/Core/CameraSession+Configuration.swift
+++ b/node_modules/react-native-vision-camera/ios/Core/CameraSession+Configuration.swift
@@ -125,6 +125,12 @@ extension CameraSession {
       ReactLogger.log(level: .info, message: "Adding Code Scanner output...")
       let codeScannerOutput = AVCaptureMetadataOutput()

+      // 2. Add
+      guard captureSession.canAddOutput(codeScannerOutput) else {
+        throw CameraError.codeScanner(.notCompatibleWithOutputs)
+      }
+      captureSession.addOutput(codeScannerOutput)
+
       // 1. Configure
       let options = codeScanner.options
       try codeScanner.options.codeTypes.forEach { type in
@@ -138,11 +144,6 @@ extension CameraSession {
         codeScannerOutput.rectOfInterest = rectOfInterest
       }

-      // 2. Add
-      guard captureSession.canAddOutput(codeScannerOutput) else {
-        throw CameraError.codeScanner(.notCompatibleWithOutputs)
-      }
-      captureSession.addOutput(codeScannerOutput)
       self.codeScannerOutput = codeScannerOutput
     }

It essentially swaps the "1. Configure" and "2. Add" blocks.

maslovay commented 11 months ago

@tmoran-stenoa it works, thank you a lot!

AndrySquirrel commented 11 months ago

I don't know much about native iOS dev, but it appears the problem is that in the configureOutputs() function of CameraSession+Configuration.swift, the captureSession.addOutput(codeScannerOutput) line needs to come before checking the types, as per this SO post.

It works for me when I put the line above.

Yes it works for me too thank you @tmoran-stenoa

mrousavy commented 11 months ago

Hi - few things:

  1. Thanks for reporting the issue and providing more details.
  2. Thanks to @tmoran-stenoa for finding the issue, I noticed that in my YT stream as well but didn't leave a comment there so I must've forgot it already again. I should add a comment there.
  3. Why do you guys keep posting local patches instead of just submitting a PR here? This is the bare minimum you can do to provide back to the project, a PR is really quickly created. Instead you guys keep sharing local patches and leave the issue open, effectively never fixing it. Open-source only works if we collaborate, either by sponsoring me on GitHub to thank me for my work and the amount of time I allocate to help you ship better apps (which makes you money), or by submitting PRs here and contributing back to the project.

Anyways, I did the work and created a PR, will merge this to main and release soon.

mrousavy commented 11 months ago

Also, fortunately, this repo seems to be quite actively maintained, so it'll probably get properly fixed soon

🙃

mrousavy commented 11 months ago

Sorry, I could not find any, can you please explain where exactly are logs for RNVC located?

@iliapnmrv this is what you saw when you clicked on "Create Issue":

image

KristianSelnas commented 11 months ago

@mrousavy When are you planning to make a release where this is included?

Superb work in this library, btw. And kudos for adding code scanning support without plugins 👍

celik75 commented 11 months ago

After updating to 3.4.0

it works great, however i tested on some different androids phones. samsung S20, the camera is sometimes not full screen, leaves a white bar at the bottom, when switching navigation it sometimes fix it or by changing orientation landscape to portraid again fills the camera screen. (by doing this serval times)

Samsung a50, starts with black screen and crashes if you click/touch anywhere on the screen. Since these phones are tested on my colleges by sending them the apk, i don't have the logs. And some other androids the camera starts with white screen changing navigations trigger the isActive.

When i test on my own iphone/android(s20) there are no errors or warnings.

I am using reactnavigation maybe it conflicts with this. il try to release one without the reactnavigation and see if the problems still persists

mrousavy commented 11 months ago

@celik75 that's a completely different issue.

samsung S20, the camera is sometimes not full screen, leaves a white bar at the bottom, when switching navigation it sometimes fix it or by changing orientation landscape to portraid again fills the camera screen

Anyways, I can still try to at least help you a little, does it work if you change this line to false and then rebuild and test? https://github.com/mrousavy/react-native-vision-camera/blob/764897dcf119e26668b9fb6c6eb78f0e2993ffd1/package/android/src/main/java/com/mrousavy/camera/CameraView.kt#L117

Samsung a50, starts with black screen and crashes if you click/touch anywhere on the screen

No idea, this is something where I absolutely need the logs. Or you can buy me that phone itself and I'll fix it.

mrousavy commented 11 months ago

I just released VisionCamera 3.4.1 which fixes the issue with the QR Code Scanner now! 💪

vaibsshukla commented 4 months ago

This issue is still pending in iOS it shows

{ [code-scanner/code-type-not-supported: The codeType "qr" is not supported by the Code Scanner!] name: 'code-scanner/code-type-not-supported', _code: 'code-scanner/code-type-not-supported', _message: 'The codeType "qr" is not supported by the Code Scanner!', _cause: undefined }

Affected Version 3.9.2