Unable to scan a barcode on iPhone 14 Pro and iPhone 14 Pro Max
Users report they are unable to scan a barcode with an iPhone 14 Pro and iPhone 14 Pro Max. My app is using the CodenameOne CodeScanner Library.
There does seem to be an acknowledged issue with the cameras on these phones caused by the main camera of these iPhone models being unable to focus at distances closer than 15cm.
Relevance: https://www.reddit.com/r/cn1/comments/14va2hf/iphone_14_not_scanning_barcodes/
Is there an update on this, my customers are leaning on me to get it fixed. They called Apple Care about and were told it is an app developer problem.
Thanks,
Martin
Steve is working on this. In the interim can't you just use the workaround of migrating to use the LittleMonkey codescan?
This will be our underlying fix too.
I didn't realize there was a workaround. What does it involve? I did a search on " LittleMonkey codescan" but didn't really turn up anything.
Thanks,
Martin
It's this: https://github.com/littlemonkeyltd/QRScanner
I guess you searched for barcode scanning, notice it works with that too. It builds on top of our existing cn1lib but embeds a native Android scanner.
Thanks for the link, is this going to solve the Android 13 problem too? That is another one my users have run into.
I had a couple of problems trying to follow this though. The instructions say to:
Install the cn1-codescan library into your project.
Obviously, I did that.
Build or download the QRScanner.cn1lib file.
I was able to download the file from the supplied link
Put the file the libs folder of your project.
I don't have a libs folder in any of my CodenameOne projects, I do have a cn1libs folder which contains the codescanner cn1lib, is that the folder you mean? If it is relevant I am using the Maven build with Netbeans 12.5 on kubuntu.
Right-click on your project and choose Refresh Libs
There is no Refresh Libs popup menu when I right-click on my project, again this is with Netbeans 12.5.
Thanks,
Martin
Don't follow that. Launch Codename One settings, go to the extensions menu and search for the QR extension. Click download.
I couldn't find a QR extension. There are two matching cn1 libs when I search for QR, but I don't see how either will help with this problem.
QRScanner which is described as a zbar implementation for Android. The platform is listed as Android only. QR Code Generator which is described as a port of Zying for generating QR codes.
So maybe QRScanner will fix the problem with barcode scanning on Android 13, but what about this issue?
Sorry I was talking about the QRScanner one and totally missed that it's on iPhone with all the context switching.
This one is a big problem. I couldn't find any information about it while searching. ZBar which we used seems to be unmaintained: https://zbar.sourceforge.net/
I found no reports about it. The only free alternative to it that I can find is https://github.com/mercari/QRScanner
I'm not sure if it's a good alternative since it's written in Swift and that might make integration challenging. @shannah might have some thoughts on that.
Sorry for the confusion.
So there is no workaround for this problem with the iPhone 14 Pro and Pro Max, no way for a CodenameOne app to scan a barcode? It does seem a real issue, if you search Google for "Why can't i scan barcodes on my iPhone 14 Pro?", there is no shortage of people complaining about the problems with various apps. Apparently it is due to a change Apple made to the camera specs. If they realize the problem and fix it, this might go away. However if these cameras become the new standard for an iPhone, it will be a huge problem. Right now Apple is telling users it is an app developer problem.
Unfortunately this refers to barcode apps experiencing a problem. We need this for the barcode library and need to understand how this fix can be made from our end. If you can find a free library that works with iOS 14 we can just dump zbar and switch to that. Right now the only workaround I can think of is impractical for 99% of current users: scandit. Since it's a commercial library it's probably supported on iOS 14, unfortunately it's also prohibitively expensive for most.
Apparently the solution to this problem is to select the correct camera for scanning, (the macro one?), but it doesn't do so.
Are you aware of a way we can workaround this natively? Do you have a link to resources on that?
No, sorry, I have never done any native iOS development. Apparently in iOS 14 Apple added a way to set the default camera for an app, but CodenameOne ignores this.
This might hemp: https://stackoverflow.com/questions/74381985/choosing-suitable-camera-for-barcode-scanning-when-using-avcapturedevicetypebuil
Unfortunately it doesn't really help unless we want to implement our own barcode/QR code scanning logic. All the logic of picking the camera is compiled into zbar itself as you can see here: https://github.com/codenameone/cn1-codescan/blob/6c20d51ceef93520c29b1560fce5c57bf501aff4/ios/src/main/objectivec/com_codename1_ext_codescan_NativeCodeScannerImpl.m
This is the entire code. Everything else in that directory are headers and stubs.
Currently the only two workarounds I can think of are to fork zbar or find an alternative (or someone else who forked it).
Lately I have received numerous complaints from users saying they can no longer scan a barcode. This i s an important part of my app. It is effecting users of iPhone 13, 14 and 15, models Pro and Pro Max. Apple is still telling users that this is an app developer problem. This has become a huge issue that has to be fixed. It seems that Apple is focused on this approach in their high end models. It will become more and more of an issue for all CodenameOne developers.
When I first started with CodenameOne, barcode scanning was a standard part of CodenameOne. Then it was pushed off to a cn1lib, now it is barely functional. You have to fix this.
The push to the lib didn't change the capabilities in any way. It made it easier to create great enhancements by 3rd parties such as the QRScanner from Little Monkey and scandit.
The problem is I can't find any suggested workaround to these problems and the zbar lib is the only free option I see.
This is their community: https://sourceforge.net/projects/zbar/
I did some additional research and it seems there's one "free" barcode scanner available that might work. The Google ML Kit: https://developers.google.com/ml-kit/vision/barcode-scanning/
I'm not sure what are the complexities of integrating this as a QR/Barcode scanner. I'm assigning this to @shannah for evaluation.
Do you have any plan to support Google ML kit in near future?
I cannot read small barcodes with Codename One QRScanner on iPhone 14/iOS 17.5.1(regular, not Pro or Pro Max).
Unfortunately, this is a showstopper for me.
Is there an update on this? It has become a bigger issue for me. My competitors had the same issue, but they have now resolved it. I am stuck with CodenameOne with no apparent solution in sight. So I am really feeling pressure from my users.
I found this while searching. Is it possible you took a picture with a camera within the app before using the barcode? If so that might be the bug.
Regardless we'll need to research this. Maybe the situation has changed. @shannah I understand the issue is that the ultra-wide camera on the iPhone 14 Pro has a shorter focal length and can focus at closer distances than the main camera. We can programmatically switch to the ultra-wide camera when scanning barcodes. For that we will need to compile a new version of zbar as it seems there's no official support for that. Do we have an official fork of zbar?
Why not using native iOS AVFoundation APIs? This is what Gluon is using on iOS and works pretty well. For Android they use ZXing but I haven't tested it.
Ugh. That explains why there are no up to date libraries for barcode/qrcode reading... We're looking into migrating the code now. I was so focused on searching for a library I missed entirely that this has been in the OS forever now.
This was fixed by @shannah in the 2.0.3 version of the library.
I tried LATEST version of the library on iOS, but now my application crashes. It shows the camera screen for a second and then immediately crashes, this is what I see on the Console log:
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AVMetadataSalientObject stringValue]: unrecognized selector sent to instance 0x302c9a3e0'
*** First throw call stack:
(0x19088cf20 0x188722018 0x190996480 0x190829fb4 0x1908298d0 0x104a8db9c 0x1ad84f138 0x1ad873cdc 0x1b10c03a0 0x1b10c0010 0x198731dd4 0x1987352d8 0x1987491c8 0x198747d8c 0x1987404b4 0x1987401b8 0x19085f710 0x19085c914 0x19085bcd8 0x1d570c1a8 0x192e9490c 0x192f489d0 0x10492bbb0 0x10480f120 0x104589138 0x1049d5754 0x1049d579c 0x1b3f0de4c)
My app code is very basic, it is the CN1 bare bone Java app with the example code from QRScanner Github project.
This issue should be fixed with version 2.0.4 just released.