Skip to content

[Flutter][Android] setCameraFocusPositionInPreview does not work as expected #2257

Closed as not planned
@locandpad

Description

@locandpad

Basically, I have the same problem as this issue: #195

When calling setCameraFocusPositionInPreview, the camera focuses at the tap position for a brief second then switches back to auto-focus somewhere else. I do receive the cameraFocusAreaChanged just fine. Cameras are standing still and not moving.

I don't think this is my camera problem since I have tested on multiple devices, including popular phones like Samsung S21 and Pixel 6. The stock camera app works as expected, when I tap on the position to focus, it keep the focus until I tap somewhere else.

  • Device: Pixel 5a, Samsung S21, etc
  • OS: Android 12, Android 14
  • Agora RTC: 6.5.1

Platforms affected

  • Android
  • iOS
  • macOS
  • Windows
  • Web

Steps to reproduce

  1. Enable video module
  2. Call setCameraFocusPositionInPreview with localPosition from GestureDetector

Expected results

Camera should keep the focus on tap position

Actual results

Camera only keep the focus on tap position for a brief second then switches back to auto-focus somewhere else

Code sample

Code sample
[Paste your code here]

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[!] Flutter (Channel [user-branch], 3.27.0, on macOS 14.7 23H124 darwin-arm64, locale en-VN)
    ! Flutter version 3.27.0 on channel [user-branch] at /Users/Desktop/user/development/flutter
      Currently on an unknown channel. Run `flutter channel` to switch to an official channel.
      If that doesn't fix the issue, reinstall Flutter by following instructions at https://flutter.dev/setup.
    ! Upstream repository unknown source is not a standard remote.
      Set environment variable "FLUTTER_GIT_URL" to unknown source to dismiss this error.
    • Framework revision 8495dee1fd (4 months ago), 2024-12-10 14:23:39 -0800
    • Engine revision 83bacfc525
    • Dart version 3.6.0
    • DevTools version 2.40.2
    • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update
      checks and upgrades.

[✓] Android toolchain - develop for Android devices (Android SDK version 35.0.0)
    • Android SDK at /Users/user/Library/Android/sdk
    • Platform android-35, build-tools 35.0.0
    • ANDROID_HOME = /Users/user/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)
    • All Android licenses accepted.

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

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

[✓] Android Studio (version 2024.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 17.0.11+0-17.0.11b1207.24-11852314)

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions