-
Notifications
You must be signed in to change notification settings - Fork 9.8k
[camera] Fix all capture timeout, autofocus, flash, exposure, and device crash issues #3651
Conversation
…view texture to capture request
I've connected this branch to our project and played with it a little. Looks promising, can't wait to see this in main repo. Unfortunately, for now I'll have to make a fork of this fork :) There are several problems described in this comment. Although we don't use front camera and don't record video, so most of them are not critical for us. Still, we do observe major freezing when flash is enabled. Also, our app freezes forever when we call So, I guess, because of all the separating-in-multiple-PRs work for now I'll have to fork this branch and do some workarounds myself if you don't mind. |
This solved my problems on the Teracube 2e phone (Android 10). |
@IanDarwin had the same problem. Turned out that was because we used another library to check if flash is available, that was likely implemented via Camera 1 API internally. Everything worked well on newer devices, but Android 5 devices often doesn't support Camera 2 API used in this library and switch to legacy mode, so we got an error about camera being locked by lower API. Works fine after removing that library usages. |
Thanks @Bringoff but not using any other camera-related APIs. |
If someone else is looking to use this right now before it's merged, use this in your pubspec:
Just be warned, this is really BLEEDING EDGE and uses a branch that is being worked on and may break at any time as far as I'm aware! (unless @acoutts or someone that worked on this confirms it is fine to use) |
I've been using this for a while (during testing of a new build) but intermittently getting crashes when taking photos on Android .. Haven't noticed if the same on iOS. I'll try and get a proper crash report added but not sure if it's relevant to this issue. |
Conflict @acoutts |
The conflict is with the first of the incremental patches that are being extracted; there's not a lot of point in resolving them until all five have landed. |
All (the pull request submitter and all commit authors) CLAs are signed, but one or more commits were authored or co-authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that by leaving a comment that contains only Note to project maintainer: There may be cases where the author cannot leave a comment, or the comment is not properly detected as consent. In those cases, you can manually confirm consent of the commit author(s), and set the ℹ️ Googlers: Go here for more info. |
) Adds exposure related features containing the implementation to handle auto exposure, exposure lock, exposure offset and exposure point via the Android Camera2 API. This is the third PR in a series of pull-requests which will gradually introduce changes from PR #3651, making it easier to review the code (as discussed with @stuartmorgan).
Any news on this? I'm desperate to release an update for an app but cannot use the current compatible versions or this PR because I'm still getting crashes that just say |
Individual pieces continue to be extracted, reviewed, and landed.
If you have a crash even when using this PR then this isn't going to be relevant to your use case; you should file an issue with details. |
Closing this, as the final changes from this PR have finally been merged with #4059. Many thanks to those who worked on this! |
…utter#3797) Adds exposure related features containing the implementation to handle auto exposure, exposure lock, exposure offset and exposure point via the Android Camera2 API. This is the third PR in a series of pull-requests which will gradually introduce changes from PR flutter#3651, making it easier to review the code (as discussed with @stuartmorgan).
This PR is a full rework of the android plugin. There were a number of issues before, including crashes on some legacy devices and some features just didn't work. I found that the camera API wasn't quite implemented correctly, and it wasn't transitioning between the states / modes as it should have. This led to instabilities on some devices.
I've tested this PR on the following devices and every feature in the plugin now works as expected:
Summary of major changes / improvements:
NV21
image streams in Android for more efficient use with Firebase ML Vision- no need to concatenate the YUV420 planes anymore, just feed the one plane from NV21 directly to ML Vision.PictureCaptureRequest
, we now have a newCameraState
as well as thePictureCaptureRequestState
. ThePictureCaptureRequestState
handles timing out captures while theCameraState
tracks the state of the camera as it's processing the current request. This made it easier to keep track of how the camera is moving between states during capture.Testing this PR
In order to use this PR before the update to
camera
andcamera_platform_interface
are published, you need to include the following in yourpubspec.yaml
:Future improvements
There is still a delay when capturing images on some devices. I believe it's because we are blocking the UI thread and freezing flutter, so the image preview freezes. I think what we can do to improve this is when calling take picture from android, we need to return a completer future so we can immediately call the result function to unblock flutter, and then once the image is processed we can complete it to return the image path back to dart.
The same could be applied to starting/stopping video capture too.
Related issues:
setFocusMode()
on iOS front-facing camera crashes app: [AVCaptureDevice setFocusMode:] Unsupported focusMode - use -isFocusModeSupported: to discover valid focus modes flutter#76498Pre-launch Checklist
[shared_preferences]
///
).If you need help, consider asking for advice on the #hackers-new channel on Discord.