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: updated camera to react-native-vision 3 #1046

Merged
merged 25 commits into from
Jan 20, 2024

Conversation

wadeking98
Copy link
Contributor

@wadeking98 wadeking98 commented Dec 12, 2023

Summary of Changes

Replaced the depricated RNCamera module with react-native-vision-camera. Updated tests to be compatible. I had to make some modifications to the android permissions text... but it looks like they weren't being used anyway for some reason. This should be a transparent change, I've tested in the android emulator API version 30 and 32, as well as an iphone physical device. I was running into an issue on API version 30, but I wasn't sure if that was just a problem with the emulator itself. Other than android API 30 it works great on all versions. I'd appreciate some help testing the changes on different versions especially on android.

Additionally I've made sure the torch functionality works well.

Other advantages of this library:

It provides support for non QR code barcodes out of the box so we can provide more specific error messages if the user tries to scan their driver's license, etc.

Related Issues

Fixes bcgov/bc-wallet-mobile#1653

Pull Request Checklist

Tick all boxes below to demonstrate that you have completed the respective task. If the item does not apply to your this PR check it anyway to make it apparent that there's nothing to do.

  • All commits contain a DCO Signed-off-by line (we use the DCO GitHub app to enforce this);
  • Updated LICENSE-3RD-PARTY.md for any added dependencies or vendored components;
  • Updated documentation as needed for changed code and new or modified features;
  • Added sufficient tests so that overall code coverage is not reduced.

If you have any questions to any of the points above, just submit and ask! This checklist is here to help you, not to deter you from contributing!

Pro Tip 🤓

  • Read our contribution guide at least once; it will save you a few review cycles!
  • Your PR will likely not be reviewed until all the above boxes are checked and all automated tests have passed.

PR template adapted from the Python attrs project.

@wadeking98 wadeking98 requested a review from a team as a code owner December 12, 2023 23:33
Copy link

codecov bot commented Dec 12, 2023

Codecov Report

Attention: 29 lines in your changes are missing coverage. Please review.

Comparison is base (73a2246) 61.77% compared to head (5f7f49b) 62.09%.

Files Patch % Lines
...ges/legacy/core/App/components/misc/ScanCamera.tsx 50.00% 14 Missing ⚠️
packages/legacy/core/App/navigators/TabStack.tsx 0.00% 7 Missing ⚠️
...ages/legacy/core/App/components/misc/QRScanner.tsx 55.55% 3 Missing and 1 partial ⚠️
packages/legacy/core/App/screens/Scan.tsx 55.55% 4 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1046      +/-   ##
==========================================
+ Coverage   61.77%   62.09%   +0.32%     
==========================================
  Files         170      171       +1     
  Lines        5467     5466       -1     
  Branches     1574     1571       -3     
==========================================
+ Hits         3377     3394      +17     
+ Misses       2066     2048      -18     
  Partials       24       24              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@bryce-mcmath
Copy link
Contributor

What was the issue on API 30? Just so we can look out for it

@bryce-mcmath
Copy link
Contributor

Looks like you may need to update the gradle lockfile in Bifold too

@wadeking98
Copy link
Contributor Author

What was the issue on API 30? Just so we can look out for it

I'd get a repetitive error saying failed to load depricated vision dynamite module

@jleach
Copy link
Contributor

jleach commented Dec 13, 2023

@wadeking98 We go back pretty far for Android API compatibility - no? Do you think we'll loose anything with this change?

@wadeking98 wadeking98 requested a review from jleach December 13, 2023 19:57
@wadeking98
Copy link
Contributor Author

I've fixed the issue for api level 29 but I'm still running into issues with API level 30: mrousavy/react-native-vision-camera#2287

Signed-off-by: wadeking98 <[email protected]>
Signed-off-by: wadeking98 <[email protected]>
@jleach jleach marked this pull request as draft December 14, 2023 00:15
@jleach jleach added the do not merge Don't merge when label present label Dec 19, 2023
@wadeking98 wadeking98 marked this pull request as ready for review December 23, 2023 00:15
@wadeking98
Copy link
Contributor Author

I've confirmed this is working with API level 29, 30, 31 now

Comment on lines 6 to 11
export const SCREEN_WIDTH = Dimensions.get('window').width
export const SCREEN_HEIGHT = Platform.select<number>({
android: Dimensions.get('screen').height - StaticSafeAreaInsets.safeAreaInsetsBottom,
ios: Dimensions.get('window').height,
}) as number

Copy link
Contributor

Choose a reason for hiding this comment

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

How does this behave on tablets when they switch between portrait and landscape on the camera screen?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

good question, BC Wallet is locked in portrait mode so it shouldn't be an issue

Copy link
Contributor

Choose a reason for hiding this comment

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

I don't think it's locked in portrait mode on tablets, only on phones

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tested it on the pixel tablet with auto rotate turned on and the BC Wallet app was locked in portrait mode on that device

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. Maybe it's just unlocked on iPads. We should ask @jleach

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I could downgrade to version 2 or switch to another library but that may introduce it's own dependency issues and IMHO that seems like a lot of work to address what would be a minor inconvenience to only a handful of users, especially when it looks like this issue is going to be fixed in the library eventually. What are your thoughts @bryce-mcmath @jleach ?

Copy link
Contributor

Choose a reason for hiding this comment

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

I would tend to agree with that but what happened with testing older Android versions that we still support? I remember you saying something like API 24 wasn't scanning

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually I just tested it again on my mac environment and it worked fine on API 24. I think maybe I just didn't try moving the camera around last time

Copy link
Contributor

Choose a reason for hiding this comment

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

Well then I'm ok to move forward with this. Might want to wait until Clecio gets back and takes a look at it but I think you've done a great job

@wadeking98 wadeking98 removed the do not merge Don't merge when label present label Jan 5, 2024
jleach
jleach previously approved these changes Jan 16, 2024
@@ -42,6 +44,10 @@ const App = () => {
SplashScreen.hide()
}, [])

if (!isTablet()) {
Orientation.lockToPortrait()
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we want to support landscape but just lock the camera screen to portrait.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I thought we decided against landscape mode in mobile view?

@@ -42,6 +44,10 @@ const App = () => {
SplashScreen.hide()
}, [])

if (!isTablet()) {
Copy link
Contributor

Choose a reason for hiding this comment

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

There are some helper functions that use the screen dimensions for this. I think its better if we don't use both. If not in this PR can you create a technical debt ticket to clean this up at a later point?

@jleach jleach self-requested a review January 16, 2024 22:06
Signed-off-by: wadeking98 <[email protected]>
Copy link
Contributor

@bryce-mcmath bryce-mcmath left a comment

Choose a reason for hiding this comment

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

Can we only use the official package isTablet function and get rid of our helper version of it?

jleach
jleach previously approved these changes Jan 19, 2024
Signed-off-by: wadeking98 <[email protected]>
Signed-off-by: wadeking98 <[email protected]>
@wadeking98 wadeking98 merged commit 94e231e into openwallet-foundation:main Jan 20, 2024
6 of 7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Update or replace camera library
3 participants