flutter / flutter/flutter

camera: CameraPreview displays landscape images on an mobile web when it is held in a portrait position.

Open
#143,288 9 comments 0 reactions 0 assignees View on GitHub
assigned for triage found in release: 3.16 found in release: 3.20 has partial patch has reproducible steps p: camera P3 platform-web team-web triaged-web
Dominant language
Dart
Stars
179k
Forks
31.1k
PR merge metrics
PR metrics pending

Description

### Steps to reproduce

The following steps were replicated on Flutter Web, iPhone 15, iOS 17.2.1, and Mobile Safari.

1. Hold an iPhone 15 in a portrait position (with the front-facing camera up and the charging port down).
2. Open iOS Mobile Safari.
3. Navigate to https://camera-preview-bug.web.app/.
4. Tap on the front-facing camera icon on the bottom left.

### Expected results

It is expected that CameraPreview would display portrait images, similar to the iOS camera app.

![F882DDEE-C410-4384-8201-84E4BAD88955_1_102_o](https://github.com/flutter/flutter/assets/1053445/a818f3f9-5a42-48a8-9b26-4bc7f2359510)

### Actual results

However, CameraPreview currently shows cropped landscape images instead.

![4CF1688F-1C14-46D6-AF1D-4F56D8BEDA74_1_102_o](https://github.com/flutter/flutter/assets/1053445/cbd2c948-d4f4-4754-bcfe-4a7805fa8890)

Interestingly, when accessing the website with the phone already in a landscape position, the camera preview functions correctly. It even displays valid portrait images when the phone is rotated to a portrait position.

### Code sample

Code sample

The official camera example from https://github.com/flutter/packages/tree/main/packages/camera/camera/example was used for the website without any modifications.

### Screenshots or Video

Screenshots / Video demonstration

![4CF1688F-1C14-46D6-AF1D-4F56D8BEDA74_1_102_o](https://github.com/flutter/flutter/assets/1053445/635e169e-b417-459b-888d-79f2512a6a39)

### Logs

Logs

```console
[Paste your logs here]
```

### Flutter Doctor output

Doctor output

```console
[✓] Flutter (Channel stable, 3.16.8, on macOS 14.2.1 23C71 darwin-arm64, locale en-US)
• Flutter version 3.16.8 on channel stable at /opt/homebrew/Caskroom/flutter/3.16.4/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 67457e669f (4 weeks ago), 2024-01-16 16:22:29 -0800
• Engine revision 6e2ea58a5c
• Dart version 3.2.5
• DevTools version 2.28.5

[✗] Android toolchain - develop for Android devices
✗ Unable to locate Android SDK.
Install Android Studio from: https://developer.android.com/studio/index.html
On first launch it will assist you in installing the Android SDK components.
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).
If the Android SDK has been installed to a custom location, please use
`flutter config --android-sdk` to update to that location.

[✓] Xcode - develop for iOS and macOS (Xcode 15.2)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Build 15C500b
• CocoaPods version 1.14.3

[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[!] Android Studio (not installed)
• Android Studio not found; download from https://developer.android.com/studio/index.html
(or visit https://flutter.dev/docs/get-started/install/macos#android-setup for detailed instructions).

[✓] Connected device (2 available)
• macOS (desktop) • macos • darwin-arm64 • macOS 14.2.1 23C71 darwin-arm64
• Chrome (web) • chrome • web-javascript • Google Chrome 121.0.6167.160

[✓] Network resources
• All expected network resources are available.

! Doctor found issues in 2 categories.
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.