Skip to content

Conversation

@romeo4934
Copy link

@romeo4934 romeo4934 commented Nov 1, 2025

Description

Fixes camera initialization failure on Firefox Android when no video constraints are specified.

Firefox Android rejects getUserMedia({video: {}}) with an AbortError, but accepts {video: true}. This PR modifies VideoConstraints.toMediaStreamConstraints() to return true.toJS instead 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

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

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
@romeo4934 romeo4934 requested a review from mdebbar as a code owner November 1, 2025 20:52
@flutter-dashboard
Copy link

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.

@google-cla
Copy link

google-cla bot commented Nov 1, 2025

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.

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 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.
@romeo4934 romeo4934 force-pushed the fix-camera-web-firefox-android branch from a92f2bd to ecf097d Compare November 2, 2025 06:52
Copy link
Contributor

@mdebbar mdebbar left a 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}.
Copy link
Contributor

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?

@stuartmorgan-g
Copy link
Collaborator

Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs
  • My PR includes unit or integration tests for ALL changed/updated/fixed behaviors (See [Contributor Guide])
  • All existing and new tests are passing
  • I updated/added relevant documentation (doc comments with ///)
  • The analyzer (flutter analyze) does not report any problems on my PR
  • I read and followed the [Flutter Style Guide]
  • I signed the [CLA]
  • I am willing to follow-up on review comments in a timely manner

Breaking Change

  • This is a breaking change (if so, please include a migration guide)

Generated with Claude Code

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.

@stuartmorgan-g stuartmorgan-g marked this pull request as draft November 4, 2025 19:45
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.
@romeo4934 romeo4934 marked this pull request as ready for review November 5, 2025 08:44
@stuartmorgan-g
Copy link
Collaborator

Where is this issue link? I am not seeing it in the PR description.

@romeo4934
Copy link
Author

@stuartmorgan-g where to create the issue ? it seems i can't create one in your repo

@stuartmorgan-g
Copy link
Collaborator

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

@romeo4934
Copy link
Author

thanks done @stuartmorgan-g

@romeo4934
Copy link
Author

@stuartmorgan-g any update? :)

@stuartmorgan-g
Copy link
Collaborator

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

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants