Skip to content

Commit b60dd88

Browse files
authored
fix(barcode-scanner): start capture session on a separate thread (#3223)
fixes the given warning: Thread Performance Checker: -[AVCaptureSession startRunning] should be called from background thread. Calling it on the main thread can lead to UI unresponsiveness which might cause a UI freeze
1 parent a97033b commit b60dd88

2 files changed

Lines changed: 9 additions & 1 deletion

File tree

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
barcode-scanner: patch
3+
barcode-scanner-js: patch
4+
---
5+
6+
On iOS, start the scanning session on a separate thread to fix performance issues.

plugins/barcode-scanner/ios/Sources/BarcodeScannerPlugin.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,9 @@ class BarcodeScannerPlugin: Plugin, AVCaptureMetadataOutputObjectsDelegate {
286286
}
287287

288288
self.metaOutput!.metadataObjectTypes = self.scanFormats
289-
self.captureSession!.startRunning()
289+
DispatchQueue.main.async {
290+
self.captureSession!.startRunning()
291+
}
290292

291293
self.isScanning = true
292294
}

0 commit comments

Comments
 (0)