-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
Hi, I have problem with camera in 0.7.0 version. When I try take a photo with turned on flash camera throw timeout exception.
I/flutter (20358): CameraException(captureTimeout, Picture capture request timed out)
I/flutter (20358): #6 _rootRunBinary (dart:async/zone.dart:1214:47)
I/flutter (20358): #7 _CustomZone.runBinary (dart:async/zone.dart:1107:19)
I/flutter (20358): #8 _FutureListener.handleError (dart:async/future_impl.dart:157:20)
I/flutter (20358): #9 Future._propagateToListeners.handleError (dart:async/future_impl.dart:708:47)
I/flutter (20358): #10 Future._propagateToListeners (dart:async/future_impl.dart:729:24)
I/flutter (20358): #11 Future._completeError (dart:async/future_impl.dart:537:5)
I/flutter (20358): #12 _AsyncAwaitCompleter.completeError (dart:async-patch/async_patch.dart:47:15)
I/flutter (20358): #13 CameraController.takePicture (package:camera/src/camera_controller.dart)
I/flutter (20358): #14 _asyncErrorWrapperHelper.errorCallback (dart:async-patch/async_patch.dart:91:64)
I/flutter (20358): #15 _rootRunBinary (dart:async/zone.dart:1214:47)
I/flutter (20358): #16 _CustomZone.runBinary (dart:async/zone.dart:1107:19)
I/flutter (20358): #17 FutureListener.handleError (dart:async/future
It happens when autofocus not get right focus.
Flutter doctor output:
[✓] Flutter (Channel unknown, 1.22.4, on macOS 11.1 20C69 darwin-x64, locale pl-PL)
• Flutter version 1.22.4 at fvm/versions/1.22.4
• Framework revision 1aafb3a (2 months ago), 2020-11-13 09:59:28 -0800
• Engine revision 2c956a31c0
• Dart version 2.10.4[!] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at Library/Android/sdk
• Platform android-30, build-tools 30.0.2
• ANDROID_HOME = /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)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses[✓] Xcode - develop for iOS and macOS (Xcode 12.3)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.3, Build version 12C33
• CocoaPods version 1.9.3[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome[!] Android Studio (version 4.1)
• Android Studio at /Applications/Android Studio.app/Contents
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)[!] IntelliJ IDEA Community Edition (version 2020.1.2)
• IntelliJ at /Applications/IntelliJ IDEA CE.app
✗ Flutter plugin not installed; this adds Flutter specific functionality.
✗ Dart plugin not installed; this adds Dart specific functionality.
• For information about installing plugins, see
https://flutter.dev/intellij-setup/#installing-the-plugins[✓] Connected device (5 available)
• Pixel 3a (mobile) • 9CBAY1NPJR • android-arm64 • Android 11 (API 30)
• sdk gphone x86 64 (mobile) • emulator-5554 • android-x64 • Android 11 (API 30) (emulator)
• Web Server (web) • web-server • web-javascript • Flutter Tools
• Chrome (web) • chrome • web-javascript • Google Chrome 88.0.4324.96
! Doctor found issues in 3 categories. I have noticed it only on Android device (Pixel 3a).
Code to reproduce:
void _initializeController() {
if (cameras.length == 0) {
log('No cameras detected');
return;
}
controller = CameraController(cameras[0], ResolutionPreset.max,
imageFormatGroup: Platform.isIOS ? ImageFormatGroup.bgra8888 : ImageFormatGroup.jpeg);
controller.initialize().then((_) async {
if (!mounted) {
return;
}
try {
await controller.setFlashMode( FlashMode.always);
} catch (exc, stack) {
}
setState(() {});
});
}
Future<String> takePicture() async {
if (!controller.value.isInitialized) {
return null;
}
if (controller.value.isTakingPicture) {
return null;
}
try {
final result = await controller.takePicture();
return result.path;
} catch (exc) {
return null;
}
}