Skip to content

[camerax] orientation issue in landscape mode with camera_android_camerax while video recording #146395

@ekuleshov

Description

@ekuleshov

Steps to reproduce

To verify if I can replace the camera_android with camera_android_camerax I took the federated plugin example project from the current head of the main branch of packages repo and added camera_android_camerax dependency as stated in the camerax plugin readme:

  camera_android_camerax:
    path: ../../camera_android_camerax

Then performed the following steps

  • Build and launched this example on Samsung S23 Android phone
  • Rotated phone to landscape (automatic screen rotation is enabled in the system settings)
  • Tap any camera at the bottom. Then tap the "record video" icon button.
  • Observe video flips to 90 degrees and then recorded file is also rotated at 90 degrees.
  • Additionally the video has extension like .temp instead of .mp4

I don't observe the above behaviour after removing the camera_android_camerax dependency.

On a side note I see a lot of differences between examples located inside camera, camera_android and camera_android_camerax. Not sure why the first one is different, but shouldn't the latter two plugins have the same example code?

Expected results

I'd expect camera_android_camerax to behave the same as camera_android

Actual results

See above.

Also I see the following in the LogCat

22:51:18.322  E  Activity io.flutter.embedding.android.FlutterActivity has leaked IntentReceiver io.flutter.plugins.camerax.DeviceOrientationManager$1@4c198eb that was originally registered here. Are you missing a call to unregisterReceiver()?
                 android.app.IntentReceiverLeaked: Activity io.flutter.embedding.android.FlutterActivity has leaked IntentReceiver io.flutter.plugins.camerax.DeviceOrientationManager$1@4c198eb that was originally registered here. Are you missing a call to unregisterReceiver()?
                 	at android.app.LoadedApk$ReceiverDispatcher.<init>(LoadedApk.java:1980)
                 	at android.app.LoadedApk.getReceiverDispatcher(LoadedApk.java:1690)
                 	at android.app.ContextImpl.registerReceiverInternal(ContextImpl.java:1901)
                 	at android.app.ContextImpl.registerReceiver(ContextImpl.java:1853)
                 	at android.app.ContextImpl.registerReceiver(ContextImpl.java:1841)
                 	at android.content.ContextWrapper.registerReceiver(ContextWrapper.java:772)
                 	at io.flutter.plugins.camerax.DeviceOrientationManager.start(DeviceOrientationManager.java:74)
                 	at io.flutter.plugins.camerax.DeviceOrientationManagerHostApiImpl.startListeningForDeviceOrientationChange(DeviceOrientationManagerHostApiImpl.java:65)
                 	at io.flutter.plugins.camerax.GeneratedCameraXLibrary$DeviceOrientationManagerHostApi$-CC.lambda$setup$0(GeneratedCameraXLibrary.java:1512)
                 	at io.flutter.plugins.camerax.GeneratedCameraXLibrary$DeviceOrientationManagerHostApi$$ExternalSyntheticLambda0.onMessage(Unknown Source:2)
                 	at io.flutter.plugin.common.BasicMessageChannel$IncomingMessageHandler.onMessage(BasicMessageChannel.java:261)
                 	at io.flutter.embedding.engine.dart.DartMessenger.invokeHandler(DartMessenger.java:292)
                 	at io.flutter.embedding.engine.dart.DartMessenger.lambda$dispatchMessageToQueue$0$io-flutter-embedding-engine-dart-DartMessenger(DartMessenger.java:319)
                 	at io.flutter.embedding.engine.dart.DartMessenger$$ExternalSyntheticLambda0.run(Unknown Source:12)
                 	at android.os.Handler.handleCallback(Handler.java:958)
                 	at android.os.Handler.dispatchMessage(Handler.java:99)
                 	at android.os.Looper.loopOnce(Looper.java:230)
                 	at android.os.Looper.loop(Looper.java:319)
                 	at android.app.ActivityThread.main(ActivityThread.java:8919)
                 	at java.lang.reflect.Method.invoke(Native Method)
                 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:578)
                 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1103)

Code sample

See above

Screenshots or Video

Screenshot

image

Logs

N/A

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.19.5, on macOS 13.6.6 22G630 darwin-arm64, locale en-CA)
    • Flutter version 3.19.5 on channel stable at ***/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 300451adae (10 days ago), 2024-03-27 21:54:07 -0500
    • Engine revision e76c956498
    • Dart version 3.3.3
    • DevTools version 2.31.1

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0-rc3)
    • Android SDK at ***/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0-rc3
    • Java binary at: /Applications/Android Studio Giraffe Canary.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.9+0-17.0.9b1087.9-11255266)
    • All Android licenses accepted.

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

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

[✓] IntelliJ IDEA Ultimate Edition (version 2024.1)
    • IntelliJ at /Applications/IntelliJ IDEA.app
    • Flutter plugin version 78.5.1
    • Dart plugin version 241.15845

[✓] Connected device (3 available)
    • SM S916W (mobile) • R5CW51YL0NV • android-arm64  • Android 14 (API 34)
    • macOS (desktop)   • macos       • darwin-arm64   • macOS 13.6.6 22G630 darwin-arm64
    • Chrome (web)      • chrome      • web-javascript • Google Chrome 123.0.6312.107

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

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listfound in release: 3.19Found to occur in 3.19found in release: 3.22Found to occur in 3.22has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.platform-androidAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionteam-androidOwned by Android platform team

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions