Skip to content

Commit 02a0371

Browse files
authored
feat: ✨ V3 ✨ (#1466)
See #1376 ## Breaking Changes * Frame Processors are now **synchronous**. Previously they ran on a separate Thread. If you want to run something on a separate Thread now, use `runAsync` inside a Frame Processor * Frame Processor Plugins are no longer in the global object with the `__` prefix, but rather stored directly in the `FrameProcessorPlugins` object exported by react-native-vision-camera. (e.g. replace `__scanQRCodes(frame)` with `FrameProcessorPlugins.scanQRCodes(frame)`) * `frameProcessorFps` no longer exists. Use `runAtTargetFps` inside a Frame Processor to throttle some calls. * `onFrameProcessorPerformanceSuggestionAvailable` no longer exists. Use the FPS display (`enableFpsGraph={true}`) to see how your Frame Processor performs over time. This is more in-line with how React Native works (Dev Tools / Perf Monitor) * VisionCamera V3 will not work on RN 0.70 or below. You need to use RN 0.71. This is because the build script got way simpler and smaller, making it faster to build and way less error prone. Backwards compatibility is just too complex here. * Reanimated is no longer used as a Worklet Runtime. Instead, VisionCamera now uses [react-native-worklets-core](https://github.com/margelo/react-native-worklets-core). ## Progress You can test the latest V3 release by creating a new RN project with RN 0.71 and installing VisionCamera + RNWorklets: ```sh yarn add [email protected] yarn add react-native-worklets-core yarn add @shopify/react-native-skia ``` Things to test: * TensorFlow Lite plugin to load any `.tflite` model!! ✨ (see [this PR for more info](#1633), will be a separate library soon) * Drawing onto a Frame using Skia!! 🎉 * Using `frame.toArrayBuffer()` to get the Frame's byte content in JS * New Android build script. This should drastically speed up the build time! 💨 * New Worklet library. This replaces Reanimated Worklets. Should be faster and more stable :) * New synchronous Frame Processors. Should be faster :) * `runAtTargetFps` and `runAsync` in Frame Processors * Using HostObjects or HostFunctions (like models from PyTorch) inside a Frame Processor. This will probably require a few native bindings on PyTorch's end to make the integration work (cc @raedle) Overall V3 is close to completion. I have a few things to do the coming days so not sure how much work I can put into this. **If anyone wants to support the development of v3, I'd appreciate donations / sponsors: https://github.com/sponsors/mrousavy** ❤️ :) ## Related issues features - resolves #1376 - fixes #281 - resolves #211 - resolves #130 - resolves #117 - fixes #76 - resolves #75 - resolves #562 - resolves #565 - fixes #570 - fixes #287 - resolves #311 - fixes #315 - resolves #323 - fixes #340 - fixes #354 - resolves #420 - fixes #434 - fixes #452 - fixes #496 - fixes #497 - resolves #499 - fixes #516 - fixes #527 - fixes #542 - fixes #548 - fixes #561 - fixes #740 - fixes #770 ...and then pretty much every Android issue lol - fixes #1675 (**maybe**, please test @PrernaBudhraja) - fixes #1671 .. maybe also (not tested): - fixes #1698 - fixes #1687 - fixes #1685 - fixes #1681 - fixes #1650 - fixes #1646 - fixes #1635 - fixes #1631 - fixes #1621 - fixes #1615 - fixes #1612 - fixes #1605 - fixes #1599 - fixes #1585 - fixes #1581 - fixes #1569 - fixes #1568 - fixes #1565 - fixes #1561 - fixes #1558 - fixes #1554 - fixes #1551 - fixes #1547 - fixes #1543 - fixes #1538 - fixes #1536 - fixes #1534 - fixes #1528 - fixes #1520 - fixes #1498 - fixes #1489 - fixes #1477 - fixes #1474 - fixes #1463 - fixes #1462 - fixes #1449 - fixes #1443 - fixes #1437 - fixes #1431 - fixes #1429 - fixes #1427 - fixes #1423 - fixes #1416 - fixes #1407 - fixes #1403 - fixes #1402 - fixes #1398 - fixes #1396 - fixes #1395 - fixes #1379 - fixes #1377 - fixes #1374 - fixes #1373 - fixes #1365 - fixes #1356 - fixes #1353 - fixes #1352 - fixes #1351 - fixes #1343 - fixes #1340 - fixes #1334 - fixes #1330 - fixes #1322 - fixes #1296 - fixes #1283 - fixes #1260 - fixes #1253 - fixes #1251 - fixes #1245 - fixes #1238 - fixes #1227 - fixes #1226 - fixes #1225 - fixes #1222 - fixes #1211 - fixes #1208 - fixes #1193 - fixes #1191 - fixes #1184 - fixes #1164 - fixes #1143 - fixes #1128 - fixes #1122 - fixes #1120 - fixes #1110 - fixes #1097 - fixes #1081 - fixes #1080 - fixes #1064 - fixes #1053 - fixes #1047 - fixes #1044 - fixes #1032 - fixes #1026 - fixes #1023 - fixes #1015 - fixes #1012 - fixes #997 - fixes #960 - fixes #959 - fixes #954 - fixes #946 - fixes #945 - fixes #922 - fixes #908 - fixes #907 - fixes #868 - fixes #855 - fixes #834 - fixes #793 - fixes #779 - fixes #746 - fixes #740 - fixes #727 - fixes #671 - fixes #613 - fixes #595 - fixes #588 - fixes #570 - fixes #569 - fixes #542 - fixes #516 - fixes #515 - fixes #434 - fixes #354 - fixes #323 - fixes #315 - fixes #281 - fixes #211 - fixes #76
2 parents c62b5de + 74b5898 commit 02a0371

File tree

466 files changed

+29070
-22651
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

466 files changed

+29070
-22651
lines changed

.github/ISSUE_TEMPLATE/BUG_REPORT.yml

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,26 @@ labels: [🐛 bug]
55
body:
66
- type: textarea
77
attributes:
8-
label: What were you trying to do?
9-
description: Explain what you are trying to do.
10-
placeholder: I wanted to take a picture.
8+
label: What's happening?
9+
description: Explain what you are trying to do and what happened instead. Be as precise as possible, I can't help you if I don't understand your issue.
10+
placeholder: I wanted to take a picture, but the method failed with this error "[capture/photo-not-enabled] Failed to take photo, photo is not enabled!"
1111
validations:
1212
required: true
1313
- type: textarea
1414
attributes:
1515
label: Reproduceable Code
1616
description: Share a small reproduceable code snippet here (or the entire file if necessary). This will be automatically formatted into code, so no need for backticks.
1717
render: tsx
18-
- type: textarea
19-
attributes:
20-
label: What happened instead?
21-
description: Explain what happened instead of the desired outcome. Did something crash?
22-
placeholder: The app crashes with an `InvalidPhotoCodec` error.
23-
validations:
24-
required: true
2518
- type: textarea
2619
attributes:
2720
label: Relevant log output
2821
description: Please copy and paste any relevant log output (Xcode Logs/Android Studio Logcat). This will be automatically formatted into code, so no need for backticks.
2922
render: shell
23+
- type: textarea
24+
attributes:
25+
label: Camera Device
26+
description: Please paste the JSON Camera `device` that was used here. (`console.log(JSON.stringify(device, null, 2))`) This will be automatically formatted into code, so no need for backticks.
27+
render: shell
3028
- type: input
3129
attributes:
3230
label: Device
@@ -38,15 +36,22 @@ body:
3836
attributes:
3937
label: VisionCamera Version
4038
description: Which version of react-native-vision-camera are you using?
41-
placeholder: ex. 2.0.1-beta.1
39+
placeholder: ex. 3.1.6
4240
validations:
4341
required: true
42+
- type: checkboxes
43+
attributes:
44+
label: Can you reproduce this issue in the VisionCamera Example app?
45+
description: Run the example app (`package/example/`) and see if the issue is reproduceable here.
46+
options:
47+
- label: I can reproduce the issue in the VisionCamera Example app.
4448
- type: checkboxes
4549
attributes:
4650
label: Additional information
4751
description: Please check all the boxes that apply
4852
options:
4953
- label: I am using Expo
54+
- label: I have enabled Frame Processors (react-native-worklets-core)
5055
- label: I have read the [Troubleshooting Guide](https://react-native-vision-camera.com/docs/guides/troubleshooting)
5156
required: true
5257
- label: I agree to follow this project's [Code of Conduct](https://github.com/mrousavy/react-native-vision-camera/blob/main/CODE_OF_CONDUCT.md)
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: 🔧 Build Error
2+
description: File a build error bug report
3+
title: "🔧 "
4+
labels: [🔧 build error]
5+
body:
6+
- type: textarea
7+
attributes:
8+
label: How were you trying to build the app?
9+
description: Explain how you tried to build the app, through Xcode, `yarn ios`, a CI, or other. Be as precise as possible, I can't help you if I don't understand your issue.
10+
placeholder: I tried to build my app with react-native-vision-camera using the `yarn ios` command, and it failed.
11+
validations:
12+
required: true
13+
- type: textarea
14+
attributes:
15+
label: Full build logs
16+
description: Share the full build logs that appear in the console. Make sure you don't just paste the last few lines here, but rather everything from start to end.
17+
render: tsx
18+
- type: textarea
19+
attributes:
20+
label: Project dependencies
21+
description: Share all of your project's dependencies including their versions from `package.json`. This is useful if there are any other conflicting libraries.
22+
render: tsx
23+
validations:
24+
required: true
25+
- type: dropdown
26+
attributes:
27+
label: Target platforms
28+
description: Select the platforms where the build error occurs.
29+
multiple: true
30+
options:
31+
- iOS
32+
- Android
33+
validations:
34+
required: true
35+
- type: dropdown
36+
attributes:
37+
label: Operating system
38+
description: Select your operating system that you are trying to build on.
39+
multiple: true
40+
options:
41+
- MacOS
42+
- Windows
43+
- Linux
44+
validations:
45+
required: true
46+
- type: checkboxes
47+
attributes:
48+
label: Can you build the VisionCamera Example app?
49+
description: Try to build the example app (`package/example/`) and see if the issue is reproduceable here.
50+
options:
51+
- label: I can build the VisionCamera Example app.
52+
- type: checkboxes
53+
attributes:
54+
label: Additional information
55+
description: Please check all the boxes that apply
56+
options:
57+
- label: I am using Expo
58+
- label: I have enabled Frame Processors (react-native-worklets-core)
59+
- label: I have read the [Troubleshooting Guide](https://react-native-vision-camera.com/docs/guides/troubleshooting)
60+
required: true
61+
- label: I agree to follow this project's [Code of Conduct](https://github.com/mrousavy/react-native-vision-camera/blob/main/CODE_OF_CONDUCT.md)
62+
required: true
63+
- label: I searched for [similar issues in this repository](https://github.com/mrousavy/react-native-vision-camera/issues) and found none.
64+
required: true

.github/workflows/build-android.yml

Lines changed: 52 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,34 @@ on:
66
- main
77
paths:
88
- '.github/workflows/build-android.yml'
9+
- 'cpp/**'
910
- 'android/**'
1011
- 'example/android/**'
1112
- 'yarn.lock'
1213
- 'example/yarn.lock'
1314
pull_request:
1415
paths:
1516
- '.github/workflows/build-android.yml'
17+
- 'cpp/**'
1618
- 'android/**'
1719
- 'example/android/**'
1820
- 'yarn.lock'
1921
- 'example/yarn.lock'
2022

2123
jobs:
22-
build_example:
24+
build:
2325
name: Build Android Example App
2426
runs-on: ubuntu-latest
27+
defaults:
28+
run:
29+
working-directory: ./package
2530
steps:
2631
- uses: actions/checkout@v2
2732

28-
- name: Setup JDK 1.8
33+
- name: Setup JDK 11
2934
uses: actions/setup-java@v1
3035
with:
31-
java-version: 1.8
36+
java-version: 11
3237

3338
- name: Get yarn cache directory path
3439
id: yarn-cache-dir-path
@@ -55,7 +60,49 @@ jobs:
5560
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
5661
restore-keys: |
5762
${{ runner.os }}-gradle-
58-
- name: Run Gradle Build for android/
59-
run: cd android && ./gradlew assembleDebug --build-cache && cd ..
63+
- name: Run Gradle Build for example/android/
64+
run: cd example/android && ./gradlew assembleDebug --build-cache && cd ../..
65+
66+
build-no-frame-processors:
67+
name: Build Android Example App (without Frame Processors)
68+
runs-on: ubuntu-latest
69+
defaults:
70+
run:
71+
working-directory: ./package
72+
steps:
73+
- uses: actions/checkout@v2
74+
75+
- name: Setup JDK 11
76+
uses: actions/setup-java@v1
77+
with:
78+
java-version: 11
79+
80+
- name: Get yarn cache directory path
81+
id: yarn-cache-dir-path
82+
run: echo "::set-output name=dir::$(yarn cache dir)"
83+
- name: Restore node_modules from cache
84+
uses: actions/cache@v2
85+
id: yarn-cache
86+
with:
87+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
88+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
89+
restore-keys: |
90+
${{ runner.os }}-yarn-
91+
- name: Install node_modules
92+
run: yarn install --frozen-lockfile
93+
- name: Install node_modules for example/
94+
run: yarn install --frozen-lockfile --cwd example
95+
- name: Remove react-native-worklets-core
96+
run: yarn remove react-native-worklets-core --cwd example
97+
98+
- name: Restore Gradle cache
99+
uses: actions/cache@v2
100+
with:
101+
path: |
102+
~/.gradle/caches
103+
~/.gradle/wrapper
104+
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
105+
restore-keys: |
106+
${{ runner.os }}-gradle-
60107
- name: Run Gradle Build for example/android/
61108
run: cd example/android && ./gradlew assembleDebug --build-cache && cd ../..

.github/workflows/build-ios.yml

Lines changed: 66 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,14 @@ on:
66
- main
77
paths:
88
- '.github/workflows/build-ios.yml'
9+
- 'cpp/**'
910
- 'ios/**'
1011
- '*.podspec'
1112
- 'example/ios/**'
1213
pull_request:
1314
paths:
1415
- '.github/workflows/build-ios.yml'
16+
- 'cpp/**'
1517
- 'ios/**'
1618
- '*.podspec'
1719
- 'example/ios/**'
@@ -22,7 +24,7 @@ jobs:
2224
runs-on: macOS-latest
2325
defaults:
2426
run:
25-
working-directory: example/ios
27+
working-directory: package/example/ios
2628
steps:
2729
- uses: actions/checkout@v2
2830

@@ -47,9 +49,8 @@ jobs:
4749
- name: Setup Ruby (bundle)
4850
uses: ruby/setup-ruby@v1
4951
with:
50-
ruby-version: 2.6
52+
ruby-version: 2.6.10
5153
bundler-cache: true
52-
working-directory: example/ios
5354

5455
- name: Restore Pods cache
5556
uses: actions/cache@v2
@@ -62,7 +63,68 @@ jobs:
6263
restore-keys: |
6364
${{ runner.os }}-pods-
6465
- name: Install Pods
65-
run: bundle exec pod check || bundle exec pod install
66+
run: pod install
67+
- name: Install xcpretty
68+
run: gem install xcpretty
69+
- name: Build App
70+
run: "set -o pipefail && xcodebuild \
71+
CC=clang CPLUSPLUS=clang++ LD=clang LDPLUSPLUS=clang++ \
72+
-derivedDataPath build -UseModernBuildSystem=YES \
73+
-workspace VisionCameraExample.xcworkspace \
74+
-scheme VisionCameraExample \
75+
-sdk iphonesimulator \
76+
-configuration Debug \
77+
-destination 'platform=iOS Simulator,name=iPhone 11 Pro' \
78+
build \
79+
CODE_SIGNING_ALLOWED=NO | xcpretty"
80+
81+
build-no-frame-processors:
82+
name: Build iOS Example App without Frame Processors
83+
runs-on: macOS-latest
84+
defaults:
85+
run:
86+
working-directory: package/example/ios
87+
steps:
88+
- uses: actions/checkout@v2
89+
90+
- name: Get yarn cache directory path
91+
id: yarn-cache-dir-path
92+
run: echo "::set-output name=dir::$(yarn cache dir)"
93+
- name: Restore node_modules from cache
94+
uses: actions/cache@v2
95+
id: yarn-cache
96+
with:
97+
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
98+
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
99+
restore-keys: |
100+
${{ runner.os }}-yarn-
101+
- name: Install node_modules for example/
102+
run: yarn install --frozen-lockfile --cwd ..
103+
- name: Remove react-native-worklets-core
104+
run: yarn remove react-native-worklets-core --cwd ..
105+
106+
- name: Restore buildcache
107+
uses: mikehardy/buildcache-action@v1
108+
continue-on-error: true
109+
110+
- name: Setup Ruby (bundle)
111+
uses: ruby/setup-ruby@v1
112+
with:
113+
ruby-version: 2.6.10
114+
bundler-cache: true
115+
116+
- name: Restore Pods cache
117+
uses: actions/cache@v2
118+
with:
119+
path: |
120+
example/ios/Pods
121+
~/Library/Caches/CocoaPods
122+
~/.cocoapods
123+
key: ${{ runner.os }}-pods-${{ hashFiles('**/Podfile.lock') }}
124+
restore-keys: |
125+
${{ runner.os }}-pods-
126+
- name: Install Pods
127+
run: pod install
66128
- name: Install xcpretty
67129
run: gem install xcpretty
68130
- name: Build App

.github/workflows/notice-yarn-changes.yml

Lines changed: 0 additions & 19 deletions
This file was deleted.

.github/workflows/validate-android.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,13 @@ jobs:
2020
runs-on: ubuntu-latest
2121
defaults:
2222
run:
23-
working-directory: ./android
23+
working-directory: ./package/android
2424
steps:
2525
- uses: actions/checkout@v2
26-
- name: Setup JDK 1.8
26+
- name: Setup JDK 11
2727
uses: actions/setup-java@v1
2828
with:
29-
java-version: 1.8
29+
java-version: 11
3030

3131
- name: Get yarn cache directory path
3232
id: yarn-cache-dir-path

0 commit comments

Comments
 (0)