Commit Graph

975 Commits

Author SHA1 Message Date
Marc Rousavy
c2096a4c71 fix: Fix FP Plugin init call 2023-07-31 11:34:27 +02:00
Marc Rousavy
deeb8db59f fix: Fix namespace 2023-07-31 11:34:21 +02:00
Marc Rousavy
78a64abb8c chore: Bump version 2023-07-31 11:31:55 +02:00
Marc Rousavy
86dd703c2b
feat: Rewrite Android C++ part (VisionCameraProxy + JFrame) (#1661)
* First Android rewrite

* Rewrite Android C++ backend

* Pass `ReadableNativeMap`, fix build error

* fix: Fix FrameProcessor init

* Make a bunch of stuff const reference to avoid copies

* Indents

* Cleanup

* indents

* docs: Update Android docs

* Update CameraView.kt

* fix: Format C++ code
2023-07-22 00:15:11 +02:00
Marc Rousavy
44ed42d5d6
feat: Expose unified VisionCameraProxy object, make FrameProcessorPlugins object-oriented (#1660)
* feat: Replace `FrameProcessorRuntimeManager` with `VisionCameraProxy` (iOS)

* Make `FrameProcessorPlugin` a constructable HostObject

* fix: Fix `name` override

* Simplify `useFrameProcessor

* fix: Fix lint errors

* Remove FrameProcessorPlugin::name

* JSIUtils -> JSINSObjectConversion
2023-07-21 17:52:30 +02:00
Marc Rousavy
375e894038
feat: Complete iOS Codebase rewrite (#1647)
* Make Frame Processors an extra subspec

* Update VisionCamera.podspec

* Make optional

* Make VisionCamera compile without Skia

* Fix

* Add skia again

* Update VisionCamera.podspec

* Make VisionCamera build without Frame Processors

* Rename error to `system/frame-processors-unavailable`

* Fix Frame Processor returning early

* Remove `preset`, FP partial rewrite

* Only warn on frame drop

* Fix wrong queue

* fix: Run on CameraQueue again

* Update CameraView.swift

* fix: Activate audio session asynchronously on audio queue

* Update CameraView+RecordVideo.swift

* Update PreviewView.h

* Cleanups

* Cleanup

* fix cast

* feat: Add LiDAR Depth Camera support

* Upgrade Ruby

* Add vector icons type

* Update Gemfile.lock

* fix: Stop queues on deinit

* Also load `builtInTrueDepthCamera`

* Update CameraViewManager.swift

* Update SkImageHelpers.mm

* Extract FrameProcessorCallback to FrameProcessor

Holds more context now :)

* Rename to .m

* fix: Add `RCTLog` import

* Create SkiaFrameProcessor

* Update CameraBridge.h

* Call Frame Processor

* Fix defines

* fix: Allow deleting callback funcs

* fix Skia build

* batch

* Just call `setSkiaFrameProcessor`

* Rewrite in Swift

* Pass `SkiaRenderer`

* Fix Import

* Move `PreviewView` to Swift

* Fix Layer

* Set Skia Canvas to Frame Host Object

* Make `DrawableFrameHostObject` subclass

* Fix TS types

* Use same MTLDevice and apply scale

* Make getter

* Extract `setTorch` and `Preview`

* fix: Fix nil metal device

* Don't wait for session stop in deinit

* Use main pixel ratio

* Use unique_ptr for Render Contexts

* fix: Fix SkiaPreviewDisplayLink broken after deinit

* inline `getTextureCache`

* Update CameraPage.tsx

* chore: Format iOS

* perf: Allow MTLLayer to be optimized for only frame buffers

* Add RN Video types

* fix: Fix Frame Processors if guard

* Find nodeModules recursively

* Create `Frame.isDrawable`

* Add `cocoapods-check` dependency
2023-07-20 15:30:04 +02:00
Marc Rousavy
5fb594ce6b fix: Fix Worklets imports 2023-07-03 22:32:08 +02:00
Marc Rousavy
0139324da8 fix: Use correct Gradle version 2023-07-03 22:21:02 +02:00
Marc Rousavy
66c64814cc fix: Downgrade Gradle to 7.5.1 2023-07-03 22:15:06 +02:00
Marc Rousavy
cde8b762a3 chore: Remove react-native-slider 2023-07-03 22:10:20 +02:00
Marc Rousavy
7ae15af8cd feat: Add RN 0.72 support (namespace in build.gradle) 2023-07-03 22:07:49 +02:00
Marc Rousavy
0111f2edb4 fix: Simplify Podfile 2023-07-03 13:37:43 +02:00
Marc Rousavy
d964f40e53 Merge branch 'v3' of https://github.com/mrousavy/react-native-vision-camera into v3 2023-07-03 12:41:33 +02:00
Marc Rousavy
82eaf9594f chore: Extract to convertMTLTextureToSkImage 2023-07-03 12:41:26 +02:00
Marc Rousavy
4ad4804e51
chore: Upgrade Skia to new Ganesh Rendering Pipeline and RN to 0.72 (#1638)
* chore: Upgrade all Deps RN 72

* fix breaking skia changes

* fix devDeps

* Update yarn.lock

* fix metro config

* Update yarn.lock
2023-07-03 12:40:07 +02:00
Hanno J. Gödecke
820db3ca9e
android: add build support with RNSkia
This still depends on this PR to be merged: https://github.com/Shopify/react-native-skia/pull/1550
2023-05-04 12:30:24 +02:00
Marc Rousavy
f03dde725e
fix: Fix Skia build (#1582)
* Add Skia search path from `node_modules/`

* fix: Find `react-native-skia` from node_modules

* fix: Upgrade RN Skia to use includes fix

* Update FrameProcessorUtils.mm
2023-05-03 14:27:34 +02:00
Marc Rousavy
032798331a chore: Upgrade RN Skia 2023-05-02 12:54:18 +02:00
Marc Rousavy
bf52e8dad7 chore: Upgrade React Native for Xcode fix 2023-04-24 22:40:14 +02:00
Marc Rousavy
bb7ab30a0e fix: Set min iOS version to 12.4 2023-04-24 22:32:20 +02:00
Marc Rousavy
38749fb613 fix: Fix missing Camera error 2023-04-21 12:08:59 +02:00
Marc Rousavy
533c32a48d docs: fix wrong comment 2023-03-29 12:03:20 +02:00
Marc Rousavy
af4e366312 fix: Fix runAtTargetFps for multiple invocations per FP 2023-03-21 16:10:09 +01:00
Marc Rousavy
e1973b9b8d chore: Use Reanimated 3 from npm 2023-03-21 15:19:32 +01:00
Marc Rousavy
6deb6862cf fix: Remove temp-patch for REA plugin 2023-03-21 15:17:22 +01:00
Marc Rousavy
a1af891879 fix: Use global.expo.modules for JSI expo modules 2023-03-15 09:34:15 -04:00
Marc Rousavy
0d83a13196
feat: New CameraDevice + CameraFormat detection using CameraX (#1495)
* Create CameraDevice.kt

* Create VideoStabilizationMode+String.kt

* Use CameraX Extensions

* Remove `system/no-camera-manager` error
2023-03-13 09:23:19 -04:00
Marc Rousavy
f791c6b4cd
feat: Better Native Module Error Detection (#1515)
* feat: Add more Error insights when the Camera Module cannot be found

* Assert JSI is available

* Update error description

* fix

* Update CameraError.ts
2023-03-13 09:21:08 -04:00
Marc Rousavy
622d3830f1
feat: Make Frame Processor Plugins object-oriented on iOS as well (#1496)
* feat: Make Frame Processor Plugins object-oriented on iOS as well

* Add Plugin in AppDelegate
2023-02-27 11:18:03 +01:00
Marc Rousavy
61f19df500 fix: Remove RN Skia dependency on Android for now 2023-02-23 17:43:24 +01:00
Marc Rousavy
f227a3e396 fix: Catch device == null error 2023-02-23 14:57:57 +01:00
Marc Rousavy
ad5d64b01f fix: ignore duplicate .so libraries in package 2023-02-22 12:28:51 +01:00
Marc Rousavy
cf19ff2e5a fix: Fix Android namespace 2023-02-21 15:54:04 +01:00
Marc Rousavy
0c3cd66016
fix: Improve C++ safety by attaching Cache Invalidator to jsi::Runtime's lifecycle (#1488)
* fix: fix C++ lint

* fix: attach `InvalidateCacheOnDestroy` to `jsi::Runtime`
2023-02-21 15:44:43 +01:00
Marc Rousavy
1ddea178ae chore: release 3.0.0-rc.2 2023-02-21 15:09:55 +01:00
Marc Rousavy
12f850c8e1
feat: Draw onto Frame as if it was a Skia Canvas (#1479)
* Create Shaders.ts

* Add `previewType` and `enableFpsGraph`

* Add RN Skia native dependency

* Add Skia Preview View on iOS

* Pass 1

* Update FrameHostObject.mm

* Wrap Canvas

* Lockfiles

* fix: Fix stuff

* chore: Upgrade RNWorklets

* Add `previewType` to set the Preview

* feat: Add Example

* Update project.pbxproj

* `enableFpsGraph`

* Cache the `std::shared_ptr<FrameHostObject>`

* Update CameraView+RecordVideo.swift

* Update SkiaMetalCanvasProvider.mm

* Android: Integrate Skia Dependency

* fix: Use new Prefix

* Add example for rendering shader

* chore: Upgrade CameraX

* Remove KTX

* Enable `viewBinding`

* Revert "Enable `viewBinding`"

This reverts commit f2a603f53b33ea4311a296422ffd1a910ce03f9e.

* Revert "chore: Upgrade CameraX"

This reverts commit 8dc832cf8754490d31a6192e6c1a1f11cdcd94fe.

* Remove unneeded `ProcessCameraProvider.getInstance()` call

* fix: Add REA hotfix patch

* fix: Fix FrameHostObject dead in runAsync

* fix: Make `runAsync` run truly async by dropping new Frames while executing

* chore: Upgrade RN Worklets to latest

* chore: Upgrade RN Skia

* Revert "Remove KTX"

This reverts commit 253f586633f7af2da992d2279fc206dc62597129.

* Make Skia optional in CMake

* Fix import

* Update CMakeLists.txt

* Update build.gradle

* Update CameraView.kt

* Update CameraView.kt

* Update CameraView.kt

* Update Shaders.ts

* Center Blur

* chore: Upgrade RN Worklets

* feat: Add `toByteArray()`, `orientation`, `isMirrored` and `timestamp` to `Frame` (#1487)

* feat: Implement `orientation` and `isMirrored` on Frame

* feat: Add `toArrayBuffer()` func

* perf: Do faster buffer copy

* feat: Implement `toArrayBuffer()` on Android

* feat: Add `orientation` and `isMirrored` to Android

* feat: Add `timestamp` to Frame

* Update Frame.ts

* Update JImageProxy.h

* Update FrameHostObject.cpp

* Update FrameHostObject.cpp

* Update CameraPage.tsx

* fix: Format Swift
2023-02-21 15:00:48 +01:00
Marc Rousavy
1f7a2e07f2 fix: Fix global.FrameProcessorPlugins TS error 2023-02-15 19:15:36 +01:00
Marc Rousavy
0635d4aba0 fix: Add missing <regex> header 2023-02-15 19:13:33 +01:00
Marc Rousavy
2909085ea6 chore: release 3.0.0-rc.1 2023-02-15 18:23:05 +01:00
Marc Rousavy
770357fd94 chore: Bump to 3.0.0-rc.0 2023-02-15 18:21:33 +01:00
Marc Rousavy
222ded4728 fix: Prevent possible crash in log error handler 2023-02-15 18:15:13 +01:00
Marc Rousavy
6825c1f587 fix: Print correct error in build.gradle 2023-02-15 17:39:46 +01:00
Marc Rousavy
f0ea18115e
fix: Fix CI for V3 (#1475)
* fix: Fix CI for "Build Android"

* update versions

* Update Gemfile.lock

* format swift

* fix: Fix swift lint

* Update .swiftlint.yml

* Use C++17 for lint

* fix: Fix C++ lints
2023-02-15 17:24:33 +01:00
Marc Rousavy
30b56153db
feat: Sync Frame Processors (plus runAsync and runAtTargetFps) (#1472)
Before, Frame Processors ran on a separate Thread.

After, Frame Processors run fully synchronous and always at the same FPS as the Camera.

Two new functions have been introduced:

* `runAtTargetFps(fps: number, func: () => void)`: Runs the given code as often as the given `fps`, effectively throttling it's calls.
* `runAsync(frame: Frame, func: () => void)`: Runs the given function on a separate Thread for Frame Processing. A strong reference to the Frame is held as long as the function takes to execute.

You can use `runAtTargetFps` to throttle calls to a specific API (e.g. if your Camera is running at 60 FPS, but you only want to run face detection at ~25 FPS, use `runAtTargetFps(25, ...)`.)

You can use `runAsync` to run a heavy algorithm asynchronous, so that the Camera is not blocked while your algorithm runs. This is useful if your main sync processor draws something, and your async processor is doing some image analysis on the side. 

You can also combine both functions.

Examples:

```js
const frameProcessor = useFrameProcessor((frame) => {
  'worklet'
  console.log("I'm running at 60 FPS!")
}, [])
```

```js
const frameProcessor = useFrameProcessor((frame) => {
  'worklet'
  console.log("I'm running at 60 FPS!")

  runAtTargetFps(10, () => {
    'worklet'
    console.log("I'm running at 10 FPS!")
  })
}, [])
```



```js
const frameProcessor = useFrameProcessor((frame) => {
  'worklet'
  console.log("I'm running at 60 FPS!")

  runAsync(frame, () => {
    'worklet'
    console.log("I'm running on another Thread, I can block for longer!")
  })
}, [])
```

```js
const frameProcessor = useFrameProcessor((frame) => {
  'worklet'
  console.log("I'm running at 60 FPS!")

  runAtTargetFps(10, () => {
    'worklet'
    runAsync(frame, () => {
      'worklet'
      console.log("I'm running on another Thread at 10 FPS, I can block for longer!")
    })
  })
}, [])
```
2023-02-15 16:47:09 +01:00
Marc Rousavy
a0590dccb5
feat: Replace Reanimated with RN Worklets (#1468)
* Setup RN Worklets

* Use RN Worklets on iOS

* Fix console

* Add `installFrameProcessorBindings()` function

* Add `FrameProcessorPlugins` proxy (BREAKING CHANGE)

* Clean up docs

* Update FRAME_PROCESSORS.mdx

* Use RN Worklets 0.2.5

* feat: Android build setup

* Rewrite Android Frame Processor Part

* Update CMakeLists.txt

* fix: Add react-native-worklets Gradle dependency

* Update Podfile.lock

* fix build

* gradle:7.4.1

* Init JSI Bindings in method on Android

* Fix Folly flags

* fix: Init `FrameProcessorRuntimeManager` later

* fix: Wrap in `<GestureHandlerRootView>`

* Refactor plugins

* fix: Remove enableFrameProcessors

* Install RN Worklets from current GH master

* Update babel.config.js

* Update CameraViewModule.kt

* Update ImageProxyUtils.java

* feat: Upgrade to Reanimated v3

* fix: Fix crash on Worklet init

* Update RN Worklets to latest master

* fix: Simplify FP Plugins Proxy
2023-02-13 15:22:45 +01:00
Marc Rousavy
11d1e7178d
chore: Upgrade to RN 71 (#1465)
* chore: Upgrade Example to RN 0.71

* chore: Upgrade all libs

* fix: Fix CameraRoll installation

* Update Gradle Tools

* fix: Fix buildscripts

* Clean out build.gradle

* fix: Fix Kotlin setup

* fix: Move kotlin-android dependency to lib

* Move `_setGlobalConsole`

* Update gradle-wrapper.properties

* Rebuild lockfiles

* chore: Update build:gradle

* Update StatusBarBlurBackground.tsx

* Use Java 11 in Workflows

* Update MediaPage.tsx

* Add `google` repository to build.gradle

* Double Java Heap size

* Increase heap size

* Alternative args

* Update build.gradle
2023-02-09 11:52:41 +01:00
mrousavy
28a43f716f chore: Drop support for RN < 71 to simplify buildscript 2023-02-08 17:48:22 +01:00
Marc Rousavy
9963f4dedc chore: release 2.15.4 2023-02-01 16:37:53 +01:00
zzz08900
6a094bf1b0
fix: Fix Android build error on RN < 0.71 (#1447) 2023-02-01 16:37:18 +01:00
Marc Rousavy
a1a2cdc246 chore: release 2.15.3 2023-01-30 19:39:46 +01:00