Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

I can't scan anything anymore #3670

Closed
teolemon opened this issue Feb 4, 2023 · 23 comments · Fixed by #3767
Closed

I can't scan anything anymore #3670

teolemon opened this issue Feb 4, 2023 · 23 comments · Fixed by #3767
Labels
🐛 bug Something isn't working 🎯 P0 🤳🥫 Scan We need to be able to scan on low-end, old devices, even with a bad camera, connexion…

Comments

@teolemon
Copy link
Member

teolemon commented Feb 4, 2023

What

  • I can't scan anything anymore. At this point, I can't scan on a Google Pixel 6 (high memory, highend, vanilla Android). This is not a Redmi 10 thing.
  • My suspicion is that it might be related to the general Flutter/Library bump where we have probably discarded some forks of the libraries made by @g123k ?
@teolemon teolemon added 🐛 bug Something isn't working 🎯 P0 🤳🥫 Scan We need to be able to scan on low-end, old devices, even with a bad camera, connexion… labels Feb 4, 2023
@M123-dev
Copy link
Member

M123-dev commented Feb 4, 2023

It isn't working for me too 🤕

@M123-dev
Copy link
Member

M123-dev commented Feb 4, 2023

We didn't change anything directly on the scanner. It could be that the underlying code has changed

@monsieurtanuki
Copy link
Contributor

I'm about to start a new simple flutter project from scratch: just a barcode scanner.
This way I would be able to work on android.

As @M123-dev suggested I guess @g123k's forks were side-effected by the upgrade to flutter 3.7, but we cannot stay forever on flutter 3.0.5 or hold our breath each time we want to upgrade flutter.

Besides, I really find the UI/UX about scanning is not optimal for the user, and definitely problematic for us developers. I would prefer a "scan!" button that would detect a barcode only when needed. But that's another story.

@monsieurtanuki
Copy link
Contributor

My first attempt to use qr_code_scanner was successful (their example), even on my canary smartphone:
Screenshot_2023-02-04-15-36-06

There were probably good reasons for coding a more complex barcode scanner in Smoothie.
I never worked on the camera-related classes for Smoothie, and I don't know if those reasons are still relevant today. Are they?

@teolemon @M123-dev Please run the qr_code_scanner example and check if it works on your devices.

@teolemon
Copy link
Member Author

teolemon commented Feb 4, 2023

Is it using CameraX?

@monsieurtanuki
Copy link
Contributor

Is it using CameraX?

I don't think so:

Since the underlying frameworks of this package, zxing for android and MTBBarcodescanner for iOS are both not longer maintaned, this plugin is no longer up to date and in maintenance mode only. Only bug fixes and minor enhancements will be considered.

I am developing a new plugin mobile_scanner that uses the latest version of MLKit for detecting barcodes and QR codes. On Android it also uses the latest version of CameraX, and on iOS the native AVFoundation for best camera performance.

To be honest, I have no clue about CameraX and MLKit, and from outside I haven't seen the point to all that jazz.
That said, I'm about to test mobile_scanner too. I'll die less stupid.

@teolemon
Copy link
Member Author

teolemon commented Feb 4, 2023

  • CameraX aims at standardizing the Android camera clusterf**k

  • MLKit is independent and normally offers better perf than axing

  • The Flutter team has promised in Flutter Extended they would make CameraX the default sometime this year.

  • The thing is there's no official implementation mixing properly the two (CameraX + MLKit)

  • We've been using Camera2+MLKit

  • I've been tracking a bunch of other packages as well:

  • https://pub.dev/packages/camerawesome

@monsieurtanuki
Copy link
Contributor

@teolemon What I can tell you is that qr_code_scanner works right out of the box, even on my phone, in the very same conditions as Smoothie (forever barcode scanning on top of the screen, with pause/resume methods).
mobile_scanner does not work without some rewriting, as the example do not match the code of the package.
camerawesome has no example related to barcode scanning.

That said, I don't have your experience with the android legacy off app and the probable issues regarding cameras and barcode scans.

