Skip to content

Conversation

@romeo4934
Copy link

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.

Testing

Tested on Firefox Android with camera initialization - camera now successfully initializes where it previously failed.

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

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

1 participant