Skip to content

Camera first photo is overexposed when using startImageStream #134300

Closed

Description

@vodemn

Is there an existing issue for this?

Steps to reproduce

  1. Open the app
  2. Take a picture
  3. Take a picture of the same scene
  4. Exit to the home screen of your device
  5. Open the app again
  6. Repeat 2-3

Expected results

EV is always +- the same

Actual results

The first picture is overexposed sometimes

Code sample

Code sample
// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import 'dart:async';
import 'dart:developer';
import 'dart:io';
import 'dart:math' as math;

import 'package:camera/camera.dart';
import 'package:exif/exif.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(const CameraApp());
}

/// CameraApp is the Main Application.
class CameraApp extends StatelessWidget {
  /// Default Constructor
  const CameraApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(
      home: CameraExampleHome(),
    );
  }
}

/// Camera example home widget.
class CameraExampleHome extends StatefulWidget {
  /// Default Constructor
  const CameraExampleHome({Key? key}) : super(key: key);

  @override
  State<CameraExampleHome> createState() {
    return _CameraExampleHomeState();
  }
}

class _CameraExampleHomeState extends State<CameraExampleHome> with WidgetsBindingObserver, TickerProviderStateMixin {
  CameraController? controller;

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
    initialize();
  }

  @override
  void dispose() {
    WidgetsBinding.instance.removeObserver(this);
    super.dispose();
  }

  // #docregion AppLifecycle
  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    final CameraController? cameraController = controller;

    // App state changed before we got the chance to initialize.
    if (cameraController == null || !cameraController.value.isInitialized) {
      return;
    }

    if (state == AppLifecycleState.inactive) {
      cameraController.dispose();
    } else if (state == AppLifecycleState.resumed) {
      initialize();
    }
  }
  // #enddocregion AppLifecycle

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('Camera example'),
      ),
      body: Column(
        children: <Widget>[
          Expanded(
            child: Container(
              decoration: const BoxDecoration(color: Colors.black),
              child: Padding(
                padding: const EdgeInsets.all(1.0),
                child: Center(
                  child: controller == null || !controller!.value.isInitialized
                      ? const SizedBox.shrink()
                      : Stack(
                          children: [
                            CameraPreview(controller!),
                            CameraHistogram(controller: controller!),
                          ],
                        ),
                ),
              ),
            ),
          ),
          IconButton(
            icon: const Icon(Icons.camera_alt),
            color: Colors.blue,
            onPressed: controller != null && controller!.value.isInitialized && !controller!.value.isRecordingVideo
                ? takePicture
                : null,
          ),
        ],
      ),
    );
  }

  Future<void> initialize() async {
    try {
      final List<CameraDescription> cameras = await availableCameras();
      if (cameras.isEmpty) {
        return;
      }
      controller = CameraController(
        cameras.firstWhere(
          (CameraDescription camera) => camera.lensDirection == CameraLensDirection.back,
          orElse: () => cameras.last,
        ),
        ResolutionPreset.low,
        enableAudio: false,
      );

      await controller!.initialize();
      await controller!.setFlashMode(FlashMode.off);

      setState(() {});
    } catch (e) {
      log(e.toString());
    }
  }

  Future<XFile?> takePicture() async {
    final CameraController? cameraController = controller;
    if (cameraController == null || !cameraController.value.isInitialized) {
      return null;
    }

    if (cameraController.value.isTakingPicture) {
      // A capture is already pending, do nothing.
      return null;
    }

    try {
      await cameraController.setFocusMode(FocusMode.locked);
      await cameraController.setExposureMode(ExposureMode.locked);
      final XFile file = await cameraController.takePicture();
      await cameraController.setFocusMode(FocusMode.auto);
      await cameraController.setExposureMode(ExposureMode.auto);

      final Uint8List bytes = await file.readAsBytes();
      Directory(file.path).deleteSync(recursive: true);

      final Map<String, IfdTag> tags = await readExifFromBytes(bytes);
      final double? iso = double.tryParse("${tags["EXIF ISOSpeedRatings"]}");
      final Ratio? apertureValueRatio = (tags['EXIF FNumber']?.values as IfdRatios?)?.ratios.first;
      final Ratio? speedValueRatio = (tags['EXIF ExposureTime']?.values as IfdRatios?)?.ratios.first;
      if (iso == null || apertureValueRatio == null || speedValueRatio == null) {
        log('Error parsing EXIF: ${tags.keys}');
        return null;
      }

      final double aperture = apertureValueRatio.numerator / apertureValueRatio.denominator;
      final double speed = speedValueRatio.numerator / speedValueRatio.denominator;
      double log2(num x) => math.log(x) / math.log(2);
      final double ev = log2(math.pow(aperture, 2)) - log2(speed) - log2(iso / 100);
      showInSnackBar('Photo taken. EV: $ev');
      return file;
    } on CameraException catch (e) {
      log('Error: ${e.code}${e.description == null ? '' : '\nError Message: ${e.description}'}');
      return null;
    }
  }

  void showInSnackBar(String message) {
    ScaffoldMessenger.of(context).showSnackBar(SnackBar(content: Text(message)));
  }
}

class CameraHistogram extends StatefulWidget {
  final CameraController controller;

  const CameraHistogram({required this.controller, super.key});

  @override
  _CameraHistogramState createState() => _CameraHistogramState();
}

class _CameraHistogramState extends State<CameraHistogram> {
  List<int> histogramR = List.filled(256, 0);
  List<int> histogramG = List.filled(256, 0);
  List<int> histogramB = List.filled(256, 0);

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addPostFrameCallback((_) {
      _startImageStream();
    });
  }

  @override
  void didUpdateWidget(covariant CameraHistogram oldWidget) {
    super.didUpdateWidget(oldWidget);
    WidgetsBinding.instance.addPostFrameCallback((_) {
      _startImageStream();
    });
  }

  @override
  void dispose() {
    /// There is no need to stop image stream here,
    /// because this widget will be disposed when CameraController is disposed
    widget.controller.stopImageStream();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return const SizedBox();
  }

  void _startImageStream() {
    widget.controller.startImageStream((CameraImage image) {});
  }
}
pubspec.yaml
name: camera_example
description: Demonstrates how to use the camera plugin.
publish_to: none

environment:
  sdk: ">=3.0.0 <4.0.0"

dependencies:
  camera: 0.10.5+2
  exif: 3.1.4
  flutter:
    sdk: flutter

flutter:
  uses-material-design: true

Screenshots or Video

Screenshots / Video demonstration

ezgif com-optimize-2

Logs

Logs
Restarted application in 2,457ms.
I/Camera  (15651): close
I/Camera  (15651): open | onClosed
W/Camera  (15651): The selected imageFormatGroup is not supported by Android. Defaulting to yuv420
I/Camera  (15651): startPreview
I/Camera  (15651): CameraCaptureSession onConfigured
I/Camera  (15651): Updating builder settings
D/Camera  (15651): Updating builder with feature: ExposureLockFeature
D/Camera  (15651): Updating builder with feature: ExposurePointFeature
D/Camera  (15651): Updating builder with feature: ZoomLevelFeature
D/Camera  (15651): Updating builder with feature: AutoFocusFeature
D/Camera  (15651): Updating builder with feature: NoiseReductionFeature
I/Camera  (15651): updateNoiseReduction | currentSetting: fast
D/Camera  (15651): Updating builder with feature: FocusPointFeature
D/Camera  (15651): Updating builder with feature: ResolutionFeature
D/Camera  (15651): Updating builder with feature: SensorOrientationFeature
D/Camera  (15651): Updating builder with feature: FlashFeature
D/Camera  (15651): Updating builder with feature: ExposureOffsetFeature
D/Camera  (15651): Updating builder with feature: FpsRangeFeature
I/Camera  (15651): refreshPreviewCaptureSession
I/Camera  (15651): refreshPreviewCaptureSession
I/Camera  (15651): startPreviewWithImageStream
I/Camera  (15651): CameraCaptureSession onConfigured
I/Camera  (15651): Updating builder settings
D/Camera  (15651): Updating builder with feature: ExposureLockFeature
D/Camera  (15651): Updating builder with feature: ExposurePointFeature
D/Camera  (15651): Updating builder with feature: ZoomLevelFeature
D/Camera  (15651): Updating builder with feature: AutoFocusFeature
D/Camera  (15651): Updating builder with feature: NoiseReductionFeature
I/Camera  (15651): updateNoiseReduction | currentSetting: fast
D/Camera  (15651): Updating builder with feature: FocusPointFeature
D/Camera  (15651): Updating builder with feature: ResolutionFeature
D/Camera  (15651): Updating builder with feature: SensorOrientationFeature
D/Camera  (15651): Updating builder with feature: FlashFeature
D/Camera  (15651): Updating builder with feature: ExposureOffsetFeature
D/Camera  (15651): Updating builder with feature: FpsRangeFeature
I/Camera  (15651): refreshPreviewCaptureSession
I/Camera  (15651): CameraCaptureSession onClosed
W/1.raster(15651): type=1400 audit(0.0:112468): avc: denied { getattr } for name="/" dev="dmabuf" ino=1 scontext=u:r:untrusted_app_27:s0:c37,c257,c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=filesystem permissive=0 app=io.flutter.plugins.cameraexample
W/1.raster(15651): type=1400 audit(0.0:112469): avc: denied { getattr } for name="/" dev="dmabuf" ino=1 scontext=u:r:untrusted_app_27:s0:c37,c257,c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=filesystem permissive=0 app=io.flutter.plugins.cameraexample
W/1.raster(15651): type=1400 audit(0.0:112470): avc: denied { getattr } for name="/" dev="dmabuf" ino=1 scontext=u:r:untrusted_app_27:s0:c37,c257,c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=filesystem permissive=0 app=io.flutter.plugins.cameraexample
W/1.raster(15651): type=1400 audit(0.0:112471): avc: denied { getattr } for name="/" dev="dmabuf" ino=1 scontext=u:r:untrusted_app_27:s0:c37,c257,c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=filesystem permissive=0 app=io.flutter.plugins.cameraexample
W/1.raster(15651): type=1400 audit(0.0:112472): avc: denied { getattr } for name="/" dev="dmabuf" ino=1 scontext=u:r:untrusted_app_27:s0:c37,c257,c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=filesystem permissive=0 app=io.flutter.plugins.cameraexample
W/System  (15651): A resource failed to call Surface.release.
I/Camera  (15651): lockAutoFocus
I/Camera  (15651): refreshPreviewCaptureSession
I/Camera  (15651): runPrecaptureSequence
I/Camera  (15651): refreshPreviewCaptureSession
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_START | afState: 2 | aeState: 2
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 2 | aeState: 2
I/Camera  (15651): captureStillPicture
D/Camera  (15651): Updating builder with feature: ExposureLockFeature
D/Camera  (15651): Updating builder with feature: ExposurePointFeature
D/Camera  (15651): Updating builder with feature: ZoomLevelFeature
D/Camera  (15651): Updating builder with feature: AutoFocusFeature
D/Camera  (15651): Updating builder with feature: NoiseReductionFeature
I/Camera  (15651): updateNoiseReduction | currentSetting: fast
D/Camera  (15651): Updating builder with feature: FocusPointFeature
D/Camera  (15651): Updating builder with feature: ResolutionFeature
D/Camera  (15651): Updating builder with feature: SensorOrientationFeature
D/Camera  (15651): Updating builder with feature: FlashFeature
D/Camera  (15651): Updating builder with feature: ExposureOffsetFeature
D/Camera  (15651): Updating builder with feature: FpsRangeFeature
I/Camera  (15651): sending capture request
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 2 | aeState: 2
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 2 | aeState: 2
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 2 | aeState: 2
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 2 | aeState: 2
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 2 | aeState: 2
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 2 | aeState: 2
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 5 | aeState: 5
I/Camera  (15651): onImageAvailable
I/Camera  (15651): unlockAutoFocus
I/Camera  (15651): refreshPreviewCaptureSession
I/Camera  (15651): unlockAutoFocus
I/Camera  (15651): refreshPreviewCaptureSession
I/Camera  (15651): refreshPreviewCaptureSession
W/1.raster(15651): type=1400 audit(0.0:112473): avc: denied { getattr } for name="/" dev="dmabuf" ino=1 scontext=u:r:untrusted_app_27:s0:c37,c257,c512,c768 tcontext=u:object_r:unlabeled:s0 tclass=filesystem permissive=0 app=io.flutter.plugins.cameraexample
W/System  (15651): A resource failed to call Surface.release.
E/System  (15651): Uncaught exception thrown by finalizer
E/System  (15651): java.util.concurrent.RejectedExecutionException: Task android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy$$ExternalSyntheticLambda0@bdeae47 rejected from java.util.concurrent.ThreadPoolExecutor@8d40674[Terminated, pool size = 0, active threads = 0, queued tasks = 0, completed tasks = 11]
E/System  (15651): 	at java.util.concurrent.ThreadPoolExecutor$AbortPolicy.rejectedExecution(ThreadPoolExecutor.java:2072)
E/System  (15651): 	at java.util.concurrent.ThreadPoolExecutor.reject(ThreadPoolExecutor.java:834)
E/System  (15651): 	at java.util.concurrent.ThreadPoolExecutor.execute(ThreadPoolExecutor.java:1364)
E/System  (15651): 	at java.util.concurrent.Executors$DelegatedExecutorService.execute(Executors.java:644)
E/System  (15651): 	at android.hardware.camera2.impl.CallbackProxies$SessionStateCallbackProxy.onClosed(CallbackProxies.java:104)
E/System  (15651): 	at android.hardware.camera2.impl.CameraCaptureSessionImpl.close(CameraCaptureSessionImpl.java:588)
E/System  (15651): 	at android.hardware.camera2.impl.CameraCaptureSessionImpl.finalize(CameraCaptureSessionImpl.java:894)
E/System  (15651): 	at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:319)
E/System  (15651): 	at java.lang.Daemons$FinalizerDaemon.runInternal(Daemons.java:306)
E/System  (15651): 	at java.lang.Daemons$Daemon.run(Daemons.java:140)
E/System  (15651): 	at java.lang.Thread.run(Thread.java:1012)
I/Camera  (15651): lockAutoFocus
I/Camera  (15651): refreshPreviewCaptureSession
I/Camera  (15651): runPrecaptureSequence
I/Camera  (15651): refreshPreviewCaptureSession
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_START | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 3 | aeState: 3
I/Camera  (15651): captureStillPicture
D/Camera  (15651): Updating builder with feature: ExposureLockFeature
D/Camera  (15651): Updating builder with feature: ExposurePointFeature
D/Camera  (15651): Updating builder with feature: ZoomLevelFeature
D/Camera  (15651): Updating builder with feature: AutoFocusFeature
D/Camera  (15651): Updating builder with feature: NoiseReductionFeature
I/Camera  (15651): updateNoiseReduction | currentSetting: fast
D/Camera  (15651): Updating builder with feature: FocusPointFeature
D/Camera  (15651): Updating builder with feature: ResolutionFeature
D/Camera  (15651): Updating builder with feature: SensorOrientationFeature
D/Camera  (15651): Updating builder with feature: FlashFeature
D/Camera  (15651): Updating builder with feature: ExposureOffsetFeature
D/Camera  (15651): Updating builder with feature: FpsRangeFeature
I/Camera  (15651): sending capture request
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
I/Camera  (15651): onImageAvailable
I/Camera  (15651): unlockAutoFocus
I/Camera  (15651): refreshPreviewCaptureSession
I/Camera  (15651): unlockAutoFocus
I/Camera  (15651): refreshPreviewCaptureSession
I/Camera  (15651): refreshPreviewCaptureSession
I/Camera  (15651): lockAutoFocus
I/Camera  (15651): refreshPreviewCaptureSession
I/Camera  (15651): runPrecaptureSequence
I/Camera  (15651): refreshPreviewCaptureSession
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_START | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_WAITING_PRECAPTURE_DONE | afState: 3 | aeState: 3
I/Camera  (15651): captureStillPicture
D/Camera  (15651): Updating builder with feature: ExposureLockFeature
D/Camera  (15651): Updating builder with feature: ExposurePointFeature
D/Camera  (15651): Updating builder with feature: ZoomLevelFeature
D/Camera  (15651): Updating builder with feature: AutoFocusFeature
D/Camera  (15651): Updating builder with feature: NoiseReductionFeature
I/Camera  (15651): updateNoiseReduction | currentSetting: fast
D/Camera  (15651): Updating builder with feature: FocusPointFeature
D/Camera  (15651): Updating builder with feature: ResolutionFeature
D/Camera  (15651): Updating builder with feature: SensorOrientationFeature
D/Camera  (15651): Updating builder with feature: FlashFeature
D/Camera  (15651): Updating builder with feature: ExposureOffsetFeature
D/Camera  (15651): Updating builder with feature: FpsRangeFeature
I/Camera  (15651): sending capture request
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 5 | aeState: 5
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
D/CameraCaptureCallback(15651): CameraCaptureCallback | state: STATE_CAPTURING | afState: 3 | aeState: 3
I/Camera  (15651): onImageAvailable
I/Camera  (15651): unlockAutoFocus
I/Camera  (15651): refreshPreviewCaptureSession
I/Camera  (15651): unlockAutoFocus
I/Camera  (15651): refreshPreviewCaptureSession
I/Camera  (15651): refreshPreviewCaptureSession
Application finished.
Exited

Flutter Doctor output

Doctor output
[✓] Flutter (Channel stable, 3.10.0, on macOS 13.4 22F66 darwin-arm64, locale en-BY)
    • Flutter version 3.10.0 on channel stable at /Users/vodemn/Development/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 84a1e904f4 (4 months ago), 2023-05-09 07:41:44 -0700
    • Engine revision d44b5a94c9
    • Dart version 3.0.0
    • DevTools version 2.23.1

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.2)
    • Android SDK at /Users/vodemn/Library/Android/sdk
    • Platform android-33, build-tools 33.0.2
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 14.2)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 14C18
    • CocoaPods version 1.12.1

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

[✓] Android Studio (version 2022.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 11.0.15+0-b2043.56-8887301)

[✓] VS Code (version 1.81.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.72.0

[✓] Connected device (4 available)
    • Pixel 6 (mobile)  • 192.168.96.106:38813 • android-arm64  • Android 13 (API 33)
    • SM G985F (mobile) • 192.168.96.107:32997 • android-arm64  • Android 13 (API 33)
    • macOS (desktop)   • macos                • darwin-arm64   • macOS 13.4 22F66 darwin-arm64
    • Chrome (web)      • chrome               • web-javascript • Google Chrome 116.0.5845.179

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

Activity

  1. Karthikeyanarla commented on Sep 9, 2023

    @Karthikeyanarla

    What is meant by overexposure?
    Sorry to say. I could not see any difference in your video, at least. Every time. Could you please come again?

  2. rightsaidfred99 commented on Sep 9, 2023

    @rightsaidfred99

    @Karthikeyanarla , the first image will be completely white because the exposure is wrong

  3. added
    in triagePresently being triaged by the triage team
    on Sep 11, 2023
  4. huycozy commented on Sep 11, 2023

    @huycozy
    Member

    Hi @vodemn
    I checked this issue on my device Realme 6, Android 11 but can't see the overexposed as you observed. The EV values are changed a bit between tests but not too much.

    Are you seeing this issue on your all devices in flutter doctor output? (SM G985F, Pixel 6) Which is the device model SM G985F? Do you also see this issue on iOS?

    Also, can you share the EV values between tests in text format here? Your demo gif above is not quite clear. Thank you!

  5. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 11, 2023
  6. vodemn commented on Sep 11, 2023

    @vodemn
    Author

    @huycozy

    • The issue is present only on Pixel 6.
    • SM G985F stands for Samsung Galaxy S20+.
    • No, I wasn't able to test it on the iPhone.
  7. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Sep 11, 2023
  8. huycozy commented on Sep 12, 2023

    @huycozy
    Member

    I can see the issue on Pixel 7, Android 13 as well. The EV values between tests:

    • 6.77 (overexposed)
    • 8.14 (normal)
    • 8.1 (normal)

    I also check this on iPhone 7, iOS 15.7.2 but the issue does not appear. Labeling this issue as a device-specific issue on Android. Thanks!

    Maybe related: #83549

    flutter doctor -v (stable and master)
    [✓] Flutter (Channel stable, 3.13.3, on macOS 13.5 22G74 darwin-x64, locale en-VN)
        • Flutter version 3.13.3 on channel stable at /Users/huynq/Documents/GitHub/flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 2524052335 (32 hours ago), 2023-09-06 14:32:31 -0700
        • Engine revision b8d35810e9
        • Dart version 3.1.1
        • DevTools version 2.25.0
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 32.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-34, build-tools 32.0.0
        • ANDROID_HOME = /Users/huynq/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.0)
        • Xcode at /Applications/Xcode15-beta8.app/Contents/Developer
        • Build 15A5229m
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • 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.6+0-17.0.6b802.4-9586694)
    
    [✓] VS Code (version 1.81.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.70.0
    
    [✓] Connected device (4 available)
        • RMX2001 (mobile) • EUYTFEUSQSRGDA6D                         • android-arm64  • Android 11 (API 30)
        • iPhone (mobile)  • d9a94afe2b649fef56ba0bfeb052f0f2a7dae95e • ios            • iOS 15.7.2 19H218
        • macOS (desktop)  • macos                                    • darwin-x64     • macOS 13.5 22G74 darwin-x64
        • Chrome (web)     • chrome                                   • web-javascript • Google Chrome 116.0.5845.179
    
    [✓] Network resources
        • All expected network resources are available.
    
    • No issues found!
    [!] Flutter (Channel master, 3.14.0-14.0.pre.210, on macOS 13.5 22G74 darwin-x64, locale en-VN)
        • Flutter version 3.14.0-14.0.pre.210 on channel master at /Users/huynq/Documents/GitHub/flutter_master
        ! Warning: `flutter` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        ! Warning: `dart` on your path resolves to /Users/huynq/Documents/GitHub/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/huynq/Documents/GitHub/flutter_master. Consider adding /Users/huynq/Documents/GitHub/flutter_master/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 0d9ea62756 (4 hours ago), 2023-09-10 18:34:24 -0400
        • Engine revision 04d836f695
        • Dart version 3.2.0 (build 3.2.0-134.0.dev)
        • DevTools version 2.27.0
        • 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 32.0.0)
        • Android SDK at /Users/huynq/Library/Android/sdk
        • Platform android-34, build-tools 32.0.0
        • ANDROID_HOME = /Users/huynq/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 14.3)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 14E222b
        • CocoaPods version 1.11.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • 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.6+0-17.0.6b802.4-9586694)
    
    [✓] VS Code (version 1.81.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.70.0
    
    [✓] Connected device (3 available)
        • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64  • Android 11 (API 30)
        • macOS (desktop)  • macos            • darwin-x64     • macOS 13.5 22G74 darwin-x64
        • Chrome (web)     • chrome           • web-javascript • Google Chrome 116.0.5845.179
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 1 category.
  9. added
    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
    and removed
    in triagePresently being triaged by the triage team
    on Sep 12, 2023
  10. 5 remaining items

  11. reidbaker commented on Sep 18, 2023

    @reidbaker
    Contributor

    Thank you both for trying the camerax plugin and reporting the features that need to be added for you to migrate. Feel free to file features request bugs for camerax so that we have the option of adding the features you need to migrate.

    @camsim99 @mariamhas fyi.

  12. aakarapetyan commented on Dec 8, 2023

    @aakarapetyan

    @reidbaker I tried camera_android_camerax: 0.5.0+18 and yes, it fixed this issue for my Pixel 6.

    But unfortunately, I cannot use this package, as it lacks exposure- and focus-related features.

    We have the same problem. So we really need to migrate to another pub library?

  13. reidbaker commented on Dec 11, 2023

    @reidbaker
    Contributor

    Locking focus is being worked on in flutter/packages#5285 I do not have an update on the exposure related features at this time.

    If you cannot use the camerax implementation and you have this issue you can either submit a pull request to fix the issue in the camera_android implementation or migrate to another pub package. Android camera development is difficult to get right on every camera manufactured and we have made the decision to put our effort into expanding the use of the camerax libraries since that library/team has the focus and mission to make android cameras as reliable as possible.

  14. camsim99 commented on Dec 13, 2023

    @camsim99
    Contributor

    Locking focus is being worked on in flutter/packages#5285 I do not have an update on the exposure related features at this time.

    That PR is related to locking the capture orientation. However, work on exposure & focus controls is in progress and I will update #120468 and #120467 as I move along :)

  15. camsim99 commented on Mar 27, 2024

    @camsim99
    Contributor

    The CameraX implementation of the camera plugin is finished, so we would greatly appreciate it if you try it out to see if it fixes this issue :)

    If you find a similar issue with that implementation (or any other issues), please feel free to file a separate issue.

  16. vodemn commented on Apr 4, 2024

    @vodemn
    Author

    @camsim99 I've rechecked this issue and it still persists

  17. camsim99 commented on Apr 4, 2024

    @camsim99
    Contributor

    @camsim99 I've rechecked this issue and it still persists

    @vodemn To clarify, with the CameraX plugin being used?

  18. vodemn commented on Apr 5, 2024

    @vodemn
    Author

    @camsim99 My bad. I've retested this issue today and everything is fine.

      camera: 0.10.5+2
      camera_android_camerax: 0.6.1+1

    Tested on

    • Pixel 6
    • Samsung S20+
  19. github-actions commented on Apr 22, 2024

    @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.

  20. locked as resolved and limited conversation to collaborators on Apr 22, 2024
  21. moved this to [CONFIRMED] camera_android issues solved by camera_android_camerax in Android Camera Re-writeon Aug 28, 2024
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 liste: device-specificOnly manifests on certain devicesfound in release: 3.13Found to occur in 3.13found in release: 3.14Found to occur in 3.14has 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: solvedIssue is closed as solvedteam-androidOwned by Android platform teamtriaged-androidTriaged by Android platform team

    Type

    No type

    Projects

    • Status
      [CONFIRMED] camera_android issues solved by camera_android_camerax

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions