Commit Graph

91 Commits

Author SHA1 Message Date
Marc Rousavy
3d51cca02c chore: Also run validate-cpp for Android C++ files 2021-09-07 14:17:35 +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
Natalia
3b7560ac4d
fix: Fix Android tasks execution (#407) 2021-09-06 10:32:06 +02:00
Marc Rousavy
98128471cc
fix: Fix Proguard annotation for mHybridData (#406)
* fix: Fix Proguard annotation for `mHybridData`

* rebuild lockfiles
2021-09-05 11:24:33 +02:00
Marc Rousavy
ff5a8b8900
fix: Improve Android resource efficiency/cleanup (use class members for CoroutineScope and FrameProcessorThread) (#335)
* fix: Use custom CoroutineScope

* fix: Use custom `CoroutineScope`

* Make `frameProcessorThread` and `coroutineScope` instance variables

* Update VisionCameraScheduler.java

* Remove `HybridData::resetNative()` calls

they're called by a Java GC destructor anyways.

* Update CameraViewManager.kt

* Update CameraView.kt
2021-08-25 11:33:57 +02:00
Marc Rousavy
c7fb89170e
fix: Apply correct initial rotation on Android (#368)
* fix: Apply correct initial rotation

* Make `rotation` a property getter

* Update CameraView.kt
2021-08-25 11:16:07 +02:00
Marc Rousavy
c657bf8718 Revert "fix: Fix Frame Processor null-dereference error (use ref-counted JNI local_ref) (#351)"
This reverts commit d06bcf648c.
2021-08-20 16:05:09 +02:00
Marc Rousavy
90f2a1ef7d
fix: Fix close being called on a collected reference (enforce alias_ref) (#379)
* fix: Fix `close` being called on a collected reference (enforce `alias_ref`)

* Remove `~FrameHostObject` on iOS too
2021-08-20 16:05:02 +02:00
Marc Rousavy
0d3f2cbd9d
fix: Fix crash when accessing planesCount or bytesPerRow (#380)
* fix: Fix `bytesPerRow` and `planeCount` crashing

* use direct call

* Call `getPlanesCount` and `getBytesPerRow` through java

* revert camerapage changes

* remove removed header import

* Update CameraPage.tsx
2021-08-20 16:02:34 +02:00
Marc Rousavy
d06bcf648c
fix: Fix Frame Processor null-dereference error (use ref-counted JNI local_ref) (#351) 2021-08-20 15:57:31 +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
8e02b49c16
chore(deps): Upgrade CameraX to alpha08 (#377) 2021-08-20 11:07:20 +02:00
Marc Rousavy
494925c96e
fix: Always return authorized for requestPermission on SDK 22 and below (#344) 2021-08-09 11:43:56 +02:00
dependabot[bot]
80f87bfc77
chore(deps): bump exifinterface from 1.3.2 to 1.3.3 in /android (#327)
Bumps exifinterface from 1.3.2 to 1.3.3.

---
updated-dependencies:
- dependency-name: androidx.exifinterface:exifinterface
  dependency-type: direct:production
  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:57 +02:00
Marc Rousavy
37db643f71
fix: Fix format Preview and Video Capture resolution setting (#325)
* fix: Actually use a format's `videoSize` for Preview/Video Capture

* `setDefaultResolution` -> `setTargetResolution`
2021-08-05 15:54:01 +02:00
Marc Rousavy
1c32726ef6
fix: Throw JS errors if JSI <-> JNI conversion failed (#324) 2021-08-05 10:10:49 +02:00
Marc Rousavy
b493576373
fix: Fix java.lang.NoSuchMethodError error for .toArrayList() (#322)
* fix: Fix `java.lang.NoSuchMethodError` error for `.toArrayList()`

* Fix `HashMap<K, V>` conversion to `jsi::Object`

* Update FRAME_PROCESSORS_CREATE_OVERVIEW.mdx
2021-08-04 16:07:08 +02:00
Marc Rousavy
aaecb90937
fix: Fix dead link in parallel-video-processing-not-supported error 2021-08-02 11:21:23 +02:00
Marc Rousavy
0f7ee51333
feat: Add console logging support for Frame Processors (#297)
* Try to log to console via runOnJS

* Call `console.log`

* Create custom `VisionCameraScheduler`

* Fix scheduler call

* Call with this

* Fix console setting

* Move J---- to `java-bindings`

* c++ style

* Android: 1/2 Create custom Scheduler

* Android: 2/2 Use custom Scheduler

* Don't use `runOnJS`, use `__callAsync` directly
2021-07-30 10:27:45 +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
445af943c3
feat: BREAKING CHANGE: Express zoom factor always in actual factor value (1, 2, 128, ...) instead of 0.0-1.0 scale (#306)
* Make `zoom` go on "factor" scale

* Clean up `zoom` code

* fix float conversion

* fix zoom interpretation

* Update docs for new zoom scale

* fix float conversion
2021-07-29 11:44:22 +02:00
Marc Rousavy
ef455df865
feat: Support rotation (#301)
* feat: Android: Listen to rotation changes

* Only change rotation on configuration change

* feat: iOS: Support Rotation

* Swift lint
2021-07-26 11:32:58 +02:00
Marc Rousavy
159ff44de3
chore(deps): Upgrade CameraX to 7 (#300) 2021-07-26 10:23:18 +02:00
Marc Rousavy
5eaed05f47
fix: Fix "REACT_NATIVE_UTILS_LIB not found" build error (#295)
* Remove `REACT_NATIVE_UTILS_LIB`

* Clean up CMakeLists.txt
2021-07-23 14:28:38 +02:00
Marc Rousavy
4b4ea0ff33
fix: Fix UI Thread race condition in setFrameProcessor(...) (#265)
* fix: Fix UI Thread race condition in `setFrameProcessor(...)`

* Revert "fix: Fix UI Thread race condition in `setFrameProcessor(...)`"

This reverts commit 9c524e123cff6843d7d11db602a5027d1bb06b4b.

* Use `setImmediate` to call `setFrameProcessor(...)`

* Fix frame processor order of applying

* Add `enableFrameProcessor` prop that defines if a FP is added

* rename constant

* Implement `enableFrameProcessor` prop for Android and make `frameProcessorFps` faster

* link to troubleshooting guide

* Update TROUBLESHOOTING.mdx

* Add logs for use-cases

* fix log

* set initial frame processor in `onLayout` instead of `componentDidMount`
2021-07-12 15:16:03 +02:00
Marc Rousavy
66f22d7b21 fix: Only extract either JSC or Hermes REA .aar 2021-07-08 11:12:26 +02:00
Marc Rousavy
b2f3c08a07
fix: Distribute Android code as source (#234)
* Build Android as source

* more reliably find `enableHermes`
2021-07-08 10:52:14 +02:00
dependabot[bot]
63053f8650
chore(deps): bump gradle-download-task from 4.1.1 to 4.1.2 in /android (#262)
Bumps [gradle-download-task](https://github.com/michel-kraemer/gradle-download-task) from 4.1.1 to 4.1.2.
- [Release notes](https://github.com/michel-kraemer/gradle-download-task/releases)
- [Commits](https://github.com/michel-kraemer/gradle-download-task/compare/4.1.1...4.1.2)

---
updated-dependencies:
- dependency-name: de.undercouch:gradle-download-task
  dependency-type: direct:production
  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-07-08 10:50:38 +02:00
Marc Rousavy
2f889f5855
fix: Fix hot-reload crash caused by Frame Processor Runtime being initialized twice (#258)
* Fix Frame Processor Runtime being initialized twice causing a hot-reload to crash

* Remove unnecessary `HasRegisteredPlugins` singleton

* make non-optional

* `REACT_CLASS` -> `TAG`

* fix nullable
2021-07-07 15:00:32 +02:00
Marc Rousavy
3007cd9430 fix: Add @Keep annotation to prevent minifier from deleting java funcs 2021-07-07 13:18:38 +02:00
Marc Rousavy
7a5e879b92 fix: Fix lint error for missing JNI func (3) 2021-07-07 13:17:41 +02:00
Marc Rousavy
91e81d7594 fix: Fix lint error for missing JNI func (2) 2021-07-07 13:16:19 +02:00
Marc Rousavy
1730ce8980 fix: Fix lint error for missing JNI func 2021-07-07 13:15:32 +02:00
Marc Rousavy
339b470ca5 fix: Fix wrong HDR error being thrown on LowLight mode 2021-07-07 13:14:36 +02:00
Marc Rousavy
1e64215d37
chore(deps): upgrade camerax (#257)
* Upgrade CameraX to alpha6

* Upgrade CameraX extensions to alpha26

* `init` -> `getInstance`

* Use new Extensions API

* Update CameraView.kt

* use new ExtensionsManager API in `getAvailableCameraDevices()`

* fix cpplint errors
2021-07-07 12:57:28 +02:00
Marc Rousavy
2fa0f8fd46
chore: Clean up root directory (#236)
* Clean up root

* remove unused REA patches

* Remove `cpp/` and create headers per platform

* fix `#import`

* fix `VISION_CAMERA_DISABLE_FRAME_PROCESSORS`
2021-07-06 16:42:58 +02:00
Marc Rousavy
fa5f5c0cab
feat: Implement Frame.close() (#229)
* Implement `Frame.close()`

* close frame in dtor

* Update JImageProxyHostObject.cpp

* fix close

* Check if closed

* remove a few logs

* r

* fix `isValid` and `isReady`

* Add JImage

* Release JNI frame ref on destroy

* fix pod setup

* Fix isValid call

* Fix `close` not returning a function

* throw error if closed twice

* iOS: Schedule `console.error` call on JS thread

* Android: Log Frame Processor Error to JS

* fix syntax

* Check if valid `toString()`

* Update Frame.ts

* Remove `isReady`

* Fix JImage accessors

* remove `JImage` C++ sources

* Throw error if accessing props on closed Frame

* Delete `JImage.h`
2021-07-06 10:08:44 +02:00
Marc Rousavy
bfb1b67c2f Update FrameProcessorRuntimeManager.cpp 2021-06-29 10:38:35 +02:00
Marc Rousavy
5ab1a72e01 chore: Fix C++ indents 2021-06-29 10:38:13 +02:00
Marc Rousavy
45fad5ab19 fix: Add more logs 2021-06-29 10:36:39 +02:00
Marc Rousavy
359fd00c73 fix: print stacktrace on error 2021-06-29 10:34:48 +02:00
Marc Rousavy
f1a5ee7ee1 fix: Log errors in update and configureSession 2021-06-29 10:18:39 +02:00
Marc Rousavy
f07f4a8770 fix: Correctly propagate Errors in configureSession() 2021-06-29 10:16:38 +02:00
Marc Rousavy
f80e606c6d fix: Report all errors to JS in configureSession 2021-06-29 10:14:33 +02:00
Marc Rousavy
da84a0fd42 perf: Avoid error message copying 2021-06-28 20:45:08 +02:00
Marc Rousavy
4bacee796a feat: Print Frame Processor errors to Metro console 2021-06-28 20:44:50 +02:00
Marc Rousavy
26d19d5152 perf: Remove a few unnecessary log statements 2021-06-28 18:30:42 +02:00
Marc Rousavy
e13bef7d17 fix: Host Object error 2021-06-28 10:19:19 +02:00
Marc Rousavy
87e6bb710e
feat: Frame Processors for Android (#196)
* Create android gradle build setup

* Fix `prefab` config

* Add `pickFirst **/*.so` to example build.gradle

* fix REA path

* cache gradle builds

* Update validate-android.yml

* Create Native Proxy

* Copy REA header

* implement ctor

* Rename CameraViewModule -> FrameProcessorRuntimeManager

* init FrameProcessorRuntimeManager

* fix name

* Update FrameProcessorRuntimeManager.h

* format

* Create AndroidErrorHandler.h

* Initialize runtime and install JSI funcs

* Update FrameProcessorRuntimeManager.cpp

* Update CameraViewModule.kt

* Make CameraView hybrid C++ class to find view & set frame processor

* Update FrameProcessorRuntimeManager.cpp

* pass function by rvalue

* pass by const &&

* extract hermes and JSC REA

* pass `FOR_HERMES`

* correctly prepare JSC and Hermes

* Update CMakeLists.txt

* add missing hermes include

* clean up imports

* Create JImageProxy.h

* pass ImageProxy to JNI as `jobject`

* try use `JImageProxy` C++ wrapper type

* Use `local_ref<JImageProxy>`

* Create `JImageProxyHostObject` for JSI interop

* debug call to frame processor

* Unset frame processor

* Fix CameraView native part not being registered

* close image

* use `jobject` instead of `JImageProxy` for now :(

* fix hermes build error

* Set enable FP callback

* fix JNI call

* Update CameraView.cpp

* Get Format

* Create plugin abstract

* Make `FrameProcessorPlugin` a hybrid object

* Register plugin CXX

* Call `registerPlugin`

* Catch

* remove JSI

* Create sample QR code plugin

* register plugins

* Fix missing JNI binding

* Add `mHybridData`

* prefix name with two underscores (`__`)

* Update CameraPage.tsx

* wrap `ImageProxy` in host object

* Use `jobject` for HO box

* Update JImageProxy.h

* reinterpret jobject

* Try using `JImageProxy` instead of `jobject`

* Update JImageProxy.h

* get bytes per row and plane count

* Update CameraView.cpp

* Return base

* add some docs and JNI JSI conversion

* indent

* Convert JSI value to JNI jobject

* using namespace facebook

* Try using class

* Use plain old Object[]

* Try convert JNI -> JSI

* fix decl

* fix bool init

* Correctly link folly

* Update CMakeLists.txt

* Convert Map to Object

* Use folly for Map and Array

* Return `alias_ref<jobject>` instead of raw `jobject`

* fix JNI <-> JSI conversion

* Update JSIJNIConversion.cpp

* Log parameters

* fix params index offset

* add more test cases

* Update FRAME_PROCESSORS_CREATE_OVERVIEW.mdx

* fix types

* Rename to example plugin

* remove support for hashmap

* Try use HashMap iterable fbjni binding

* try using JReadableArray/JReadableMap

* Fix list return values

* Update JSIJNIConversion.cpp

* Update JSIJNIConversion.cpp

* (iOS) Rename ObjC QR Code Plugin to Example Plugin

* Rename Swift plugin QR -> Example

* Update ExamplePluginSwift.swift

* Fix Map/Dictionary logging format

* Update ExampleFrameProcessorPlugin.m

* Reconfigure session if frame processor changed

* Handle use-cases via `maxUseCasesCount`

* Don't crash app on `configureSession` error

* Document "use-cases"

* Update DEVICES.mdx

* fix merge

* Make `const &`

* iOS: Automatically enable `video` if a `frameProcessor` is set

* Update CameraView.cpp

* fix docs

* Automatically fallback to snapshot capture if `supportsParallelVideoProcessing` is false.

* Fix lookup

* Update CameraView.kt

* Implement `frameProcessorFps`

* Finalize Frame Processor Plugin Hybrid

* Update CameraViewModule.kt

* Support `flash` on `takeSnapshot()`

* Update docs

* Add docs

* Update CameraPage.tsx

* Attribute NonNull

* remove unused imports

* Add Android docs for Frame Processors

* Make JNI HashMap <-> JSI Object conversion faster

directly access `toHashMap` instead of going through java

* add todo

* Always run `prepareJSC` and `prepareHermes`

* switch jsc and hermes

* Specify ndkVersion `21.4.7075529`

* Update gradle.properties

* Update gradle.properties

* Create .aar

* Correctly prepare android package

* Update package.json

* Update package.json

* remove `prefab` build feature

* split

* Add docs for registering the FP plugin

* Add step for dep

* Update CaptureButton.tsx

* Move to `reanimated-headers/`

* Exclude reanimated-headers from cpplint

* disable `build/include_order` rule

* cpplint fixes

* perf: Make `JSIJNIConversion` a `namespace` instead of `class`

* Ignore runtime/references for `convert` funcs

* Build Android .aar in CI

* Run android build script only on `prepack`

* Update package.json

* Update package.json

* Update build-android-npm-package.sh

* Move to `yarn build`

* Also install node_modules in example step

* Update validate-android.yml

* sort imports

* fix torch

* Run ImageAnalysis on `FrameProcessorThread`

* Update Errors.kt

* Add clean android script

* Upgrade reanimated to 2.3.0-alpha.1

* Revert "Upgrade reanimated to 2.3.0-alpha.1"

This reverts commit c1d3bed5e03728d0b5e335a359524ff4f56f5035.

* ⚠️ TEMP FIX: hotfix reanimated build.gradle

* Update CameraView+TakeSnapshot.kt

* ⚠️ TEMP FIX: Disable ktlint action for now

* Update clean.sh

* Set max heap size to 4g

* rebuild lockfiles

* Update Podfile.lock

* rename

* Build lib .aar before example/
2021-06-27 12:37:54 +02:00
Marc Rousavy
9ea158ad8f
chore: Move to /mrousavy/ (#224)
* rename 1/n

* 2

* 3

* fix indent
2021-06-21 22:42:46 +02:00