Skip to content

[camera_android_camerax] Setting exposure compensation index was canceled due to the camera being closed or a new request being submitted #148521

Closed
flutter/packages
#12582

Description

@Correct-Syntax

Steps to reproduce

  1. Create a new flutter project and paste in the code from https://github.com/flutter/packages/blob/main/packages/camera/camera/example/lib/main.dart
  2. Add camera, video_player, and permission_handler dependencies in pubspec.
  3. Add CAMERA permission to AndroidManifest.xml.
  4. Run the app in debug mode
  5. Accept the permission
  6. Tap on Exposure mode and slide the slider
  7. The error Setting exposure compensation index was canceled due to the camera being closed or a new request being submitted stops the session.

This is on a Samsung Galaxy A53 running Android 14.

Expected results

Adjusting the exposure (EV) slider should not cause errors.

Actual results

Exception: Setting exposure compensation index was canceled due to the camera being closed or a new request being submitted

Code sample

The camera example code.

Screenshots or Video

Screenshots / Video demonstration

[Upload media here]

Logs

Logs
[Paste your logs here]

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.22.0, on Zorin OS 17.1 6.5.0-35-generic, locale
    en_US.UTF-8)
    • Flutter version 3.22.0 on channel stable at /home/noah/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 5dcb86f68f (7 days ago), 2024-05-09 07:39:20 -0500
    • Engine revision f6344b75dc
    • Dart version 3.4.0
    • DevTools version 2.34.3

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /home/noah/Android/Sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /home/noah/android-studio/jbr/bin/java
    • Java version OpenJDK Runtime Environment (build
      17.0.10+0-17.0.10b1087.21-11572160)
    • All Android licenses accepted.

[✗] Chrome - develop for the web (Cannot find Chrome executable at
    google-chrome)
    ! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.

[✗] Linux toolchain - develop for Linux desktop
    ✗ clang++ is required for Linux development.
      It is likely available from your distribution (e.g.: apt install clang),
      or can be downloaded from https://releases.llvm.org/
    ✗ CMake is required for Linux development.
      It is likely available from your distribution (e.g.: apt install cmake),
      or can be downloaded from https://cmake.org/download/
    ✗ ninja is required for Linux development.
      It is likely available from your distribution (e.g.: apt install
      ninja-build), or can be downloaded from
      https://github.com/ninja-build/ninja/releases
    • pkg-config version 0.29.2
    ✗ GTK 3.0 development libraries are required for Linux development.
      They are likely available from your distribution (e.g.: apt install
      libgtk-3-dev)

[✓] Android Studio (version 2023.3)
    • Android Studio at /home/noah/android-studio
    • Flutter plugin version 79.0.2
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build
      17.0.10+0-17.0.10b1087.21-11572160)

[✓] Connected device (2 available)
    • SM S536DL (mobile) • <unknown> • android-arm64 • Android 14 (API 34)
    • Linux (desktop)    • linux     • linux-x64     • Zorin OS 17.1
      6.5.0-35-generic

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

! Doctor found issues in 2 categories.

Activity

  1. danagbemava-nc commented on May 17, 2024

    @danagbemava-nc
    Member

    Reproducible using the plugin example app and the steps outlined above.

    I tested on my Pixel 7.

    I/flutter (10804): Error: setExposureOffsetFailed
    I/flutter (10804): Error Message: Setting exposure compensation index was canceled due to the camera being closed or a new request being submitted.
    E/flutter (10804): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: CameraException(setExposureOffsetFailed, Setting exposure compensation index was canceled due to the camera being closed or a new request being submitted.)
    E/flutter (10804): #0      AndroidCameraCameraX.setExposureOffset (package:camera_android_camerax/src/android_camera_camerax.dart:669:9)
    E/flutter (10804): <asynchronous suspension>
    E/flutter (10804): #1      _CameraExampleHomeState.setExposureOffset (package:libr/main.dart:957:16)
    E/flutter (10804): <asynchronous suspension>
    E/flutter (10804): 
    
    flutter doctor -v
    [!] Flutter (Channel stable, 3.22.0, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
        • Flutter version 3.22.0 on channel stable at /Users/nexus/dev/sdks/flutter
        ! Warning: `flutter` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/nexus/dev/sdks/flutters/bin/dart, which is not inside your current Flutter SDK checkout at /Users/nexus/dev/sdks/flutter. Consider adding /Users/nexus/dev/sdks/flutter/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 5dcb86f68f (8 days ago), 2024-05-09 07:39:20 -0500
        • Engine revision f6344b75dc
        • Dart version 3.4.0
        • DevTools version 2.34.3
        • 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 34.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.3)
        • Xcode at /Applications/Xcode-15.3.0.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 2023.1)
        • Android Studio at /Users/nexus/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.7+0-17.0.7b1000.6-10550314)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 77.2.2
        • Dart plugin version 232.10286
    
    [✓] VS Code (version 1.89.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.88.0
    
    [✓] Connected device (6 available)
        • Pixel 7 (mobile)                • adb-28291FDH2001SA-5Lv71w._adb-tls-connect._tcp. • android-arm64  • Android 14 (API 34)
        • Nexus (mobile)                  • 00008020-001875E83A38002E                        • ios            • iOS 17.4.1 21E236
        • Dean’s iPad (mobile)            • 00008103-000825C811E3401E                        • ios            • iOS 17.4.1 21E236
        • macOS (desktop)                 • macos                                            • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad                            • darwin         • macOS 14.4.1 23E224 darwin-arm64
        • Chrome (web)                    • chrome                                           • web-javascript • Google Chrome 124.0.6367.208
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
    
    [✓] Flutter (Channel master, 3.22.0-36.0.pre.36, on macOS 14.4.1 23E224 darwin-arm64, locale en-GB)
        • Flutter version 3.22.0-36.0.pre.36 on channel master at /Users/nexus/dev/sdks/flutters
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 58dfbbc1ec (4 hours ago), 2024-05-17 00:12:37 -0400
        • Engine revision 8d1a1d8d7b
        • Dart version 3.5.0 (build 3.5.0-162.0.dev)
        • DevTools version 2.36.0-dev.10
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/nexus/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • Java binary at: /Users/nexus/Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.3)
        • Xcode at /Applications/Xcode-15.3.0.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 2023.1)
        • Android Studio at /Users/nexus/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.7+0-17.0.7b1000.6-10550314)
    
    [✓] IntelliJ IDEA Ultimate Edition (version 2023.2.5)
        • IntelliJ at /Users/nexus/Applications/IntelliJ IDEA Ultimate.app
        • Flutter plugin version 77.2.2
        • Dart plugin version 232.10286
    
    [✓] VS Code (version 1.89.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.88.0
    
    [✓] Connected device (6 available)
        • Pixel 7 (mobile)                • adb-28291FDH2001SA-5Lv71w._adb-tls-connect._tcp. • android-arm64  • Android 14 (API 34)
        • Nexus (mobile)                  • 00008020-001875E83A38002E                        • ios            • iOS 17.4.1 21E236
        • Dean’s iPad (mobile)            • 00008103-000825C811E3401E                        • ios            • iOS 17.4.1 21E236
        • macOS (desktop)                 • macos                                            • darwin-arm64   • macOS 14.4.1 23E224 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad                            • darwin         • macOS 14.4.1 23E224 darwin-arm64
        • Chrome (web)                    • chrome                                           • web-javascript • Google Chrome 124.0.6367.208
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
    
    
  2. added
    c: crashStack traces logged to the console
    platform-androidAndroid applications specifically
    packageflutter/packages repository. See also p: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    team-androidOwned by Android platform team
    fyi-ecosystemFor the attention of Ecosystem team
    and removed
    in triagePresently being triaged by the triage team
    on May 17, 2024
  3. gmackall commented on May 23, 2024

    @gmackall
    Member
  4. 7 remaining items

  5. added
    P2Important issues not at the top of the work list
    triaged-androidTriaged by Android platform team
    on Jun 3, 2024
  6. camsim99 commented on Jun 3, 2024

    @camsim99
    Contributor

    Set this to P2 because this is a bug I think we take on strictly after fixes are made to support Impeller, which is top priority for the team.

  7. Buenaventura-Celine commented on Sep 16, 2024

    @Buenaventura-Celine

    Is there a suggested workaround for this?

  8. MMoarales commented on Nov 13, 2024

    @MMoarales
  9. camsim99 commented on Nov 14, 2024

    @camsim99
    Contributor

    Not actively working on this but next steps would be to figure out why we are seeing the
    was canceled due to the camera being closed or a new request being submitted" error because we actually swallow the exception due to submitting too many values: https://github.com/flutter/packages/blob/b9ac917daeb0fbf5bd6ad4a7d2a69ab81749d767/packages/camera/camera_android_camerax/android/src/main/java/io/flutter/plugins/camerax/CameraControlHostApiImpl.java#L187-L192.

    Thus, this issue is probably caused by another exception. The documentation mentions an IllegalArgumentException being possible so I wonder if it's that and we are trying to support unsiupported exposure compensation index values.

  10. moved this to Blocking deletion in Deprecating camera_androidon Jul 7, 2025
  11. moved this from [Blocking] Harder to delegate to [Blocking] Easy to delegate in Deprecating camera_androidon Jul 7, 2025
  12. mmcdanielq commented on May 7, 2026

    @mmcdanielq

    This is not just exposure, I get this error when trying to focus the camera: "Starting focus and metering was canceled due to the camera being closed or a new request being submitted". After receiving this error the camera becomes unusable until restarting it. I'm using the example project in the camera package.

    Flutter 3.41.9 • channel stable • https://github.com/flutter/flutter.git
    Framework • revision 00b0c91 (8 days ago) • 2026-04-29 10:03:19 -0700
    Engine • hash 9161402dc0e134b3fb5adee5046b6e84b1a5e1c1 (revision 42d3d75) (8 days ago) • 2026-04-28 17:31:55.000Z
    Tools • Dart 3.11.5 • DevTools 2.54.2

  13. moved this from [Blocking] Easy to delegate to In Progress in Deprecating camera_androidon Sep 2, 2026
  14. github-actions commented on Oct 14, 2026

    @github-actions

    This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

  15. locked as resolved and limited conversation to collaborators on Oct 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listc: crashStack traces logged to the consolefound 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 specificallyteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions