Skip to content

[Camera]: availableCameras() throw CameraException: Camera is being used after Camera.release() was called / no camera found #76782

@szuwest

Description

@szuwest

[Camera Plugin] v0.7.0+2
call availableCameras() method and throw CameraException :
Camera is being used after Camera.release() was called

device : OPPO R11, Android 9.

Log:

ERROR, 03-01 10:56:31.441, 03-01 10:56:31.441, 26643, 27068, 27068, 03-01 10:56:31.441: E/flutter(26643): [ERROR:flutter/lib/ui/ui_dart_state.cc(177)] Unhandled Exception: CameraException(error, Camera is being used after Camera.release() was called)

ERROR, 03-01 10:56:31.441, 03-01 10:56:31.441, 26643, 27068, 27068, 03-01 10:56:31.441: E/flutter(26643): #0 MethodChannelCamera.availableCameras (package:camera_platform_interface/src/method_channel/method_channel_camera.dart:71)

The same code, run on other devices, it is all right. but it has problem on the device above.

Flutter 1.22.4 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 1aafb3a8b9 (3 months ago) • 2020-11-13 09:59:28 -0800
Engine • revision 2c956a31c0
Tools • Dart 2.10.4

flutter upgrade -f
output:

Flutter 1.22.6 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 9b2d32b605 (5 weeks ago) • 2021-01-22 14:36:39 -0800
Engine • revision 2f0af37152
Tools • Dart 2.10.5

Running flutter doctor -v...
[✓] Flutter (Channel stable, 1.22.6, on Mac OS X 10.15.6 19G2021 darwin-x64, locale zh-Hans-CN)
    • Flutter version 1.22.6 at /Users/kk/Documents/software/flutter
    • Framework revision 9b2d32b605 (5 weeks ago), 2021-01-22 14:36:39 -0800
    • Engine revision 2f0af37152
    • Dart version 2.10.5
    • Pub download mirror https://pub.flutter-io.cn
    • Flutter download mirror https://storage.flutter-io.cn

 
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
    • Android SDK at /Users/kk/Library/Android/sdk
    • Platform android-30, build-tools 30.0.2
    • ANDROID_HOME = /Users/kk/Library/Android/sdk
    • ANDROID_SDK_ROOT = /Users/kk/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Xcode 12.0.1, Build version 12A7300
    • CocoaPods version 1.9.3

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin installed
    • Dart plugin version 201.9245
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)

sample code:

Future getCameras() async {
    await availableCameras().then((lista) {
      //cameras.sink.add(lista);
    }).catchError((e) {
      //cameras.sink.add(null);
      print("ERROR CAMERA: $e");
    });
  }

By the way, I run the official example on the device, It found no camera.

flutter run -v too much output, I cannot provide

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 1.22Found to occur in 1.22has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions