Skip to content

Commit

Permalink
Merge pull request juliansteenbakker#781 from navaronbracke/fix_issue…
Browse files Browse the repository at this point in the history
…_720

fix: Guard against a nil device in the background queue
  • Loading branch information
navaronbracke authored Oct 13, 2023
2 parents 9232d16 + fcbb735 commit aeb2154
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions ios/Classes/MobileScanner.swift
Original file line number Diff line number Diff line change
Expand Up @@ -213,18 +213,28 @@ public class MobileScanner: NSObject, AVCaptureVideoDataOutputSampleBufferDelega
} catch {
print("Failed to reset zoom scale")
}

let dimensions = CMVideoFormatDescriptionGetDimensions(self.device.activeFormat.formatDescription)

DispatchQueue.main.async {
completion(
MobileScannerStartParameters(
width: Double(dimensions.height),
height: Double(dimensions.width),
hasTorch: self.device.hasTorch,
textureId: self.textureId

if let device = self.device {
let dimensions = CMVideoFormatDescriptionGetDimensions(
device.activeFormat.formatDescription)
let hasTorch = device.hasTorch

DispatchQueue.main.async {
completion(
MobileScannerStartParameters(
width: Double(dimensions.height),
height: Double(dimensions.width),
hasTorch: hasTorch,
textureId: self.textureId ?? 0
)
)
)
}

return
}

DispatchQueue.main.async {
completion(MobileScannerStartParameters())
}
}
}
Expand Down

0 comments on commit aeb2154

Please sign in to comment.