Commit Graph

123 Commits

Author SHA1 Message Date
Marc Rousavy
0904767cf2
fix: Log Stacktrace on Frame Processor Error (#731)
* fix: Log JS Stack on Error

* Android

* Format Stacktrace better

* Update FrameProcessorUtils.mm

* Allow unapproved C++11 headers

* Use `.c_str()`
2022-01-10 16:37:47 +01:00
Marc Rousavy
48da1819fc
feat: Custom Orientation (#715)
* feat: Custom Orientation

* Update CameraView.swift

* Update CameraView.swift

* Try outputRotation approach

* whoops

* fix: Refactor `VideoCapture` instance

* Update orientation in didSetProps

* Update Orientation in iOS

* expose to objc

* Fix Orientation values

* format
2022-01-04 16:57:40 +01:00
Marc Rousavy
adb2115d3b Update build.gradle 2022-01-04 08:49:46 +01:00
Marc Rousavy
675dec5ab3
fix: Resolve node_modules/ better (#706)
* fix: Use `rootDir` instead of `projectDir`

* Revert "fix: Use `rootDir` instead of `projectDir`"

This reverts commit 058e0a110bcf9b688e12a1cccbac2f23a29fa55c.

* fix: Find node_modules path where react-native/ lives

* fix: Figure out VisionCameraExample project

* Revert "fix: Figure out VisionCameraExample project"

This reverts commit 7ca455098244dd62280d40586062803d1ccc2c5f.
2022-01-03 13:18:38 +01:00
Marc Rousavy
1c09ded57e chore: Log target JSI Runtime 2022-01-03 13:06:21 +01:00
Marc Rousavy
d2dbcdd09d
feat: Monorepo support (#704)
* fix: Find node_modules dynamically

* Update build.gradle

* Update build.gradle

* fix: Remove `findNodeModulePath` function
2022-01-03 12:23:19 +01:00
Marc Rousavy
fc4ed60f7c
fix: Fix REA detection to build Frame Processors (#703)
* fix: Fix REA detection

* fix: Detect REA v2 only

* cleanup logic

* Log whether Frame Processors are enabled or disabled

* Log warn instead of info

* use plugin.js to check

* log more precisely

* try ctor

* Revert "try ctor"

This reverts commit bb6110a119428451389d75896234a9935c48d75b.

* fix: Fix log order

* fix: Fix dumb boolean conversion. ffs.

* Update build.gradle

* fix: Remove `VisionCamera_disableFrameProcessors=false` flag
2022-01-03 11:54:32 +01:00
Marc Rousavy
1d27f6a06b fix: Fix crash after Activity is destroyed
Fixes #664
2022-01-03 09:30:40 +01:00
Marc Rousavy
be5ec69b02
feat: Make Reanimated optional (disable Frame Processors if REA v2 is not installed) (#412)
* Fix building iOS without Reanimated

* Conditionally compile Frame Processors (gradle)

* Conditionally use externalNativeBuild

* Remove Reanimated import

* fix: Conditionally load REA/VisionCamera libraries

* fix: Add disable FP to docs

* fix: Fix dummy placeholder for Scheduler.mm

* fix: Fix dummy `Scheduler` declaration

* fix: Only init `CameraView` C++ side if frame processors are enabled

* fix: Install JSI Bindings on Frame Processor Manager ctor

* fix: Wrong conditional

* whoops
2022-01-02 17:35:26 +01:00
Marc Rousavy
77e065d961
fix: Fix Android build on React Native 0.65 and older (#694)
* fix: Fix Android build on React Native 0.65 and older

* fix: Add excludes

* fix: Ignore META-INF from package

* fix: Wrong var name
2022-01-02 16:25:43 +01:00
Janic Duplessis
dcbbae5fc7
fix: Re-install Frame Processor JSI Bindings after Reload (#691) 2022-01-02 16:02:17 +01:00
Janic Duplessis
4584d33921
fix: Fix JNI crash in FrameHostObject dtor (#689) 2022-01-02 15:57:15 +01:00
Marc Rousavy
68707322fe
feat: Use new CameraX Recorder API (Upgrade CameraX to alpha12/32) (#543)
* chore(deps): Upgrade CameraX to alpha10/30

* chore(deps): Add first stable CameraX Video library

* feat: Use new CameraX Video API

* chore(deps): Upgrade CameraX from 10 -> 12

* fix: Replace deprecated APIs

* Update CameraViewModule.kt

* fix: Fix file creation
2021-12-30 11:39:17 +01:00
Janic Duplessis
04576db975
fix: Fix extract tasks being added to clean tasks (#644) 2021-12-13 09:32:10 +01:00
Marc Rousavy
1249cde337 fix: Fix gradle build with wrong task-name and order 2021-12-10 09:53:12 +01:00
Thomas Coldwell
c3039c94c6
feat: Add pixelFormat field (#559)
* Add `mediaSubType` field to device formats

* Create FourCharCode `toString` extension

* Move pixelFormat -> `AVCaptureDevice.Format+toDictionary`

* `mediaSubType` -> `pixelFormat` + non-optional

* ts pixelFormat `string` -> specific formats

* Add default pixelFormat value of `420v` on Android

Co-authored-by: tcoldwell72 <31568400+tcoldwell72@users.noreply.github.com>
2021-12-10 09:44:30 +01:00
Marc Rousavy
6025367c72
fix: Fix duplicate JHashMap definition by moving to custom namespace (#610)
Technically `JHashMap` is duplicated now, but in separate namespaces. If I were to remove my `JHashMap` (and `JArrayList`) definitions, the user is forced to use fbjni v3.
2021-11-23 15:48:07 +01:00
Marc Rousavy
c007a08040 fix: Fix ProGuard stripping away FrameProcessorPlugin 2021-10-14 12:47:28 +02:00
Marc Rousavy
c47639d86a fix: Fix possible null-pointer error in convertJNIObjectToJSIValue 2021-10-14 12:46:42 +02:00
Marc Rousavy
4a73cb96c1
fix: Fix view-not-found race condition in C++ code (#511)
* Add custom `onViewReady` event to get layout

`componentDidMount` is async, so the native view _might_ not exist yet causing a race condition in the `setFrameProcessor` code.

This PR fixes this by calling `setFrameProcessor` only after the native view has actually mounted, and to ensure that I created a custom event that fires at that point.

* Update CameraView.swift
2021-10-11 18:27:23 +02:00
Marc Rousavy
8d24e344c9
chore: Upgrade CameraX to alpha09 (#472)
* chore: Upgrade CameraX to alpha09

* Remove custom ProGuard file

It's no longer needed, CameraX now ships one.

* Set `targetSdkVersion` to `31`

* set `compileSdkVersion` to 31

* Add `android:exported=false`
2021-10-07 12:20:21 +02:00
Marc Rousavy
fc43b1bb7c
fix: Avoid duplicate C++ symbols by using libjsi.so shared library (#494)
* fix: Avoid duplicate C++ symbols by using `libjsi.so` shared library

* exclude `libfbjni` and `libjsi` from packaging options
2021-10-07 11:16:19 +02:00
Marc Rousavy
f029e731b2
fix: Exclude libfbjni.so 2021-10-07 10:28:50 +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
42e791b4bd
perf: Remove FrameProcessorPlugin HybridClass (#467)
* Rename `JImageProxyHostObject` -> `FrameHostObject`

* `FrameProcessorPlugin` -> `JFrameProcessorPlugin` 1/2

* `FrameProcessorPlugin` -> `JFrameProcessorPlugin` 2/2

* Make `const`

* Make `getName()` instance based

* Update JFrameProcessorPlugin.h

* Update JImageProxy.h

* `T`

* T

* Remove default ctor

* Use `TSelf` again

* Return `local_ref<CameraView*>` instead of `CameraView*`

* Make `findCameraViewById` return a raw pointer again...

* Extract `setFrameProcessor` and `unsetFrameProcessor`

* Use `global_ref`

* Use `static_cast` for `FrameHostObject`

* Update FrameProcessorRuntimeManager.cpp

* Fix reference lint error

* linelength

* Fix `unsetFrameProcessor` call
2021-09-29 12:30:50 +02:00
Marc Rousavy
8f65427391
fix: Fix ExtensionsManager abstract method crash by adding ProGuard rule (#466) 2021-09-29 10:38:49 +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
Andrés Guerrero
98f58367d3
fix: Correctly set video size/aspect ratio for Image Analysis (Frame Processor) (#453) 2021-09-24 12:01:45 +02:00
Marc Rousavy
99fff446e5
fix: Fix calling multiple Plugins in a single Frame Processor (#435)
* fix: Fix JNI <-> JSI conversion for Integers

* Create another plugin and call them both serially

* Use inline formatter for `__android_log_write`

* Update FrameProcessorRuntimeManager.cpp

* Log plugin class type

* Use `pluginGlobal->cthis()`

* Log class name

* fix dumb error

* C++: Dynamically get JNI `javaPart_` class & method

* clean up PR
2021-09-24 10:19:30 +02:00
Marc Rousavy
be3312e47d
chore: Upgrade kotlinx-coroutines 1.5.0 -> 1.5.2 (#450)
* chore: Upgrade kotlinx-coroutines 1.5.0 -> 1.5.2

* Upgrade `kotlinVersion` to 1.5.30
2021-09-23 14:22:11 +02:00
Marc Rousavy
83524c0541
fix: Fix Android Stabilization Modes (#449) 2021-09-23 14:02:46 +02:00
Marc Rousavy
c3cf75eb5f fix: Fix JNI <-> JSI conversion for Integers 2021-09-15 10:14:52 +02:00
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