-
Notifications
You must be signed in to change notification settings - Fork 27.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[camera] Permissions request are not well-awaiting on iOS #97199
Comments
I did a bisect and verified that this was introduced by flutter/plugins#4140 (v0.9.4+3). |
I did some initial investigation: Comparing with apple's AVCam sample project, looks like we are missing the logic that explicitly requests permission. The current permission alert is triggered implicitly by some of the AVFoundation calls which does not have completion callbacks (e.g. So in conclusion, I think a good solution is to explicitly request permission with a completion callback like what Apple did in the sample project. I will re-visit this after other threading works are done in #96429 |
Thanks for the clarification. Though I would suggest a fix for a higher priority since it breaks most cases with the lifecycle hook. |
Update: I recently wrapped up the thread model effort (#96429), and will be working on this permission issue now. |
Update: There are API changes that may involve other platforms. I wrote up a draft proposal. It's still in progress and there are more investigation to be done. |
The proposal looks detailed and fluent overall even it's incompleted, great work! |
Update: Just finished investigating all the platforms (iOS/Android/Web/Windows) and finalized the proposal. |
@hellohuanlin I've verified that the PR has fixed the problem with the Also, the example is still requesting twice initialization when selecting one of the controllers, I'll update the example later with a separate PR. Step to reproduce
See the screenshot which might explain the behavior: |
@AlexV525 Strange. I remember when I tried it a few months ago, the camera permission request already includes microphone, so this separate microphone request is a surprise to me. (though I might be on iOS 14 back then). |
I didn't notice this too when I was tested with the official example, it seems there are a couple of combinations with audio and video recording configurations, which might be related? |
@AlexV525 I just tried out the example project again and it did ask for microphone separately now (which was not the case previously). I think we just need to add similar request logic here, but for Let me try out your project and take a look |
It might be better if they can be requested at the same time, or I think there will be another
Thanks! Please use the PR version for further investigations, and you can suggest changes if there are any problems with the implementation. |
@AlexV525 I was able to fix your project by explicitly requesting the audio permission (similar to what I did for video permission). Will be sending a PR next week. |
All incorrect behaviors are well-addressed in 0.9.6. Thanks @hellohuanlin ! Closing. |
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of |
Related to #96429. It's a serious bug that breaks lifecycle control flow on iOS. This issue could be introduced by flutter/plugins#4140.
Steps to Reproduce
camera
plugin like the first install (uninstall first if it's installed).Details
From the screenshot, we can recognize that the
initialize
method completes before permissions requests are done. This could be affected by the thread model changing of implementations on iOS.Once the new controller has been given to the field, the lifecycle listener is triggered a bit later, which will dispose the controller in a short time, causing a race condition issue.
And after the app is resumed, the controller will initialize again.
Environment
camera: 0.9.4+6
The text was updated successfully, but these errors were encountered: