Skip to content

[camera_windows] Fall back to a physical stream for cameras that reject preferred-stream selectors - #12748

Merged
auto-submit[bot] merged 4 commits into
flutter:mainfrom
llfbandit:camera_discovery
Oct 21, 2026
Merged

auto-submit[bot] merged 4 commits into
flutter:mainfrom
llfbandit:camera_discovery

Conversation

@llfbandit

Copy link
Copy Markdown
Contributor

Fixes #140014

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

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

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 updates the Windows camera implementation to resolve and use explicit source stream indices for preview, record, and photo capture, falling back to physical streams when preferred-stream selectors are rejected. This change addresses initialization failures on multi-stream USB cameras. The review feedback suggests modifying the stream resolution logic to prefer the first encountered video capture stream rather than the last.

@Piinks Piinks added the triage-windows Should be looked at in Windows triage label Sep 8, 2026
@Piinks
Piinks requested a review from a team September 8, 2026 22:05
@mattkae

mattkae commented Oct 8, 2026

Copy link
Copy Markdown
Contributor

@llfbandit Would you be able to rebase on main?

@mattkae mattkae left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

A few thoughts!

Comment on lines +680 to +683
capture_controller = nullptr;
engine = nullptr;
camera = nullptr;
texture_registrar = nullptr;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is any of this necessary? A unique_ptr will clean itself up when the scope exits

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Manual cleanup has been removed with test split.

texture_registrar = nullptr;
}

TEST(CaptureController, StartPreviewFallsBackToPhysicalStreamWhenSelectorRejected) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Could we write distinct tests that check each fallback to default path and the ultimate selection path here?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done, split into 8 tests with shared helper to keep them short as possible.

@mattkae mattkae added the CICD Run CI/CD label Oct 9, 2026

@mattkae mattkae left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Good by me!

@mattkae mattkae added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 9, 2026
@auto-submit auto-submit Bot removed the autosubmit Merge PR when tree becomes green via auto submit App label Oct 9, 2026
@auto-submit

auto-submit Bot commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

autosubmit label was removed for flutter/packages/12748, because This PR has not met approval requirements for merging. The PR author is not a member of flutter-hackers and needs 1 more review(s) in order to merge this PR.

  • Merge guidelines: A PR needs at least one approved review if the author is already part of flutter-hackers or two member reviews if the author is not a member of flutter-hackers before re-applying the autosubmit label. Reviewers: If you left a comment approving, please use the "approve" review action instead.

@Piinks
Piinks requested review from a team and loic-sharma October 20, 2026 20:52

@loic-sharma loic-sharma left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for the contribution!

@loic-sharma loic-sharma added the autosubmit Merge PR when tree becomes green via auto submit App label Oct 21, 2026
@auto-submit
auto-submit Bot merged commit 18f9c64 into flutter:main Oct 21, 2026
14 checks passed
@llfbandit
llfbandit deleted the camera_discovery branch October 22, 2026 00:11
GhagSagar23 pushed a commit to Kryonex-Labs/flutter that referenced this pull request Oct 22, 2026
flutter/packages@1383427...93baed9

2026-10-22 [email protected] [material_ui] Port flutter/flutter
flutter#186777 MaterialColor test (flutter/packages#12858)
2026-10-21 [email protected] [rfw] Migrate to material_ui
(flutter/packages#12811)
2026-10-21 [email protected] [cupertino_ui] Fix the installing
command of the cupertino_ui package (flutter/packages#13141)
2026-10-21 [email protected]
[cupertino_ui] Unskip web tests that pass on CanvasKit and Skwasm:
date_picker_test, spell_check_suggestions_toolbar_test
(flutter/packages#13367)
2026-10-21 [email protected] [video_player] Convert player classes
to Swift (flutter/packages#13197)
2026-10-21 [email protected] [camera_windows] Fall back to a physical
stream for cameras that reject preferred-stream selectors
(flutter/packages#12748)
2026-10-21 [email protected] [google_sign_in_ios, video_player] Specify
types for pattern variable declarations (flutter/packages#13362)
2026-10-21 [email protected] [google_maps_flutter_web] Issue 64073
implement my location (flutter/packages#12186)
2026-10-21 [email protected] [material_ui]
Unskip web tests that pass on CanvasKit and Skwasm: app_bar_theme_test,
input_decorator_test, paginated_data_table_test,
spell_check_suggestions_toolbar_test (flutter/packages#13352)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
suryaKommana2662 pushed a commit to suryaKommana2662/flutter that referenced this pull request Oct 29, 2026
flutter/packages@1383427...93baed9

2026-10-22 [email protected] [material_ui] Port flutter/flutter
flutter#186777 MaterialColor test (flutter/packages#12858)
2026-10-21 [email protected] [rfw] Migrate to material_ui
(flutter/packages#12811)
2026-10-21 [email protected] [cupertino_ui] Fix the installing
command of the cupertino_ui package (flutter/packages#13141)
2026-10-21 [email protected]
[cupertino_ui] Unskip web tests that pass on CanvasKit and Skwasm:
date_picker_test, spell_check_suggestions_toolbar_test
(flutter/packages#13367)
2026-10-21 [email protected] [video_player] Convert player classes
to Swift (flutter/packages#13197)
2026-10-21 [email protected] [camera_windows] Fall back to a physical
stream for cameras that reject preferred-stream selectors
(flutter/packages#12748)
2026-10-21 [email protected] [google_sign_in_ios, video_player] Specify
types for pattern variable declarations (flutter/packages#13362)
2026-10-21 [email protected] [google_maps_flutter_web] Issue 64073
implement my location (flutter/packages#12186)
2026-10-21 [email protected] [material_ui]
Unskip web tests that pass on CanvasKit and Skwasm: app_bar_theme_test,
input_decorator_test, paginated_data_table_test,
spell_check_suggestions_toolbar_test (flutter/packages#13352)

If this roll has caused a breakage, revert this CL and set the roller
to dry run mode using the controls here:
https://autoroll.skia.org/r/flutter-packages-flutter-autoroll
Please CC [email protected] on the revert to ensure that a
human
is aware of the problem.

To file a bug in Flutter:
https://github.com/flutter/flutter/issues/new/choose

To report a problem with the AutoRoller itself, please file a bug:
https://issues.skia.org/issues/new?component=1389291&template=1850622

Documentation for the AutoRoller is here:
https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

autosubmit Merge PR when tree becomes green via auto submit App CICD Run CI/CD p: camera platform-windows triage-windows Should be looked at in Windows triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[camera_windows] Failed to initialize video preview with latest webcam driver

4 participants