Skip to content

[android_camera_camerax] Fix incorrect camera mirroring for front cameras on devices using ImageReader Impeller backend #9233

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

Merged
merged 15 commits into from
Jun 12, 2025

Conversation

camsim99
Copy link
Contributor

@camsim99 camsim99 commented May 9, 2025

Fixes the incorrect camera mirroring when the front camera is used on devices that use the ImageReader Impeller backend. TLDR: for relevant rotated preview implementation, when the front camera is used, mirror the camera preview across the y-axis when the device is in a portrait orientation or across the x-axis when the device is in a landscape orientation.

Fixes flutter/flutter#156974.

cc @jesswrd, co-author of this PR

Pre-Review Checklist

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

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

@jesswrd jesswrd marked this pull request as draft May 9, 2025 19:36
@jesswrd jesswrd changed the title [android_camera_camerax] Fix incorrect camera mirroring for front cameras on devices using ImageReader Impeller backend [WIP] [android_camera_camerax] Fix incorrect camera mirroring for front cameras on devices using ImageReader Impeller backend May 9, 2025
@jesswrd jesswrd changed the title [WIP] [android_camera_camerax] Fix incorrect camera mirroring for front cameras on devices using ImageReader Impeller backend [android_camera_camerax] Fix incorrect camera mirroring for front cameras on devices using ImageReader Impeller backend Jun 2, 2025
@camsim99 camsim99 marked this pull request as ready for review June 2, 2025 22:36
Copy link
Contributor Author

@camsim99 camsim99 left a comment

Choose a reason for hiding this comment

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

These look great, thank you! Just added some suggestions for clarity in case someone has to revisit this later :)

Copy link
Contributor Author

@camsim99 camsim99 left a comment

Choose a reason for hiding this comment

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

LGTM! Just found an extra space

@camsim99 camsim99 requested a review from a team June 12, 2025 14:43
@camsim99
Copy link
Contributor Author

@jesswrd and I worked on this PR together, so we'll need another reviewer to land this PR!

// If the camera is front facing, mirror the camera preview
// according to the current device orientation.
Widget cameraPreview = widget.child;
if (widget.facingSign == 1) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is == 1 the correct comparison here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah because facingSign maps to the sign in https://developer.android.com/media/camera/camera2/camera-preview#orientation_calculation, which is 1 for front cameras, -1 for back facing cameras. I'll add a comment to the code!

@camsim99 camsim99 added the autosubmit Merge PR when tree becomes green via auto submit App label Jun 12, 2025
@auto-submit auto-submit bot merged commit ee79db6 into flutter:main Jun 12, 2025
78 checks passed
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 13, 2025
… front cameras on devices using `ImageReader` Impeller backend (flutter/packages#9233)
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Jun 13, 2025
… front cameras on devices using `ImageReader` Impeller backend (flutter/packages#9233)
github-merge-queue bot pushed a commit to flutter/flutter that referenced this pull request Jun 13, 2025
flutter/packages@6d3aaf4...c5ab57a

2025-06-13 [email protected] [flutter_svg]
feat: Expose the renderStrategy property in SvgPicture
(flutter/packages#9373)
2025-06-12 [email protected] [go_router] Add routing functions to
GoRouteData (flutter/packages#9277)
2025-06-12 [email protected] [various] Update example apps to
Swift (flutter/packages#9347)
2025-06-12 [email protected] Roll Flutter from
824868f to f79452e (94 revisions) (flutter/packages#9419)
2025-06-12 [email protected]
[android_camera_camerax] Fix incorrect camera mirroring for front
cameras on devices using `ImageReader` Impeller backend
(flutter/packages#9233)

If this roll has caused a breakage, revert this CL and stop the roller
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 p: camera
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Camera preview for front camera is flipped post ImageReader updates
3 participants