This repository was archived by the owner on Feb 22, 2023. It is now read-only.
[camera] Fix capture hang on Android 12 devices (Pixel 6) #4922
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR fixes image capture on Android 12 devices like the Pixel 6. After an image is captured, the device is stuck in
STATE_CAPTURING
because of the calls tostopRepeating()
andabortCaptures()
right after initiating the capture.The best theory I can make is on devices like the Pixel 6 this causes the capture to never finish and the state machine is stuck in the capturing state forever because it aborted the capture before it finished. There must be a change in Android 12 that causes this to be an issue now.
One other note, these 2 calls were not present in the plugin prior to the big refactor last year I started that was later split into 9 different PRs. As part of the 9th PR, it seems @BeMacized added these calls in for some reason (did not see it documented unfortunately).
After removing these 2 calls, camera capture is working for the Pixel 6 and it still works for the Pixel 4 (Android 11).
Lines in question:
https://github.com/flutter/plugins/blame/main/packages/camera/camera/android/src/main/java/io/flutter/plugins/camera/Camera.java#L586-L587
Commit that broke it:
https://github.com/flutter/plugins/commit/0a86ac866b8b322a37d5fac36c7b15856a2b37e8#diff-97f0364e631a66ce678d82ff99[…]6c59511d7d848f8c33544eR556-R557
List which issues are fixed by this PR. You must list at least one issue.
If you had to change anything in the flutter/tests repo, include a link to the migration guide as per the breaking change policy.
Pre-launch Checklist
dart format
.)[shared_preferences]
pubspec.yaml
with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.CHANGELOG.md
to add a description of the change, following repository CHANGELOG style.///
).--> No new code to comment
--> No new behavior to test with a unit test
If you need help, consider asking for advice on the #hackers-new channel on Discord.