Commit Graph

138 Commits

Author SHA1 Message Date
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
Marc Rousavy
9963f4dedc chore: release 2.15.4 2023-02-01 16:37:53 +01:00
Marc Rousavy
a1a2cdc246 chore: release 2.15.3 2023-01-30 19:39:46 +01:00
Marc Rousavy
a65b8720bd chore: release 2.15.2 2022-10-31 13:05:21 +01:00
Marc Rousavy
1d6f720f8b chore: release 2.15.1 2022-10-24 14:10:30 +02:00
Marc Rousavy
849aa3ebaf chore: release 2.15.0 2022-10-20 12:50:08 +02:00
Marc Rousavy
0fbb8a3108 chore: release 2.14.1 2022-08-09 18:21:14 +02:00
Marc Rousavy
3329ee2841 chore: release 2.14.0 2022-07-18 10:42:58 +02:00
Marc Rousavy
147b9111d4 chore: release 2.13.5 2022-06-14 11:08:33 +02:00
Marc Rousavy
97f91b4fe9 Update package.json 2022-06-14 11:08:14 +02:00
Marc Rousavy
8f327267d3 chore: release 2.13.3 2022-05-05 09:56:34 +02:00
Marc Rousavy
c1d46d933b chore: release 2.13.2 2022-04-11 10:36:07 +02:00
Marc Rousavy
a7e66ed47c chore: release 2.13.1 2022-03-30 10:34:03 +02:00
Marc Rousavy
65d4d46f6a chore: release 2.13.0 2022-03-22 11:16:11 +01:00
Marc Rousavy
eb95add5ce chore: release 2.12.2 2022-03-07 12:57:18 +01:00
Marc Rousavy
ab15521c88 chore: release 2.12.1 2022-02-28 11:40:58 +01:00
Marc Rousavy
314e4c3c8b chore: release 2.12.0 2022-01-12 12:15:19 +01:00
Marc Rousavy
9577b7320b chore: release 2.11.2 2022-01-04 17:02:26 +01:00
Marc Rousavy
f4d58412a6 chore: release 2.11.1 2022-01-03 13:20:10 +01:00
Marc Rousavy
db2a883259 Update package.json 2022-01-02 18:23:44 +01:00
Marc Rousavy
8a87820078 chore: release 2.11.0 2022-01-02 18:02:22 +01:00
Marc Rousavy
138c3f9a9a chore: release 2.10.0 2021-12-10 09:58:33 +01:00
Marc Rousavy
a54ff5782c chore: release 2.9.4 2021-11-23 15:48:34 +01:00
Marc Rousavy
7206a794a9 chore: release 2.9.3 2021-10-14 12:47:45 +02:00
Marc Rousavy
bb0a09d2a1 chore: release 2.9.2 2021-10-13 15:18:56 +02:00
Marc Rousavy
3315f51faf chore: release 2.9.1 2021-10-11 20:46:13 +02:00
Marc Rousavy
bd46da614e chore: release 2.9.0 2021-10-07 11:57:37 +02:00
Marc Rousavy
916278d3ea
feat: Add React Native 0.66 support (#490)
* feat: Add React Native 0.66 support

* Generate lockfiles

* Update Podfile.lock

* chore: Migrate from react-native-navigation to react-navigation (#491)

* Migrate RNN -> RN

* Migrate all screens

* Fix get permission status

* fix app name

* Update AppDelegate.m

* Fix Info.plist

* Set `UIViewControllerBasedStatusBarAppearance` to `YES`

* Only enable `audio` if user granted microphone permission

* Update App.tsx

* Fix RNGH for Android

* Use `navigate` instead of `push`

* Fix animation

* Upgrade @types/react-native

* "Splash" -> "PermissionsPage"
2021-10-05 12:22:14 +02:00
Marc Rousavy
e1dafe05fe chore: release 2.8.3 2021-09-27 14:44:46 +02:00
Marc Rousavy
17b1d1fda4 chore: release 2.8.2 2021-09-24 17:00:42 +02:00
Marc Rousavy
60ea779ffe
fix: De-allocate frame HybridClass with JNI class loader if using Hermes (#455)
* De-allocate `frame` HybridClass with JNI class loader if using Hermes

See 1b3a0c2612

* Don't wrap in `#if FOR_HERMES`, other `jsi::Runtime`s might also run GC on another Thread.

* Use `jni::local_ref` for `FrameHostObject`

* Update JImageProxyHostObject.cpp

* Only run with JNI `ClassLoader` if ctor Thread ID != dtor Thread ID

* Upgrade reanimated to 2.3.0-beta.1 to fix JNI crash

* Remove `this_thread::get_id()`

* Update Podfile.lock
2021-09-24 16:57:12 +02:00
Marc Rousavy
e99da26561 chore: release 2.8.1 2021-09-24 10:22:42 +02:00
Marc Rousavy
d3105fa207
chore: Upgrade a whole lotta dependencies (#436)
* chore: Upgrade a lot of dependencies for `./`

* chore: Upgrade a lot of dependencies for `./example`

* chore: Upgrade a lot of dependencies for `./docs`

* Use new `EventEmitter` syntax (`.remove()`)

* Update Podfile.lock

* docs: Use watch mode

* docs: Replace all relative links with absolute

* Fix all links

* Update docusaurus.config.js

* Upgrade docusaurus-plugin-typedoc to fix docs build

* Update yarn.lock

* Upgrade typescript to 4.4.3

* Fix error unknown

* Update package.json

* Upgrade typedoc

* Upgrade a few more deps

* Fix deprecated sidebar syntax

* Update Gemfile.lock
2021-09-22 13:58:59 +02:00
Marc Rousavy
ffb4a188a2 chore: release 2.8.0 2021-09-21 15:53:50 +02:00
Marc Rousavy
e82103977f chore: release 2.7.0 2021-09-06 16:27:53 +02:00
Marc Rousavy
ad5e131f6a
feat: frameProcessorFps="auto" and automatic performance suggestions (throttle or increase FPS) (#393)
* Add `onFrameProcessorPerformanceSuggestionAvailable` and make `frameProcessorFps` support `auto`

* Implement performance suggestion and auto-adjusting

* Fix FPS setting, evaluate correctly

* Floor suggested FPS

* Remove `console.log` for frame drop warnings.

* Swift format

* Use `30` magic number

* only call if FPS is different

* Update CameraView.swift

* Implement Android 1/2

* Cleanup

* Update `frameProcessorFps` if available

* Optimize `FrameProcessorPerformanceDataCollector` initialization

* Cache call

* Set frameProcessorFps directly (Kotlin setter)

* Don't suggest if same value

* Call suggestion every second

* reset time on set

* Always store 15 last samples

* reset counter too

* Update FrameProcessorPerformanceDataCollector.swift

* Update CameraView+RecordVideo.swift

* Update CameraView.kt

* iOS: Redesign evaluation

* Update CameraView+RecordVideo.swift

* Android: Redesign evaluation

* Update CameraView.kt

* Update REA to latest alpha and install RNScreens

* Fix frameProcessorFps updating
2021-09-06 16:27:16 +02:00
Bartosz Kaszubowski
2e00b5bc33
chore: fix bootstrap script (#381) 2021-08-20 17:37:13 +02:00
Marc Rousavy
b7bfa5ef0a chore: release 2.6.1 2021-08-20 16:05:31 +02:00
Marc Rousavy
97c20d96ae chore: release 2.6.0 2021-08-20 16:03:08 +02:00
Marc Rousavy
cae08a1402
feat: Add react-native 0.65 support (#378)
* fix `;`

* upgrade react-native to 0.65.1

* upgrade example to react-native 0.65.1

* Update Podfile.lock

* Update Podfile.lock

* add `jcenter()` temporarily

* upgrade gradle tools (kotlin, build-tools, swipe-to-refresh)

* Upgrade `react-native-navigation` to `7.18.1-snapshot.1611`

* chore(deps): Upgrade a few more deps
2021-08-20 11:53:40 +02:00
Marc Rousavy
a2293e858d
fix: Fix TypeScript relative imports (#358)
* fix: Fix TypeScript relative imports

* Decouple `example` from tsconfig

* fix ESLint config

* add lint-ci script

* move example running to workflow

* test ts

* test eslint

* test ts

* fix ESLint formatter

* Revert "fix ESLint formatter"

This reverts commit 21aca0dcdb54d4ce98b33d2b4f1decc18bc82e85.

* Revert "test ts"

This reverts commit becc346ad3d097b7d3570ebc8b5bf80390aadf87.

* Revert "test eslint"

This reverts commit 9c9f0b81bf3aa57188f550a34b2a8151e364f3b0.

* Revert "test ts"

This reverts commit 3cbe7200608910087b43e0d9cdae0917b0b4215e.
2021-08-16 10:45:41 +02:00
Marc Rousavy
ee762ce5f5 chore: release 2.5.0 2021-08-06 11:18:38 +02:00
dependabot[bot]
a442eeb0ff
chore(deps-dev): bump typescript from 4.3.2 to 4.3.5 (#251)
Bumps [typescript](https://github.com/Microsoft/TypeScript) from 4.3.2 to 4.3.5.
- [Release notes](https://github.com/Microsoft/TypeScript/releases)
- [Commits](https://github.com/Microsoft/TypeScript/compare/v4.3.2...v4.3.5)

---
updated-dependencies:
- dependency-name: typescript
  dependency-type: direct:development
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2021-08-06 10:44:50 +02:00
Marc Rousavy
25ab5382c1 chore: release 2.4.2-beta.13 2021-08-05 09:44:49 +02:00
Marc Rousavy
43f5a735a5 chore: release 2.4.2-beta.12 2021-08-01 15:30:10 +02:00
Marc Rousavy
123d0d9e9c
chore(deps): Upgrade react-native-reanimated to alpha.2 (#309)
* Upgrade react-native-reanimated to alpha.2

* fix Android header search path

* Make `const`
2021-07-30 09:50:09 +02:00
Marc Rousavy
39b16e60e4 chore: Also show dependency upgrades in release notes 2021-07-26 11:38:12 +02:00
Marc Rousavy
0c2ffd51d5 chore: release 2.4.2-beta.11 2021-07-26 11:33:56 +02:00