smooth-app icon indicating copy to clipboard operation
smooth-app copied to clipboard

fix: Background image upload

Open AshAman999 opened this issue 2 years ago • 9 comments

What

  • An initial implementation of using workmanager to do image upload in the background

Benefits

  • Background image upload
  • upload completes whenever there is good internet
  • once upload scheduled , will retry for five times before finally giving up
  • Task remains even when phone starts or app closed

Problems

  • can't easily manage app state when using workmanager [WIP] alternate ways to let users know if the task is done(possibly other menus)
  • ios setup is still not configured,(yet to be done,)

Fixes bug(s)

  • Fixes: #1593 #2192 #2459

Part of

  • #1393

AshAman999 avatar Jun 29 '22 19:06 AshAman999

Codecov Report

Merging #2433 (eba8d96) into develop (ac19a9c) will decrease coverage by 0.16%. The diff coverage is 0.47%.

@@            Coverage Diff             @@
##           develop   #2433      +/-   ##
==========================================
- Coverage     7.04%   6.88%   -0.17%     
==========================================
  Files          219     221       +2     
  Lines        10874   11161     +287     
==========================================
+ Hits           766     768       +2     
- Misses       10108   10393     +285     
Impacted Files Coverage Δ
...th_app/lib/cards/data_cards/image_upload_card.dart 0.00% <0.00%> (ø)
...oth_app/lib/data_models/continuous_scan_model.dart 0.83% <0.00%> (ø)
...h_app/lib/data_models/onboarding_data_product.dart 0.00% <0.00%> (ø)
.../smooth_app/lib/data_models/onboarding_loader.dart 0.00% <ø> (ø)
...p/lib/generic_lib/dialogs/smooth_alert_dialog.dart 15.70% <ø> (ø)
...smooth_app/lib/generic_lib/duration_constants.dart 0.00% <0.00%> (ø)
...smooth_app/lib/helpers/background_task_helper.dart 0.00% <0.00%> (ø)
...smooth_app/lib/helpers/picture_capture_helper.dart 0.00% <0.00%> (ø)
...e_panel/knowledge_panels/knowledge_panel_page.dart 0.00% <ø> (ø)
packages/smooth_app/lib/main.dart 14.52% <0.00%> (-0.13%) :arrow_down:
... and 18 more

:mega: We’re building smart automated test selection to slash your CI/CD build times. Learn more

codecov-commenter avatar Jun 30 '22 06:06 codecov-commenter

@monsieurtanuki ,

I'm not convinced by the increasing delay (what delay is that btw? the delay from the moment I clicked on upload or from the latest unsuccessful attempt?). I guess a call to sentry would make sense ("hey we've got this guy and we cannot upload his picture"), as would an alert to the end-user.

the task will immediatly try to do the execution in the background, if it fails then the retry will be done accordingly( a retry feat suggested by eduoard)

Wouldn't it be nice to display somewhere the list of the pending tasks? How do you refresh the app when the picture is uploaded? I saw something about the carousel, but I don't think it would refresh a product page, would it?

WIll do for sure, it's kinda hard to acess database in the work manager, looking and testing workaround for that

AshAman999 avatar Jul 03 '22 19:07 AshAman999

@g123k Had fixed everything for now, works like a charm on my android 11 Blocking is the ios configuration for it, android didn't required any If you could look at the ios part of this https://github.com/fluttercommunity/flutter_workmanager/blob/main/IOS_SETUP.md

AshAman999 avatar Jul 08 '22 15:07 AshAman999

@M123-dev Thanks for the detailed review, now the code looks better after formating

When I understood the code right (its a mobile review) when I upload an image it takes 30 seconds to first start the real uploading right

We don't have a local instant copy. Together with the 30sec delay, this isn't really user-friendly.

  • Zero second delay if there is working internet, or as soon as internet is connected
  • When adding a new product we have a placeholder product, but for other purposes sadly no, (Upcoming) Working on an offline tasks screen where one can see the pending tasks.

AshAman999 avatar Jul 11 '22 08:07 AshAman999

Offline images do not seem properly credited: https://world.openfoodfacts.org/product/3760262110882

teolemon avatar Jul 19 '22 13:07 teolemon

Offline images do not seem properly credited: https://world.openfoodfacts.org/product/3760262110882

Edit: Fixed the problem

AshAman999 avatar Jul 19 '22 13:07 AshAman999

There is lot of ongoing here, so in turn i did the pr as draft, also there is some problem regarding background work policy on ios. At last Eduoard is working on some custom packages for something to do sperately do tasks on ios and android. FOR NOW THE PR IS HALTED 🥲

AshAman999 avatar Jul 29 '22 16:07 AshAman999

@AshAman999 Can we solve the merge conflicts now before they become too bad ?

teolemon avatar Aug 02 '22 13:08 teolemon

@teolemon, Probably I will need to rewrite this, so nothing to worry I guess, Anyways I will solve the merge conflicts, just in case after the plugin luckily if I don't have to change much.

AshAman999 avatar Aug 02 '22 13:08 AshAman999

are there any outstanding issues left @AshAman999 @g123k ?

teolemon avatar Aug 30 '22 20:08 teolemon

are there any outstanding issues left @AshAman999 @g123k ?

@teolemon Though as of now, nothing is blocking, but still, I was thinking to create an internal release with the pr to have things tested out before we finally merge it to develop. @g123k ?

AshAman999 avatar Aug 31 '22 05:08 AshAman999

Ok, going to merge

teolemon avatar Sep 01 '22 10:09 teolemon