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

Create a ZXing (MLKit-free) build for F-Droid #1882

Closed
3 tasks
Tracked by #3872 ...
g123k opened this issue May 17, 2022 · 15 comments · Fixed by #3252
Closed
3 tasks
Tracked by #3872 ...

Create a ZXing (MLKit-free) build for F-Droid #1882

g123k opened this issue May 17, 2022 · 15 comments · Fixed by #3252

Comments

@g123k
Copy link
Collaborator

g123k commented May 17, 2022

What

  • Create a blob free version of the app that we can deploy to F-Droid
    • Remove MLKit
    • Ensure whether we need to tweak Sentry or not

Part of

Initial message by @g123k

Hi everyone,

Smoothie has two dependencies to manage barcode decoding: google_ml_barcode_scanner (MLKit) and qr_code_scanner (ZXing). For both cases, the engine is embedded in our app. For debug APKs (= non-optimized), even with the Flutter engine, the difference with V1 is huge:

  • V1 (native Android - with a dynamic downloaded MLKit engine): 30 Mo
  • V1 (native Android - embedded MLKit engine): ~ 40 Mo
  • V2 (Flutter): 95 Mo (without x86 binaries)

The reason behind this choice seems to be related that we want some builds for Google Play (let's say with MLKit) and for other app stores (FDroid…). Instead of building a single "fat" application, shouldn't we split the app into two versions?

Or maybe is qr_code_scanner still relevant? Is embedding MLKit an "OK" solution for non-Google Play Android stores?

Part of

@g123k g123k added the camera label May 17, 2022
@M123-dev
Copy link
Member

When switching back to ML Kit we left in ZXing for two reasons: 1. Comparing them, I'd say that's done and 2. To allow publishing in stores like fDroid

But first most stores like these from Amazon or Samsung don't really care if we include ML Kit or not. The only one I know of is FDroid.
V1 is on there so the initial plan was to also release it there but that's not a priority.

If there is a way to build with only one of them included without splitting the codebase that's a idea if that's not possible we can just remove qr_code_scanner. It's currently not in use and with the current level of abstraction it's easy to add back in if we need it again

@g123k
Copy link
Collaborator Author

g123k commented May 18, 2022

@teolemon What’s our déploiement target for V1 and upcoming releases?
Only Google Play? Fdroid?

@teolemon
Copy link
Member

Only Google Play, but it'd be cool to figure out fdroid after that

@g123k
Copy link
Collaborator Author

g123k commented May 18, 2022

Ok, so here is the plan:

  • For 1.0.0:

    • Embedded MLKit for Android
    • Embedded MLKit for iOS
  • For the upcoming release (let's say 1.1.x):

    • Embedded MLKit for Android - Google Play
    • Zxing for Android - Non GMS compliant stores (eg: FDroid)
    • Embedded MLKit for iOS

Is-it OK for everyone?

@monsieurtanuki
Copy link
Contributor

Is-it OK for everyone?

Understood, though I'm not convinced the energy spent there will be worth the trouble. For the Android app, how many downloads from Google Play and from FDroid?

@teolemon
Copy link
Member

We want a fully free version to be available for F-Droid and FOSS (Open Food Facts is about Open Source).
In V1, we actually allow users to opt-in into ML Kit, since there are terms and conditions.
openfoodfacts/openfoodfacts-androidapp#3836

<string name="preference_choose_scanner_dialog_title"><b>New: Enhanced “MLKit” scanner</b></string>
<string name="preference_choose_scanner_dialog_body">We have included a new option to more reliably scan barcodes. While this scanner works on your device, using machine learning,
        please be aware that it is a proprietary component provided by Google, governed by this privacy policy, and that some limited telemetry might be sent back to Google’s servers
        to improve their software. As noted in the MLKit terms, this won’t include any information about the products you scan and the telemetry is anonymized. Choosing MLKit scanner
        implies that you accept those terms\n<b>Note: You can switch back at any time between the 2 scanners in the Settings.</b>

@monsieurtanuki
Copy link
Contributor

Regarding app size in general as in OP, maybe we could get rid of external packages that we don't use often.
For the record, those are all the external packages we use:

% grep -rh ".dart';" * | grep -v "package:smooth_app" | grep -v "package:flutter" | grep -v "package:openfoodfacts" | sort | uniq -c | sort
   1 import 'package:camera_web/camera_web.dart';
   1 import 'package:carousel_slider/carousel_slider.dart';
   1 import 'package:collection/collection.dart';
   1 import 'package:device_preview/device_preview.dart';
   1 import 'package:fwfh_selectable_text/fwfh_selectable_text.dart';
   1 import 'package:hive/hive.dart';
   1 import 'package:http/http.dart';
   1 import 'package:image_cropper/image_cropper.dart';
   1 import 'package:image_cropper_for_web/image_cropper_for_web.dart';
   1 import 'package:image_picker/image_picker.dart';
   1 import 'package:image_picker_for_web/image_picker_for_web.dart';
   1 import 'package:intl/intl.dart';
   1 import 'package:iso_countries/iso_countries.dart';
   1 import 'package:latlong2/latlong.dart';
   1 import 'package:matomo_forever/matomo_forever.dart';
   1 import 'package:modal_bottom_sheet/modal_bottom_sheet.dart';
   1 import 'package:package_info_plus_web/package_info_plus_web.dart';
   1 import 'package:path/path.dart';
   1 import 'package:path_provider/path_provider.dart';
   1 import 'package:percent_indicator/percent_indicator.dart';
   1 import 'package:photo_view/photo_view.dart';
   1 import 'package:photo_view/photo_view_gallery.dart';
   1 import 'package:qr_code_scanner/qr_code_scanner.dart';
   1 import 'package:rxdart/rxdart.dart';
   1 import 'package:sentry_flutter/sentry_flutter_web.dart';
   1 import 'package:shared_preferences/shared_preferences.dart';
   1 import 'package:shared_preferences_web/shared_preferences_web.dart';
   1 import 'package:typed_data/typed_buffers.dart';
   1 import 'package:url_launcher_web/url_launcher_web.dart';
   1 import 'package:uuid/uuid.dart';
   2 import 'package:mailto/mailto.dart';
   2 import 'package:permission_handler/permission_handler.dart';
   2 import 'package:sentry_flutter/sentry_flutter.dart';
   2 import 'package:visibility_detector/visibility_detector.dart';
   4 import 'package:google_ml_barcode_scanner/google_ml_barcode_scanner.dart';
   4 import 'package:package_info_plus/package_info_plus.dart';
   4 import 'package:url_launcher/url_launcher.dart';
   6 import 'package:camera/camera.dart';
   6 import 'package:hive_flutter/hive_flutter.dart';
   8 import 'package:auto_size_text/auto_size_text.dart';
  44 import 'package:provider/provider.dart';

@g123k
Copy link
Collaborator Author

g123k commented May 18, 2022

Excellent idea @monsieurtanuki.
I have created a dedicated issue.

@g123k
Copy link
Collaborator Author

g123k commented May 23, 2022

Good news: the app is working well on Huawei devices (without GMS).
The only use case where we will have to use ZXing is for FDroid.

@teolemon teolemon added this to the V1.1 milestone Jun 11, 2022
@teolemon teolemon changed the title MLKit & ZXing in the same app? Create a ZXing (MLKit-free) build for F-Droid Jul 4, 2022
@g123k g123k self-assigned this Jul 5, 2022
@M123-dev
Copy link
Member

Heyy @g123k the new modular pipline is up and running so if we create a different flavour / store listing it's just a matter of passing different values to the workflow to create a differnt app.

@g123k
Copy link
Collaborator Author

g123k commented Oct 5, 2022

ℹ️ This issue will be implemented as part of #3084 (step 3)

@VaiTon VaiTon moved this from To discuss and validate to In Progress in 🤳🥫 The Open Food Facts mobile app (Android & iOS) Oct 6, 2022
@g123k
Copy link
Collaborator Author

g123k commented Oct 14, 2022

A few after the release, we should think about removing the data import feature #3150

@teolemon
Copy link
Member

@g123k @M123-dev @monsieurtanuki is that something we can now do ?
Unsure why we closed it in the first place

@M123-dev
Copy link
Member

We had this before the we switched Scanners, (not automated the release to the store, but the apk uploaded to github releases)

@alexgarel
Copy link
Member

I opened a new ticket, because this was is on a related subject, not the core.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging a pull request may close this issue.

5 participants