The Flutter team has promised in Flutter Extended they would make CameraX the default sometime this year.

If I were French or cynical I would say that everything is fine then, the issue will then probably be fixed sometime this year.

@monsieurtanuki
Copy link
Contributor

@teolemon I took me 1 hour to integrate qr_code_scanner into Smoothie, and it works perfectly on my canary smartphone.
Of course it should be tested on other devices.
The code would be so much easier and the app would be lighter if we used qr_code_scanner. As an expected bonus the camera and barcode scan will work, which doesn't seem to be the case today on all devices.
I'm scratching my head wondering why we should keep the MLKit and ZXing confusion (or perhaps in an experimental app).
Tell me if you want me to PR the qr_code_scanner version.

@monsieurtanuki
Copy link
Contributor

Fun fact: with the current scan system it takes me 30 minutes (!) to build the debug app on my old samsung. It takes me less than 2 minutes with qr_code_scanner instead.

I'm going to PR a qr_code_scanner version where I've blowtorched anything related to mlkit and zxing. Even if it's not merged in the end, at least I could use the app, and you guys will be able to test it. And that would be part of #3669.

@M123-dev
Copy link
Member

M123-dev commented Feb 8, 2023

That definitely sounds like an improvement in terms of developer usage.
It would be good if you could somehow integrate it into the current system. At best, a switch in the dev settings to test both.

The main problem for most barcode scanner packages is that we don't have enough ways to configure it.

@monsieurtanuki
Copy link
Contributor

@M123-dev Do you realize that I used Smoothie today in a supermarket. Last time I could was maybe one year ago., maybe more.

For the moment I'm still in the process of making qr_code_scanner work completely in the app (with flash on/off, ...).
And that means I deleted a lot of now unused files.
We'll see first if it works on actual devices, before possibly merging.

Does it match the current way of coding: unfortunately no.
The thing is that IMHO the current way of coding the scanner is a bit experimental. And it should be a black box, as packages in pub.dev:

  • I want a barcode scanner
  • I find one in pub.dev
  • it's a widget I use, with parameters, and the rest is not my business

So if the idea is to use MLkit (still a bit mysterious to me, but let's be positive), the best way would be to develop a flutter Widget in a specific open source package, that opens the camera and scans barcodes.
This way other developers would be able to reuse that package, and the code would be easy to reuse.
Currently that's not the case: there are bits of code here and there.

@M123-dev
Copy link
Member

M123-dev commented Feb 8, 2023

That's great to hear and I completely agree, a full working system would be amazing, to either have or if we make it ourselves we can share it.

For the whole system, maybe we could get help from Google for it cc @teolemon

@teolemon
Copy link
Member Author

Ok, not working any better…

@monsieurtanuki
Copy link
Contributor

@teolemon Probably #3642 would need to be reverted too.
Have you downgraded to flutter 3.0.5?

@stephanegigandet
Copy link
Contributor

@M123-dev Could you revert #3642 ? Thank you!

@M123-dev
Copy link
Member

Good news @monsieurtanuki scan now works again
not saying we should forget about this but it works for the time being

@monsieurtanuki
Copy link
Contributor

That's good! I guess we're now ready to release a new Smoothie version with the packaging-grams-with-numeric-keyboard bug fix.

@teolemon
Copy link
Member Author

Sorry I've been in an ecoscore conference all day. Will try to test on the train back tomorrow morning

@teolemon
Copy link
Member Author

Ok, just verified it works @stephanegigandet @monsieurtanuki @M123-dev going to take my laptop and proceed to release at 300km/hr for one of our fastest releases ever.

@teolemon
Copy link
Member Author

Rolling out on Android, Under validation for Apple

@stephanegigandet
Copy link
Contributor

Wonderful, thanks a lot everyone!

@M123-dev
Copy link
Member

Closing, to be followed in #3712

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 bug Something isn't working 🎯 P0 🤳🥫 Scan We need to be able to scan on low-end, old devices, even with a bad camera, connexion…
4 participants