After my live stream on how to implement barcodes with ZXing in Xamarin.Forms I got a lot of wonderful responses, thank you for that! There were a couple that are about a problem that people experience on Android. Here is a quick post on how to counter those.
Scanning Barcodes with ZXing
In my original post and the stream I show you how you can incorporate barcode scanning into your Xamarin.Forms application. The basics are very easy, but the binding libraries to ZXing seem to have some rough edges.
Skipping Frames issue
The "error" people are experiencing has to do with a message saying "Skipped 68 frames! The application may be doing too much work on its main thread" in the output of the application. Typically, this means you might be doing too much work on the main thread (that's what it says in the error!) and you need to move some heavy duty jobs to the background.
However, in this case the solution is much more simple. I'm not sure if this problem originates in the ZXing library, or the binding library by Redth, but in any case there are two setting that you can configure that will prevent this. Here they are:
You set this in the MobileBarcodeScanningOptions object that you add to your scanner view. There isn't much documented about this, so I took a little dive in the source. It seems these values are used here to determine if there is enough time between the frames. Some people I talked to had just one of these options, apparently it's important to have both.
The really weird thing is, that this seems to be in milliseconds, but actually setting the value to be lower than the default setting seems to be working better. I guess you will have to have a little play for yourself to see what works in your case.
While the problem seems to occur on Android mostly, other platforms might be affected by these settings as well.
Something that also might work is to set the IsAnalyzing property to false whenever you have scanned something and are processing. If you have any more pointers regarding this, please reach out!
Thank you again everyone for watching (back) the stream. If you've missed it, you can rewatch it here. Don't forget to subscribe! 🙂
A special thanks to @SmartmanApps who not only just came with this question, but also figured this out with me.