-
Notifications
You must be signed in to change notification settings - Fork 3.5k
[camera_web] Fix camera initialization failure on Firefox Android #10341
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?
Conversation
When VideoConstraints has no constraints, return true.toJS instead of an
empty object. Firefox Android rejects getUserMedia({video: {}}) with an
AbortError, but accepts {video: true}.
This fixes the camera initialization failure in availableCameras() on
Firefox Android while maintaining compatibility with other browsers.
Fixes flutter/flutter#XXXXX
When VideoConstraints has no constraints, return true.toJS instead of an
empty object. Firefox Android rejects getUserMedia({video: {}}) with an
AbortError, but accepts {video: true}.
This fixes the camera initialization failure in availableCameras() on
Firefox Android while maintaining compatibility with other browsers.
Fixes flutter/flutter#XXXXX
…omeo4934/packages into fix-camera-web-firefox-android # Conflicts: # packages/camera/camera_web/lib/src/types/camera_options.dart
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
|
Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). View this failed invocation of the CLA check for more information. For the most up to date status, view the checks section at the bottom of the pull request. |
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 fixes a camera initialization failure on Firefox for Android. The change modifies VideoConstraints.toMediaStreamConstraints() to return true instead of an empty object when no video constraints are specified, improving browser compatibility. The changelog and package version are updated accordingly. My review focuses on the lack of a test case for this new logic path, which is required by the project's contribution guidelines.
Add integration test to verify that VideoConstraints.toMediaStreamConstraints() returns true when no constraints are provided, covering the Firefox Android compatibility fix.
a92f2bd to
ecf097d
Compare
mdebbar
left a comment
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.
Thank you for the fix!
| }; | ||
|
|
||
| // Return true instead of empty object for better browser compatibility. | ||
| // Firefox Android rejects getUserMedia({video: {}}) but accepts {video: true}. |
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.
Is this bug documented anywhere that we can link to for context?
This is not the Flutter packages checklist. The process we require for a PR is decided by the Flutter team, not by Claude, so letting an LLM create its own checklist instead of using ours is not useful. Also, we review hundreds of PRs, and having every contributor invent their own PR description format instead of using ours is not scalable. It's fine to use AI tools to help create PRs, but not to replace our PR template. I have restored the actual checklist; once you've completed it, please mark the PR as ready for review. |
This is a bugfix, not a breaking change or new feature, so it should be a patch version bump according to Dart semantic versioning for packages <1.0.
Where is this issue link? I am not seeing it in the PR description. |
|
@stuartmorgan-g where to create the issue ? it seems i can't create one in your repo |
https://github.com/flutter/packages?tab=readme-ov-file#issues (In the future, if you have questions about instructions in the checklist I would encourage you to ask up front, rather than ignore the instruction and check the box when you haven't done the step.) |
|
thanks done @stuartmorgan-g |
|
@stuartmorgan-g any update? :) |
Since you have checked the box indicating that you read the contributing docs, I'm sure you saw the prominent note that says "Expect that a new patch will be reviewed within two weeks, unless it is fixing a P0 bug [...] Remember that reviewers are human beings with additional professional and personal responsibilities." Pinging people after two days is not appropriate. |
Description
Fixes camera initialization failure on Firefox Android when no video constraints are specified.
Firefox Android rejects
getUserMedia({video: {}})with anAbortError, but accepts{video: true}. This PR modifiesVideoConstraints.toMediaStreamConstraints()to returntrue.toJSinstead of an empty object when no constraints are specified, improving browser compatibility.Related Issue
This fix addresses camera initialization failures on Firefox Android where the camera plugin would fail with a
CameraException(cameraAbort)error.flutter/flutter#115892
Testing
Tested on Firefox Android with camera initialization - camera now successfully initializes where it previously failed.
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