Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug report] IOS crash on BarcodeScanner.startScan() #905

Open
qliqdev opened this issue Dec 27, 2024 · 0 comments
Open

[Bug report] IOS crash on BarcodeScanner.startScan() #905

qliqdev opened this issue Dec 27, 2024 · 0 comments

Comments

@qliqdev
Copy link

qliqdev commented Dec 27, 2024

Describe the bug
Here is Xcode log

⚡️  To Native ->  BarcodeScanner checkPermissions 100522241
⚡️  TO JS undefined
⚡️  TO JS {"camera":"granted"}
⚡️  To Native ->  BarcodeScanner addListener 100522242
⚡️  To Native ->  BarcodeScanner startScan 100522243
*** Terminating app due to uncaught exception 'NSGenericException', reason: '*** -[AVCaptureSession startRunning] startRunning may not be called between calls to beginConfiguration and commitConfiguration'
*** First throw call stack:
(0x1a0aecf20 0x1989932b8 0x1bdc01bd8 0x1048d4950 0x106622c14 0x106622c94 0x107bb4b98 0x107bb67bc 0x107bcad18 0x107bcb4d8 0x1fd53c8f8 0x1fd5390cc)
⚡️  TO JS undefined
⚡️  To Native ->  BarcodeScanner getMinZoomRatio 100522244
⚡️  To Native ->  BarcodeScanner getMaxZoomRatio 100522245
⚡️  TO JS {"zoomRatio":1}
⚡️  TO JS {"zoomRatio":121.875}
libc++abi: terminating due to uncaught exception of type NSException

To Reproduce

const start = async () => {
    const status = await BarcodeScanner.checkPermissions();
    if (status.camera === 'denied') {
      const c = confirm('GrantCameraPermissions');
      if (c) {
        await BarcodeScanner.openSettings();
      }
    } else if (status.camera === 'prompt' || status.camera === 'prompt-with-rationale') {
      await BarcodeScanner.requestPermissions();
    }

    const listener = await BarcodeScanner.addListener(
      'barcodeScanned',
      async res => {
        await listener.remove();
        console.log(res);
      },
    );
  
    await BarcodeScanner.startScan();
    void BarcodeScanner.getMinZoomRatio().then((z) => {
      console.log(z.zoomRatio);
    });
    void BarcodeScanner.getMaxZoomRatio().then((z) => {
      console.log(z.zoomRatio);
    });
}

Expected behavior

AVCaptureSession *session = [[AVCaptureSession alloc] init];

[session beginConfiguration];
AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
NSError *error = nil;
AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:&error];

if (input) {
    [session addInput:input];
} else {
    NSLog(@"Error: %@", error);
}

// AVCaptureMetadataOutput config

[session commitConfiguration];

// Then start session
[session startRunning];

SDK Info:

  • "@capacitor-mlkit/barcode-scanning": "^5.4.0",

Smartphone:

  • iPhone 13 (ios 17.6.1)

Development Environment:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant