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

fix: Camera ignore turn flash off exception #2228

Merged
merged 3 commits into from
Jun 9, 2022

Conversation

g123k
Copy link
Collaborator

@g123k g123k commented Jun 8, 2022

Hi everyone,

When the preview is paused, I force the flash to be turned off.
But if the native part is quicker than the Dart side (camera closed for example), it will trigger an exception.

Instead, we just ignore the error

I/Camera  (12140): open | onClosed
I/Camera  (12140): CameraCaptureSession onClosed
I/Camera  (12140): refreshPreviewCaptureSession: captureSession not yet initialized, skipping preview capture session refresh.
E/flutter (12140): [ERROR:flutter/lib/ui/ui_dart_state.cc(198)] Unhandled Exception: CameraException(setFlashModeFailed, Could not set flash mode.)
E/flutter (12140): #0      CameraController.setFlashMode (package:camera/src/camera_controller.dart:642:7)
E/flutter (12140): <asynchronous suspension>
E/flutter (12140): #1      SmoothCameraController.pausePreview (package:smooth_app/pages/scan/camera_controller.dart:83:7)
E/flutter (12140): <asynchronous suspension>
E/flutter (12140): #2      MLKitScannerPageState._stopImageStream (package:smooth_app/pages/scan/ml_kit_scan_page.dart:365:5)
E/flutter (12140): <asynchronous suspension>
E/flutter (12140): 

@g123k g123k requested a review from a team as a code owner June 8, 2022 18:41
@codecov-commenter
Copy link

Codecov Report

Merging #2228 (9f41e14) into develop (2ea0da3) will decrease coverage by 1.06%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           develop   #2228      +/-   ##
==========================================
- Coverage     8.86%   7.79%   -1.07%     
==========================================
  Files          161     181      +20     
  Lines         6623    9028    +2405     
==========================================
+ Hits           587     704     +117     
- Misses        6036    8324    +2288     
Impacted Files Coverage Δ
...kages/smooth_app/lib/widgets/attribute_button.dart 0.00% <0.00%> (-92.00%) ⬇️
packages/smooth_app/lib/themes/smooth_theme.dart 60.00% <0.00%> (-22.98%) ⬇️
...s/smooth_app/lib/data_models/user_preferences.dart 9.37% <0.00%> (-22.94%) ⬇️
...p/lib/generic_lib/dialogs/smooth_alert_dialog.dart 19.23% <0.00%> (-14.98%) ⬇️
...mooth_app/lib/data_models/product_preferences.dart 26.47% <0.00%> (-4.96%) ⬇️
.../smooth_app/lib/pages/onboarding/welcome_page.dart 0.00% <0.00%> (-3.13%) ⬇️
.../smooth_app/lib/pages/onboarding/scan_example.dart 0.00% <0.00%> (-2.28%) ⬇️
packages/smooth_app/lib/main.dart 15.74% <0.00%> (-2.16%) ⬇️
...s/smooth_app/lib/pages/onboarding/next_button.dart 2.22% <0.00%> (-1.78%) ⬇️
...p/lib/pages/onboarding/consent_analytics_page.dart 0.00% <0.00%> (-1.57%) ⬇️
... and 168 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 8a21076...9f41e14. Read the comment docs.

Copy link
Member

@M123-dev M123-dev left a comment

Choose a reason for hiding this comment

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

One comment, besides that it looks good

Comment on lines +238 to +240
// Only accepts barcodes on half-top of the image
.where((Barcode barcode) =>
(barcode.boundingBox?.top ?? 0.0) <= imageHeight * 0.5)
Copy link
Member

Choose a reason for hiding this comment

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

I don't feel comfortable doing this already. I often times have to put the barcode in at least some parts behind the card/lower then the middel

@g123k
Copy link
Collaborator Author

g123k commented Jun 8, 2022

Please do a flutter upgrade to get my latest changes to the camera.
And you will notice that focus & detection are far better now

@teolemon teolemon merged commit 004f1aa into openfoodfacts:develop Jun 9, 2022
@g123k g123k deleted the camera_ignore_exception branch June 22, 2022 17:09
@teolemon teolemon added the flash label Jun 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants