What feature or enhancement are you suggesting?
VisionCamera needs to migrate to the new architecture, and use Fabric for the View, and TurboModules + CodeGen for the native methods. Also, this implies compatibility with react-native 0.74, as that currently fails to build. (related to New Arch)
Implementation plan
Since VisionCamera is a bit more complicated, there are a few blockers I have encountered:
- ❌ I have both a View (
CameraView) and two Modules (CameraModule + DevicesModule) in the codebase. Currently, the create-react-native-library template does not have a template for multiple CodeGen specs (views + modules).
- ❌ For the Frame Processor runtime I need access to the
jsi::Value/jsi::Function that the user passes to the <Camera> view directly, instead of converting it to a callback within the TurboModules/Native Modules system because the Frame Processor function is a Worklet. This is how this works currently:
- ❌ For the Frame Processor runtime I need access to the
jsi::Runtime as early as possible (on demand). Currently I get the jsi::Runtime from the RCTCxxBridge/CatalystInstance, which is a kinda private and unsafe API.
And then a few things I wanted to wait for (which aren't blockers) before switching to the new arch are:
- I want to pass multiple callbacks to a native function. This was a limitation with the Bridge, but should now work with TurboModules I think? In my case
startRecording() takes both onRecordingFinished and onRecordingError callbacks, and also returns a Promise which resolves once the recording has actually been started.
- I couldn't find a clear script to trigger CodeGen (something like
npx react-native codegen) to generate both iOS and Android specs.
- New arch doesn't have first class Swift support as far as I know?
- New arch doesn't support custom "hybrid" objects (so e.g. I could return an in-memory
UIImage/Image instance in takePhoto(), instead of writing it to a file and returning a string as that's the only supported type)
What Platforms whould this feature/enhancement affect?
iOS, Android
Alternatives/Workarounds
Currently only the renderer interop layer can be used, but there are some issues:
Additional information
What feature or enhancement are you suggesting?
VisionCamera needs to migrate to the new architecture, and use Fabric for the View, and TurboModules + CodeGen for the native methods. Also, this implies compatibility with react-native 0.74, as that currently fails to build. (related to New Arch)
Implementation plan
Since VisionCamera is a bit more complicated, there are a few blockers I have encountered:
CameraView) and two Modules (CameraModule+DevicesModule) in the codebase. Currently, the create-react-native-library template does not have a template for multiple CodeGen specs (views + modules).CameraViewManager.swiftCameraDevicesManager.swiftCameraView.swiftjsi::Value/jsi::Functionthat the user passes to the<Camera>view directly, instead of converting it to a callback within the TurboModules/Native Modules system because the Frame Processor function is a Worklet. This is how this works currently:Camera.tsx(usesfindNodeHandle(..)+ a globalsetFrameProcessor(..)func)VisionCameraProxy.mm(usesUIManager::viewForReactTagto find the view)VisionCameraProxy.kt(usesUIManagerHelper.getUIManagerto find the View)jsi::Runtimeas early as possible (on demand). Currently I get thejsi::Runtimefrom theRCTCxxBridge/CatalystInstance, which is a kinda private and unsafe API.VisionCameraInstaller::installVisionCameraProxy.ktAnd then a few things I wanted to wait for (which aren't blockers) before switching to the new arch are:
startRecording()takes bothonRecordingFinishedandonRecordingErrorcallbacks, and also returns aPromisewhich resolves once the recording has actually been started.npx react-native codegen) to generate both iOS and Android specs.UIImage/Imageinstance intakePhoto(), instead of writing it to a file and returning astringas that's the only supported type)What Platforms whould this feature/enhancement affect?
iOS, Android
Alternatives/Workarounds
Currently only the renderer interop layer can be used, but there are some issues:
Additional information