Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Conversation

@loic-sharma
Copy link
Member

@loic-sharma loic-sharma commented Jul 26, 2022

This change improves camera_windows's error handling:

  • CaptureControllerImpl's destructor no longer tries to stop recording even if recording has already stopped.
  • An error is now reported if stop record fails
  • Pause/resume/stop preview now fails properly if preview wasn't started

Part of flutter/flutter#102098

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 ///).
  • I added new tests to check the change I am making, or this PR is test-exempt.
  • All existing and new tests are passing.

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


void CaptureControllerImpl::ResetCaptureController() {
if (record_handler_) {
if (record_handler_ && record_handler_->CanStop()) {
Copy link
Member Author

@loic-sharma loic-sharma Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Previously IsContinuousRecording and IsTimedRecording could return true even if the recording has stopped. This caused the destructor to try to stop recording again even though recording was already stopped.

// process.
if (!record_handler_->StopRecord(capture_engine_.Get())) {
// Destroy record handler on error cases to make sure state is resetted.
record_handler_ = nullptr;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OnRecordStopped does nothing if record_handler_ is null, causing errors to be dropped. Also, OnRecordStopped cleans up the record handler properly.

assert(capture_engine_);

if (!IsInitialized() && !preview_handler_) {
if (!IsInitialized() || !preview_handler_) {
Copy link
Member Author

@loic-sharma loic-sharma Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was incorrect and caused a crash if you attempted to pause/resume/stop a preview that wasn't started.


enum class RecordingType {
// Camera is not recording.
kNone,
Copy link
Member Author

@loic-sharma loic-sharma Jul 26, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This new state was added so that IsContinuousRecording and IsTimedRecording returns false if the recording isn't running or stopping. Technically this could've been achieved by checking recording_state_, but, I'd rather have type_ be a sensible value if the recording is stopped or not started.

@loic-sharma loic-sharma force-pushed the camera_windows_errors branch from bde05fd to a02193b Compare July 26, 2022 23:31
@loic-sharma loic-sharma marked this pull request as draft July 27, 2022 00:27
@loic-sharma

This comment was marked as outdated.

@loic-sharma loic-sharma marked this pull request as ready for review July 27, 2022 01:18
@loic-sharma loic-sharma force-pushed the camera_windows_errors branch from 93e539b to 2b4dd7c Compare July 27, 2022 01:21
Copy link

@a-wallen a-wallen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@a-wallen a-wallen added the autosubmit Merge PR when tree becomes green via auto submit App label Jul 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App p: camera platform-windows

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants