Thanks to visit codestin.com
Credit goes to github.com

Skip to content
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

Closed
wants to merge 1 commit into from

Conversation

acoutts
Copy link
Contributor

@acoutts acoutts commented Feb 24, 2022

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 to stopRepeating() and abortCaptures() 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

  • I read the Contributor Guide and followed the process outlined there for submitting PRs.
  • I read the Tree Hygiene wiki page, which explains my responsibilities.
  • I read and followed the relevant style guides and ran the auto-formatter. (Unlike the flutter/flutter repo, the flutter/plugins repo does use dart format.)
  • I signed the CLA.
  • The title of the PR starts with the name of the plugin surrounded by square brackets, e.g. [shared_preferences]
  • I listed at least one issue that this PR fixes in the description above.
  • I updated pubspec.yaml with an appropriate new version according to the pub versioning philosophy, or this PR is exempt from version changes.
  • I updated CHANGELOG.md to add a description of the change, following repository CHANGELOG style.
  • I updated/added relevant documentation (doc comments with ///).
    --> No new code to comment
  • I added new tests to check the change I am making, or this PR is test-exempt.
    --> No new behavior to test with a unit test
  • All existing and new tests are passing.

If you need help, consider asking for advice on the #hackers-new channel on Discord.

@acoutts
Copy link
Contributor Author

acoutts commented Feb 24, 2022

cc @mvanbeusekom

@stuartmorgan-g
Copy link
Contributor

This is a duplicate of #4572 (which is just waiting for review now)

  • I added new tests to check the change I am making, or this PR is test-exempt.
    --> No new behavior to test with a unit test

There is a behavior change: the whole point of the PR is to fix behavior. Please read the link in that bullet point for what is actually test exempt.

As part of the 9th PR, it seems @BeMacized added these calls in for some reason (did not see it documented unfortunately).

Interesting, thanks for that context. I had assumed it was in your original rewrite, but hadn't dug into your original PR.

@acoutts
Copy link
Contributor Author

acoutts commented Feb 24, 2022

I just tested #4572 on a pixel 6 and the image capture is still not working. While 4572 might fix another similar issue, it does not resolve the one I'm referring to here (and what flutter/flutter#92973 is referring to).

Can you please re-open the PR for review? I feel like we need to get @BeMacized's input as well to clarify why this was added in the first place, and why it didn't require explicit testing at that time.

I will also take a look at writing a test, using #4572 as inspiration.

Edit:
I had not checked out the correct branch. Indeed, #4572 fixes it, sorry to confuse with my reply.

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

Successfully merging this pull request may close these issues.

2 participants