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

feat: Better support error when saving the picture locally #4305

Merged
merged 5 commits into from
Jul 17, 2023

Conversation

g123k
Copy link
Collaborator

@g123k g123k commented Jul 14, 2023

Hi everyone,

If something fails in the photo-taking process, there is no error catching.
I will now catch the error and also provide a timeout, where sometimes the Isolate has weird behaviors.
We also have a dedicated method to send custom exceptions to Sentry to better track this kind of issue.

Related issue: #4304

@g123k g123k requested a review from a team as a code owner July 14, 2023 11:33
@g123k g123k self-assigned this Jul 14, 2023
@github-actions github-actions bot added 📈 Analytics We use Sentry and Matomo, with an opt-in system 🌐 l10n and removed 🖼️ Photos - Cropping labels Jul 14, 2023
@codecov-commenter
Copy link

Codecov Report

Merging #4305 (8ed7a1b) into develop (1cd22a6) will decrease coverage by 0.01%.
The diff coverage is 0.00%.

@@             Coverage Diff             @@
##           develop    #4305      +/-   ##
===========================================
- Coverage    10.80%   10.79%   -0.01%     
===========================================
  Files          287      287              
  Lines        14202    14208       +6     
===========================================
  Hits          1534     1534              
- Misses       12668    12674       +6     
Impacted Files Coverage Δ
...kages/smooth_app/lib/helpers/analytics_helper.dart 0.00% <0.00%> (ø)
packages/smooth_app/lib/pages/crop_page.dart 0.00% <0.00%> (ø)

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

Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@g123k Interesting bug! Are you able to reproduce it?
I have no idea if an isolate is more likely to fail than a standard async. Perhaps more memory intensive?

What about

  1. trying to use an isolate to save the picture (cf. the previous code and your PR)
  2. if it failed, trying to use a "normal async" to save the picture: as a fallback, the picture is going to be saved but with a little screen freeze - which is more acceptable for the user than an enigmatic dialog
  3. if it failed too, display an enigmatic dialog (cf. your PR)

Doing so, we'll deliver a better service to the user, while tracking and being able to understand how isolates (or async) may fail regarding saving a picture.

What do you think of that?

@g123k
Copy link
Collaborator Author

g123k commented Jul 14, 2023

@g123k Interesting bug! Are you able to reproduce it? I have no idea if an isolate is more likely to fail than a standard async. Perhaps more memory intensive?

What about

  1. trying to use an isolate to save the picture (cf. the previous code and your PR)
  2. if it failed, trying to use a "normal async" to save the picture: as a fallback, the picture is going to be saved but with a little screen freeze - which is more acceptable for the user than an enigmatic dialog
  3. if it failed too, display an enigmatic dialog (cf. your PR)

Doing so, we'll deliver a better service to the user, while tracking and being able to understand how isolates (or async) may fail regarding saving a picture.

What do you think of that?

My guess on this is sometimes Isolate doesn't start.
I don't really know why and the goal of this PR is just to understand if that's the root cause, thanks to the reporting to Sentry.

I'm not sure if it's worth the case to implement a better fix for now, as I can't reproduce it.
But clearly, if that's related to the Isolate, your solution should be implemented.

@monsieurtanuki
Copy link
Contributor

My guess on this is sometimes Isolate doesn't start.

Makes sense.

I don't really know why and the goal of this PR is just to understand if that's the root cause, thanks to the reporting to Sentry.

I have nothing against this idea, but I don't know how clever we are to detect it. Let me rephrase: in your PR you added a call to Sentry, but Sentry is flooded by tons of error messages.

=> Could you share a Sentry link (or set up a Sentry alarm if that exists) about all the time this specific error is sent to Sentry?

I'm not sure if it's worth the case to implement a better fix for now, as I can't reproduce it.
But clearly, if that's related to the Isolate, your solution should be implemented.

I'll implement "my" solution in another PR - I've just assigned myself to the issue and made sure that when this PR is merged the issue won't be closed automatically.

@g123k
Copy link
Collaborator Author

g123k commented Jul 15, 2023

FYI I've lost my access to Sentry. Once I have it back, it will share the link

@g123k
Copy link
Collaborator Author

g123k commented Jul 17, 2023

For Sentry; you just have to enter the method's name to filter all exceptions: https://openfoodfacts.sentry.io/issues/?project=5376745&query=is%3Aunresolved+_getCroppedImageFile&referrer=issue-list&statsPeriod=1h

@g123k g123k marked this pull request as draft July 17, 2023 08:03
@g123k
Copy link
Collaborator Author

g123k commented Jul 17, 2023

I will change a bit the implementation to show a dialog with an error message

@g123k
Copy link
Collaborator Author

g123k commented Jul 17, 2023

That should be better now, with a dedicated message: ErrorDialog.webm 🎬.
I've also created a SmoothSimpleErrorAlertDialog that we can reuse in the app.

@g123k g123k marked this pull request as ready for review July 17, 2023 08:30
@openfoodfacts openfoodfacts deleted a comment from github-actions bot Jul 17, 2023
Copy link
Contributor

@monsieurtanuki monsieurtanuki left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @g123k!
Please have a look at my comments.

packages/smooth_app/lib/pages/crop_page.dart Outdated Show resolved Hide resolved
void _showErrorDialog() {
final AppLocalizations appLocalizations = AppLocalizations.of(context);

showDialog<void>(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

await

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mmm that's meaningless here, as we're not statement after.
Why would it be necessary?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if it's "necessary", but it would be cleaner and more consistent with the rest of the showDialog calls in the app.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've added a Future to the method, which should be better

@github-actions
Copy link
Contributor

@g123k g123k merged commit 5a72a46 into openfoodfacts:develop Jul 17, 2023
7 checks passed
@g123k g123k deleted the error_saving_local_image branch July 17, 2023 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📈 Analytics We use Sentry and Matomo, with an opt-in system error handling 🌐 l10n
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants