Skip to content

Commit

Permalink
feat: Upgrade CameraX to 1.4.0-beta02 (#2986)
Browse files Browse the repository at this point in the history
* feat: Upgrade CameraX to 1.4.0-beta02

* Remove gradle cache

* Remove build-cache

* Revert "Remove gradle cache"

This reverts commit ad8e5e3.

* feat: Add back `--build-cache`, but stop daemons

* fix: Remove Skia from `example` dir

* Don't cache `~/.gradle/wrapper`

* fix: Split fps cache key

* Revert "fix: Split fps cache key"

This reverts commit aca93db.

* fix: Split with and without FPs
  • Loading branch information
mrousavy committed Jun 13, 2024
1 parent 425228a commit 036ecc5
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
32 changes: 19 additions & 13 deletions .github/workflows/build-android.yml
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@ jobs:
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-with-fps-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-with-fps-yarn-
- name: Install node_modules
run: yarn install --frozen-lockfile
- name: Install node_modules for example/
Expand All @@ -56,12 +56,15 @@ jobs:
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
key: ${{ runner.os }}-with-fps-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
${{ runner.os }}-with-fps-gradle-
- name: Run Gradle Build for example/android/
run: cd example/android && ./gradlew assembleDebug --build-cache && cd ../..
run: cd example/android && ./gradlew assembleDebug --no-daemon --build-cache && cd ../..

# Gradle cache doesn't like daemons
- name: Stop Gradle Daemon
run: cd android && ./gradlew --stop

build-no-frame-processors:
name: Build Android Example App (without Frame Processors)
Expand All @@ -87,24 +90,27 @@ jobs:
id: yarn-cache
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }}
key: ${{ runner.os }}-without-fps-yarn-${{ hashFiles('**/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-
${{ runner.os }}-without-fps-yarn-
- name: Install node_modules
run: yarn install --frozen-lockfile
- name: Install node_modules for example/
run: yarn install --frozen-lockfile --cwd example
- name: Remove worklets, skia and reanimated
run: yarn remove react-native-worklets-core @shopify/react-native-skia react-native-reanimated --cwd ..
run: yarn remove react-native-worklets-core @shopify/react-native-skia react-native-reanimated --cwd example

- name: Restore Gradle cache
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
key: ${{ runner.os }}-without-fps-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
restore-keys: |
${{ runner.os }}-gradle-
${{ runner.os }}-without-fps-gradle-
- name: Run Gradle Build for example/android/
run: cd example/android && ./gradlew assembleDebug --build-cache && cd ../..
run: cd example/android && ./gradlew assembleDebug --no-daemon --build-cache && cd ../..

# Gradle cache doesn't like daemons
- name: Stop Gradle Daemon
run: cd android && ./gradlew --stop
2 changes: 1 addition & 1 deletion package/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ dependencies {
implementation "com.facebook.react:react-android:+"

// CameraX dependency
def camerax_version = "1.4.0-alpha04"

This comment has been minimized.

Copy link
@cksiow

cksiow Jul 26, 2024

FYI, changing to beta02 will cause the application crash due to below changing, not sure why it rethrow the exception which mostly of the time we will using thread to call and unhandled exception will occur
https://androidx.tech/artifacts/camera/camera-core/1.4.0-beta02-source/androidx/camera/core/CameraX.java.html
line 371

else if (e instanceof CameraIdListIncorrectException) { --   | String message = "Device reporting less cameras than anticipated. On real"   | + " devices: Retrying initialization might resolve temporary "   | + "camera errors. On emulators: Ensure virtual camera "   | + "configuration matches supported camera features as reported by"   | + " PackageManager#hasSystemFeature. Available cameras: "   | + ((CameraIdListIncorrectException) e).getAvailableCameraCount();   | Logger.e(TAG, message, e);   | completer.setException(new InitializationException(   | new CameraUnavailableException(CAMERA_ERROR, message)));

This comment has been minimized.

Copy link
@cksiow

cksiow Jul 26, 2024

For now temporary change back to 1.4.0-alpha04 will resolve the issue for those device without camera

def camerax_version = "1.4.0-beta02"
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
Expand Down

0 comments on commit 036ecc5

Please sign in to comment.