react-native-vision-camera icon indicating copy to clipboard operation
react-native-vision-camera copied to clipboard

Vision Camera V2 - Fabric support

Open DominikHinc opened this issue 2 years ago • 4 comments

What

Since it'll be a while till v3 comes out we at Flip decided to contribute to the fabric support of vision camera v2. The library compiles on both platforms (1 small issue on IOS, which I will describe later) with Fabric enabled. Taking photo, recording, returning available camera devices etc. works correctly. The only thing which has not been implemented are the frame processors, which even on Paper we are not currently using (due to compatibility with reanimated 3). If someone needs a working camera on Fabric without any fancy processing, this is the code for you.

This implementation still needs more polishing, but due to end of resources on our side I hope somebody can take it from here, majority of migration has already been done.

Known compilation issue: On IOS, while compiling the library, it will throw such error:

image

I have tried to fix it in various ways, but nothing seems to work. A workaround I used to compile it for development purposes was to just create the mentioned header file directly in the pod directory

image

Creating such file in the source code doesn't work. If someone know how to fix it, I would appreciate such information.

I hope my code can help in the official migration of version 3 to Fabric. Any further contributions are encouraged.

Changes

  • Add support for IOS Fabric
  • Add support for Android Fabric
  • Enable Fabric as default architecture in the example app
  • Comment out or remove code related to frame processors

Tested on

Few IOS and Android devices, more testing should be done.

Related issues

‼️‼️‼️‼️ ✨ VisionCamera V3 ‼️‼️‼️‼️‼️

DominikHinc avatar Aug 09 '23 10:08 DominikHinc

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
react-native-vision-camera ❌ Failed (Inspect) Oct 23, 2023 11:48am

vercel[bot] avatar Aug 09 '23 10:08 vercel[bot]

Waiting for updates on this branch!! Thanks for your contributions!

keremkurtulus avatar Sep 01 '23 22:09 keremkurtulus

Known compilation issue: On IOS, while compiling the library, it will throw such error:

You have to update VisionCamera.podpsec file:

   # All source files that should be publicly visible
   # Note how this does not include headers, since those can nameclash.
   s.source_files = [
+    "VisionCamera.h",
     "ios/**/*.{m,mm,swift}",
     "ios/CameraBridge.h",

Thanks @DominikHinc it works like a charm on iOS (we don't support android yet so haven't tested it)

marcin-piela-800 avatar Sep 21 '23 07:09 marcin-piela-800

Heyo - looks like I never replied to this PR (sorry for that!), but this is actually quite helpful. I can't merge it because Frame Processors are required, but I think this might be of help for the V3 Fabric upgrade: https://github.com/mrousavy/react-native-vision-camera/issues/2614

mrousavy avatar Mar 04 '24 13:03 mrousavy

Hey - thanks for the PR again, but I'm gonna close this now in favor of the new architeecture migration for VC V4

mrousavy avatar May 08 '24 10:05 mrousavy