Skip to content

[MOO-2490] : Updated vision camera to v5 & used react-native-vision-camera-barcode-scanner for barcode scanning-Main - #681

Open
saurabhchavan1711 wants to merge 17 commits into
mainfrom
moo/MOO-2490-barcode-scanner-vision-camera-v5-library-migration-main
Open

saurabhchavan1711 wants to merge 17 commits into
mainfrom
moo/MOO-2490-barcode-scanner-vision-camera-v5-library-migration-main

Conversation

@saurabhchavan1711

@saurabhchavan1711 saurabhchavan1711 commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Checklist

  • Contains unit tests ✅
  • Contains breaking changes ✅
  • Compatible with: MX 11
  • Did you update version and changelog? ✅
  • PR title properly formatted ([XX-000]: description)? ✅
  • Works in Android ✅
  • Works in iOS ✅
  • Works in Tablet ✅

Feature specific

  • Comply with designs ✅
  • Comply with PM's requirements ✅

This PR contains

  • Bug fix
  • Feature
  • Refactor
  • Documentation
  • Other (describe)

What is the purpose of this PR?

This PR updates the react native vision camera from v4 to v5. Also uses its aligned react-native-vision-camera-barcode-scanner library which is more advance and fixes the issue of scanning dense and patterned background QR codes.

Relevant Changes -

The barcode scanner now uses react-native-vision-camera-barcode-scanner, which brings in Google MLKit as prebuilt frameworks. MLKit's arm64 code is labelled for physical iPhones only, so the iOS e2e build fails at link time on our Apple Silicon CI runners, which build for an arm64 simulator: "building for 'iOS-simulator', but linking in object file ... built for 'iOS'". To fix this, the pipeline now runs scripts/test/patch-mlkit-arm64-simulator.js after pod install. The script changes the platform label on MLKit's arm64 object files from iOS to iOS simulator, which is safe because device and simulator arm64 code use the same instructions and only that label differs. xcodebuild also gets EXCLUDED_ARCHS="i386 x86_64" so Xcode builds the simulator app for arm64 only and never tries to link the unpatched x86_64 code. Without these changes the iOS app can't be built, so the iOS e2e tests can't run on this branch. The patch only touches the CI simulator build.

@saurabhchavan1711
saurabhchavan1711 requested a review from a team as a code owner October 13, 2026 13:24
@saurabhchavan1711 saurabhchavan1711 changed the title [MOO-2490] : barcode scanner vision camera v5 library migration main [MOO-2490] : Updated vision camera to v5 & used react-native-vision-camera-barcode-scanner for barcode scanning-Main Oct 13, 2026

const [cameraViewDimensions, setCameraViewDimensions] = useState<{ width: number; height: number } | null>(null);
// Timer that releases the lock, kept so it can be cleared when the widget unmounts
const lockTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

lockTimeoutRef is never assigned. The setTimeout(...) in onBarcodeScanned doesn't store its handle, so the unmount cleanup below never clears anything. Either assign it there (lockTimeoutRef.current = setTimeout(...)) or remove the ref and the effect.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done . Assigned lockTimeoutRef to SetTimeout.

@YogendraShelke

Copy link
Copy Markdown
Contributor

Please check the failing GitHub Actions checks on this PR.

@YogendraShelke

Copy link
Copy Markdown
Contributor

Blocker: iOS simulator builds fail on Apple Silicon Macs

react-native-vision-camera-barcode-scanner pulls in Google ML Kit on iOS (GoogleMLKit/BarcodeScanning 9.0.0, which resolves to MLKitBarcodeScanning 8.0.0, MLKitCommon 14.0.0, MLKitVision 10.0.0 and MLImage 1.0.0-beta8). These are prebuilt fat frameworks with only two slices:

  • x86_64, built for the iOS simulator
  • arm64, built for iOS devices only

There is no arm64 iOS-simulator slice. Linking the arm64 slice for the arm64 simulator fails with:

ld: building for 'iOS-simulator', but linking in object file (.../MLKitCommon[7](MLKLogger.o)) built for 'iOS'

scripts/test/patch-mlkit-arm64-simulator.js works around this for the e2e build only: it rewrites the platform tags in the Pods binaries, and its own header says the patched binaries must never ship. Native Template doesn't include that workaround. So anyone building a Native Template app locally for an iOS simulator on an Apple Silicon Mac will hit this link error. The remaining options (a Rosetta x86_64 simulator, or excluding arm64 for the simulator) both depend on Rosetta.

Since most developers are on Apple Silicon, we can't proceed with the ML Kit-based barcode scanner on iOS in its current form.

@saurabhchavan1711

saurabhchavan1711 commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor Author

@YogendraShelke , I checked the concern, and it was indeed a blocker for anyone trying to build the app for an iOS simulator. While looking for a quick workaround, I found that we can patch ML Kit for iOS simulators as the barcode functionality will be tested on physical device only and maybe in the future vision camera versions they can have the slice for arm64 simulators as well . the patch removes arm64 from ML Kit's simulator exclusion list and it also creates simulator-only copies of the ML Kit frameworks, re-tagged for the arm64 simulator while device builds keep using the original binaries, so the app can be built for iOS simulators. Please have a look: https://github.com/mendix/native-template/pull/1344/changes

I tested it locally, and the arm64 iOS simulator build succeeds. It also doesn't affect Android, Rosetta (x86_64) iOS simulator builds, or builds for physical iOS devices. Please let me know your thoughts.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants