Closed seth35us closed 2 years ago
Do you know more parameters to the crash? Like which devices are affected or which version of iOS?
Demangled symbol:
function signature specialization of fast_barcode_scanner.BarcodeReader.metadataOutput(_: __C.AVCaptureMetadataOutput, didOutput: Swift.Array<__C.AVMetadataObject>, from: __C.AVCaptureConnection) -> ()
Which is
func metadataOutput(_ output: AVCaptureMetadataOutput,
didOutput metadataObjects: [AVMetadataObject],
from connection: AVCaptureConnection) {
guard
let metadata = metadataObjects.first,
let readableCode = metadata as? AVMetadataMachineReadableCodeObject
else { return }
pauseIfRequired()
codeCallback([flutterMetadataObjectTypes[readableCode.type]!, readableCode.stringValue!])
}
The only possible cause could be the force unwrappings here: [flutterMetadataObjectTypes[readableCode.type]!, readableCode.stringValue!]
.
The first one is really unlikely to have caused the crash, because AVFoundation supports a fixed range of code types which I just copied into flutterMetadataObjectTypes
.
Are there code types that do not have a value?
Anyway I guess it would be good to have both unwrappings in the guard statement as it is in #17.
I do not know what code types do not have a value. I think you are correct. I have modified the code in my project below and will see if the crash goes away. Do you want me to do a PR, or do you want to make the change?
Thank you for looking into this error.
func metadataOutput(_ output: AVCaptureMetadataOutput,
didOutput metadataObjects: [AVMetadataObject],
from connection: AVCaptureConnection) {
guard
let metadata = metadataObjects.first,
let readableCode = metadata as? AVMetadataMachineReadableCodeObject,
let type = flutterMetadataObjectTypes[readableCode.type],
let value = readableCode.stringValue
else { return }
pauseIfRequired()
codeCallback([type, value])
}
Did we fix this issue in the develop branch? Not sure where we left of.
I did not edit development. I ended up trying this package instead: https://pub.dev/packages/fl_mlkit_scanning. It seems really good, but possibly cpu intensive. I may try your cpu tests to see how it compares to AVFoundation.
Too bad. The force unwrapping is gone on develop branch, so the bug should not happen on there, if you like to try again!
Thanks, I will try again. I appreciate you fixing the issues!
Looks like this crash is back in version 1.1.2 on iOS, assuming the most recent build too, since I didn't see any code changes in the file that is crashing. The firebase error is: $s20fast_barcode_scanner13BarcodeReaderC14metadataOutput_03didG04fromySo017AVCaptureMetadataG0C_SaySo16AVMetadataObjectCGSo0J10ConnectionCtFTf4dndn_n + 724. I am waiting for xcode to give me more information.
I think this is related to #17. However, the error did not occur in the fixes from #17. This is the file that the crash is occurring in: https://github.com/jhoogstraat/fast_barcode_scanner/blob/main/fast_barcode_scanner/ios/Classes/BarcodeReader.swift
I am still waiting for Xcode to tell me where the crash is. Have you been seeing the same crash? I am thinking I could just add a few guards on that file and try it?