Skip to content

Conversation

@rickhohler
Copy link

@rickhohler rickhohler commented Jan 29, 2026

Fixes flutter/flutter#180048.

This PR adds error handling for AVAssetWriter.startWriting in camera_avfoundation. Previously, the boolean return value was ignored, which could mask initialization errors. Now, a FlutterError is returned if writing fails to start.

Pre-Review Checklist

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-assist bot 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

  1. 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

Handling the return value of startWriting to prevent silent failures and ensure errors are propagated.
Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

@stuartmorgan-g
Copy link
Collaborator

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.

Copy link

@gemini-code-assist gemini-code-assist bot left a 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.

@rickhohler
Copy link
Author

Thanks! I've confirmed the checklist is complete and applied the suggested code improvement. Marking ready for review.

@stuartmorgan-g
Copy link
Collaborator

I've confirmed the checklist is complete

As with your other PR, the version changes aren't in the PR.

@stuartmorgan-g stuartmorgan-g added the triage-ios Should be looked at in iOS triage label Jan 29, 2026
@rickhohler
Copy link
Author

Apologies for the oversight. I have bumped the version to 0.9.22+10 and added the corresponding CHANGELOG entry.

Additionally, I updated the isRecording property to private(set) to correctly facilitate testing as noted in the review.

Ready for another look!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[camera_avfoundation] Missing asset writer startWriting error handling

2 participants