-
Notifications
You must be signed in to change notification settings - Fork 3.6k
[camera_avfoundation] Handle startWriting errors #10921
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
base: main
Are you sure you want to change the base?
[camera_avfoundation] Handle startWriting errors #10921
Conversation
Handling the return value of startWriting to prevent silent failures and ensure errors are propagated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request correctly adds error handling for AVAssetWriter.startWriting in camera_avfoundation. Previously, the boolean return value was ignored, which could lead to silent failures during video recording initialization. The change ensures that if startWriting returns false, a FlutterError is created with details from the writer's error property and passed to the completion handler. This prevents the camera from entering an incorrect isRecording state. A new unit test is added to verify this new error handling path, and the isRecording property's access level was updated to private(set) to allow for assertions in the test.
|
Thanks for the contribution! In the future, please do not delete the checklist that is in the PR template; it is there for a reason. This PR is missing required elements described in the checklist (I’ve restored it to the PR description), which need to be addressed before it moves forward with review. I am marking the PR as a Draft. Please review the checklist, updating the PR as appropriate, and when that’s complete please feel free to mark the PR as ready for review. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces error handling for AVAssetWriter.startWriting in camera_avfoundation. Previously, the boolean return value was ignored, potentially masking initialization errors. The change correctly checks this return value and propagates a FlutterError if the operation fails. A corresponding unit test has been added to validate the new error handling logic, and the isRecording property's visibility was adjusted to private(set) to facilitate testing. The changes are well-implemented, and I have one suggestion to further improve the code's robustness.
.../camera_avfoundation/ios/camera_avfoundation/Sources/camera_avfoundation/DefaultCamera.swift
Outdated
Show resolved
Hide resolved
|
Thanks! I've confirmed the checklist is complete and applied the suggested code improvement. Marking ready for review. |
As with your other PR, the version changes aren't in the PR. |
|
Apologies for the oversight. I have bumped the version to Additionally, I updated the Ready for another look! |
Fixes flutter/flutter#180048.
This PR adds error handling for
AVAssetWriter.startWritingincamera_avfoundation. Previously, the boolean return value was ignored, which could mask initialization errors. Now, aFlutterErroris returned if writing fails to start.Pre-Review Checklist
[shared_preferences]pubspec.yamlwith an appropriate new version according to the pub versioning philosophy, or I have commented below to indicate which version change exemption this PR falls under1.CHANGELOG.mdto add a description of the change, following repository CHANGELOG style, or I have commented below to indicate which CHANGELOG exemption this PR falls under1.///).If you need help, consider asking for advice on the #hackers-new channel on Discord.
Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the
gemini-code-assistbot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.Footnotes
Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. ↩ ↩2 ↩3