Skip to content
This repository was archived by the owner on Jul 10, 2025. It is now read-only.

Bump CameraX to alpha06 - #198

Merged
aforcier merged 10 commits into
developfrom
issue-197/bump-camerax-alpha06
Nov 7, 2019
Merged

aforcier merged 10 commits into
developfrom
issue-197/bump-camerax-alpha06

Conversation

@mzorz

@mzorz mzorz commented Nov 6, 2019 •

Copy link
Copy Markdown
Contributor

Fix #197, #157

Bumps CameraX library and updates the code to cope with the breaking changes in the library, following descriptions in https://developer.android.com/jetpack/androidx/releases/camera#camera2-core-1.0.0-alpha06

  • changed UseCaseErrors to new names (437eabf)
  • set specific AsyncTask.THREAD_POOL_EXECUTOR executor for startRecording() and takePicture() (c627519)
  • null checks on currentFile added given non-nullable parameter expected on CameraX's side now (4258395)

On optimal resolution calculations

Original idea was to rollback #128 given the release notes for alpha06 of CameraX mention the following

Fixed issue where resolutions would be selected that were too small (less than 640x480) when app is requesting larger or default resolutions resulting in a blocky or blurry preview image. Applications that specifically need smaller resolutions can explicitly request them.

but, while we now don't calculate the optimal preview size based on current screen / camera resolution ourselves anymore in this PR (5ec8efe), a few tests on the recommended strategy of using the simplified setTargetAspectRatio() with the enum values AspectRatio.RATIO_4_3 and AspectRatio.RATIO_16_9 have shown artifacts (stretched preview) on a Pixel 2 so, we're considering it a work in progress on the library's side for now, and leaving the code in if we need it (a9867a3).

For now, we're using the screen's aspect ratio calculation in c736593 (as opposed to calculating the optimal target resolution) to indicate as a target hint on the configuration for preview, image capture and video capture, these are the tests results so far:

Using setTargetAspectRatio(RATIO_16_9):

  • Pixel 2 (16:9): works alright
  • J2 (16:9): video capture (and end resulting video) show stretched
  • Xiaomi Redmi Note 5 (2:1): works alright

Using screenAspectRatio = Rational(metrics.widthPixels, metrics.heightPixels)
and setTargetAspectRatioCustom(screenAspectRatio)

  • Pixel 2 (16:9): works alright
  • Samsung J2 (16:9): video capture (and end resulting video) show stretched
  • Xiaomi Redmi Note 5 (2:1): works alright

Given both have similar results, the second approach is a bit more flexible in that it doesn't hardcode 16:9 as the aspect ratio but rather tries to identify the current device's one and set it to it, which should be preferred.

As discussed previously, it doesn't seem worth it to pursue a perfect solution for all possibilities, but rather wait and keep the upcoming versions of the CameraX library updated (just to keep track of breaking changes and avoid having these pile up).

@mzorz mzorz added the CameraX applicable only to CameraX implementation label Nov 6, 2019
@peril-automattic

peril-automattic Bot commented Nov 6, 2019 •

Copy link
Copy Markdown

You can test the changes on this Pull Request by downloading the APK here.

mzorz added 4 commits November 6, 2019 14:07
…evice screen aspect ratio, given passing the enum 4:3 would make the preview stretched
…it for the VideoCapture use case configuration
@mzorz mzorz changed the title WIP - Bump CameraX to alpha06 Bump CameraX to alpha06 Nov 6, 2019
@mzorz
mzorz requested a review from aforcier November 6, 2019 19:52
@mzorz

mzorz commented Nov 6, 2019

Copy link
Copy Markdown
Contributor Author

This one should be ready for review @aforcier 🙇

@aforcier aforcier self-assigned this Nov 7, 2019
@aforcier

aforcier commented Nov 7, 2019

Copy link
Copy Markdown
Collaborator

Looks good @mzorz! Tested photo and video a Pixel 3 API29, works great. :shipit:

@aforcier

aforcier commented Nov 7, 2019

Copy link
Copy Markdown
Collaborator

Side note: I did notice some oddness on a Pixel API26 emulator where the captured video is being stretched in edit mode (static photos are fine). But I'm seeing this on develop as well so it's not caused by this branch. Does this sound familiar to you?

Screenshot_1573147308

Screenshot_1573147318

@aforcier
aforcier merged commit 59d4a8b into develop Nov 7, 2019
@aforcier
aforcier deleted the issue-197/bump-camerax-alpha06 branch November 7, 2019 17:27
@mzorz

mzorz commented Nov 7, 2019

Copy link
Copy Markdown
Contributor Author

Yeah I've seen the stretching, it's got to do with the video player, I'll open an issue for that 👍

@mzorz

mzorz commented Nov 7, 2019

Copy link
Copy Markdown
Contributor Author

Opened issue #200 - also added new label to describe the component the bug belongs to.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

CameraX applicable only to CameraX implementation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Update CameraX library

2 participants