Repository: flutter
Issue: Camera controller.resume() throws Surface was abandoned in AppLifecycleState.resumed
Labels: c: regression,platform-android,p: camera,package,has reproducible steps,P1,team-android,triaged-android,found in release: 3.24,found in release: 3.26

### What package does this bug report belong to?

camera

### What target platforms are you seeing this bug on?

Android

### Have you already upgraded your packages?

Yes

### Dependency versions

<details><summary>pubspec.lock</summary>

```lock
# Generated by pub
# See https://dart.dev/tools/pub/glossary#lockfile
packages:
  async:
    dependency: transitive
    description:
      name: async
      sha256: "947bfcf187f74dbc5e146c9eb9c0f10c9f8b30743e341481c1e2ed3ecc18c20c"
      url: "https://pub.dev"
    source: hosted
    version: "2.11.0"
  boolean_selector:
    dependency: transitive
    description:
      name: boolean_selector
      sha256: "6cfb5af12253eaf2b368f07bacc5a80d1301a071c73360d746b7f2e32d762c66"
      url: "https://pub.dev"
    source: hosted
    version: "2.1.1"
  camera:
    dependency: "direct main"
    description:
      name: camera
      sha256: "26ff41045772153f222ffffecba711a206f670f5834d40ebf5eed3811692f167"
      url: "https://pub.dev"
    source: hosted
    version: "0.11.0+2"
  camera_android_camerax:
    dependency: transitive
    description:
      name: camera_android_camerax
      sha256: "7cd93578ad201dcc6bb5810451fb00d76a86bab9b68dceb68b8cbd7038ac5846"
      url: "https://pub.dev"
    source: hosted
    version: "0.6.8+3"
  camera_avfoundation:
    dependency: transitive
    description:
      name: camera_avfoundation
      sha256: "7c28969a975a7eb2349bc2cb2dfe3ad218a33dba9968ecfb181ce08c87486655"
      url: "https://pub.dev"
    source: hosted
    version: "0.9.17+3"
  camera_platform_interface:
    dependency: transitive
    description:
      name: camera_platform_interface
      sha256: b3ede1f171532e0d83111fe0980b46d17f1aa9788a07a2fbed07366bbdbb9061
      url: "https://pub.dev"
    source: hosted
    version: "2.8.0"
  camera_web:
    dependency: transitive
    description:
      name: camera_web
      sha256: "595f28c89d1fb62d77c73c633193755b781c6d2e0ebcd8dc25b763b514e6ba8f"
      url: "https://pub.dev"
    source: hosted
    version: "0.3.5"
  characters:
    dependency: transitive
    description:
      name: characters
      sha256: "04a925763edad70e8443c99234dc3328f442e811f1d8fd1a72f1c8ad0f69a605"
      url: "https://pub.dev"
    source: hosted
    version: "1.3.0"
  clock:
    dependency: transitive
    description:
      name: clock
      sha256: cb6d7f03e1de671e34607e909a7213e31d7752be4fb66a86d29fe1eb14bfb5cf
      url: "https://pub.dev"
    source: hosted
    version: "1.1.1"
  collection:
    dependency: transitive
    description:
      name: collection
      sha256: ee67cb0715911d28db6bf4af1026078bd6f0128b07a5f66fb2ed94ec6783c09a
      url: "https://pub.dev"
    source: hosted
    version: "1.18.0"
  cross_file:
    dependency: transitive
    description:
      name: cross_file
      sha256: "7caf6a750a0c04effbb52a676dce9a4a592e10ad35c34d6d2d0e4811160d5670"
      url: "https://pub.dev"
    source: hosted
    version: "0.3.4+2"
  cupertino_icons:
    dependency: "direct main"
    description:
      name: cupertino_icons
      sha256: ba631d1c7f7bef6b729a622b7b752645a2d076dba9976925b8f25725a30e1ee6
      url: "https://pub.dev"
    source: hosted
    version: "1.0.8"
  fake_async:
    dependency: transitive
    description:
      name: fake_async
      sha256: "511392330127add0b769b75a987850d136345d9227c6b94c96a04cf4a391bf78"
      url: "https://pub.dev"
    source: hosted
    version: "1.3.1"
  flutter:
    dependency: "direct main"
    description: flutter
    source: sdk
    version: "0.0.0"
  flutter_lints:
    dependency: "direct dev"
    description:
      name: flutter_lints
      sha256: "3f41d009ba7172d5ff9be5f6e6e6abb4300e263aab8866d2a0842ed2a70f8f0c"
      url: "https://pub.dev"
    source: hosted
    version: "4.0.0"
  flutter_plugin_android_lifecycle:
    dependency: transitive
    description:
      name: flutter_plugin_android_lifecycle
      sha256: "9ee02950848f61c4129af3d6ec84a1cfc0e47931abc746b03e7a3bc3e8ff6eda"
      url: "https://pub.dev"
    source: hosted
    version: "2.0.22"
  flutter_test:
    dependency: "direct dev"
    description: flutter
    source: sdk
    version: "0.0.0"
  flutter_web_plugins:
    dependency: transitive
    description: flutter
    source: sdk
    version: "0.0.0"
  leak_tracker:
    dependency: transitive
    description:
      name: leak_tracker
      sha256: "3f87a60e8c63aecc975dda1ceedbc8f24de75f09e4856ea27daf8958f2f0ce05"
      url: "https://pub.dev"
    source: hosted
    version: "10.0.5"
  leak_tracker_flutter_testing:
    dependency: transitive
    description:
      name: leak_tracker_flutter_testing
      sha256: "932549fb305594d82d7183ecd9fa93463e9914e1b67cacc34bc40906594a1806"
      url: "https://pub.dev"
    source: hosted
    version: "3.0.5"
  leak_tracker_testing:
    dependency: transitive
    description:
      name: leak_tracker_testing
      sha256: "6ba465d5d76e67ddf503e1161d1f4a6bc42306f9d66ca1e8f079a47290fb06d3"
      url: "https://pub.dev"
    source: hosted
    version: "3.0.1"
  lints:
    dependency: transitive
    description:
      name: lints
      sha256: "976c774dd944a42e83e2467f4cc670daef7eed6295b10b36ae8c85bcbf828235"
      url: "https://pub.dev"
    source: hosted
    version: "4.0.0"
  matcher:
    dependency: transitive
    description:
      name: matcher
      sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb
      url: "https://pub.dev"
    source: hosted
    version: "0.12.16+1"
  material_color_utilities:
    dependency: transitive
    description:
      name: material_color_utilities
      sha256: f7142bb1154231d7ea5f96bc7bde4bda2a0945d2806bb11670e30b850d56bdec
      url: "https://pub.dev"
    source: hosted
    version: "0.11.1"
  meta:
    dependency: transitive
    description:
      name: meta
      sha256: bdb68674043280c3428e9ec998512fb681678676b3c54e773629ffe74419f8c7
      url: "https://pub.dev"
    source: hosted
    version: "1.15.0"
  path:
    dependency: transitive
    description:
      name: path
      sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
      url: "https://pub.dev"
    source: hosted
    version: "1.9.0"
  plugin_platform_interface:
    dependency: transitive
    description:
      name: plugin_platform_interface
      sha256: "4820fbfdb9478b1ebae27888254d445073732dae3d6ea81f0b7e06d5dedc3f02"
      url: "https://pub.dev"
    source: hosted
    version: "2.1.8"
  sky_engine:
    dependency: transitive
    description: flutter
    source: sdk
    version: "0.0.99"
  source_span:
    dependency: transitive
    description:
      name: source_span
      sha256: "53e943d4206a5e30df338fd4c6e7a077e02254531b138a15aec3bd143c1a8b3c"
      url: "https://pub.dev"
    source: hosted
    version: "1.10.0"
  stack_trace:
    dependency: transitive
    description:
      name: stack_trace
      sha256: "73713990125a6d93122541237550ee3352a2d84baad52d375a4cad2eb9b7ce0b"
      url: "https://pub.dev"
    source: hosted
    version: "1.11.1"
  stream_channel:
    dependency: transitive
    description:
      name: stream_channel
      sha256: ba2aa5d8cc609d96bbb2899c28934f9e1af5cddbd60a827822ea467161eb54e7
      url: "https://pub.dev"
    source: hosted
    version: "2.1.2"
  stream_transform:
    dependency: transitive
    description:
      name: stream_transform
      sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f"
      url: "https://pub.dev"
    source: hosted
    version: "2.1.0"
  string_scanner:
    dependency: transitive
    description:
      name: string_scanner
      sha256: "556692adab6cfa87322a115640c11f13cb77b3f076ddcc5d6ae3c20242bedcde"
      url: "https://pub.dev"
    source: hosted
    version: "1.2.0"
  term_glyph:
    dependency: transitive
    description:
      name: term_glyph
      sha256: a29248a84fbb7c79282b40b8c72a1209db169a2e0542bce341da992fe1bc7e84
      url: "https://pub.dev"
    source: hosted
    version: "1.2.1"
  test_api:
    dependency: transitive
    description:
      name: test_api
      sha256: "5b8a98dafc4d5c4c9c72d8b31ab2b23fc13422348d2997120294d3bac86b4ddb"
      url: "https://pub.dev"
    source: hosted
    version: "0.7.2"
  vector_math:
    dependency: transitive
    description:
      name: vector_math
      sha256: "80b3257d1492ce4d091729e3a67a60407d227c27241d6927be0130c98e741803"
      url: "https://pub.dev"
    source: hosted
    version: "2.1.4"
  vm_service:
    dependency: transitive
    description:
      name: vm_service
      sha256: "5c5f338a667b4c644744b661f309fb8080bb94b18a7e91ef1dbd343bed00ed6d"
      url: "https://pub.dev"
    source: hosted
    version: "14.2.5"
  web:
    dependency: transitive
    description:
      name: web
      sha256: d43c1d6b787bf0afad444700ae7f4db8827f701bc61c255ac8d328c6f4d52062
      url: "https://pub.dev"
    source: hosted
    version: "1.0.0"
sdks:
  dart: ">=3.5.2 <4.0.0"
  flutter: ">=3.24.0"

```

</details>


### Steps to reproduce

1. Run the app
2. Once the app is initialized and you see the camera preview just pull the notifications bar to trigger didChangeAppLifecycleState
3. come back to the app to trigger didChangeAppLifecycleState again 
4. the camera preview is frozen and in the console you should see Surface was abandoned

### Expected results

The camera preview should be resumed. In the pubspec.lock if you have  camera_android_camerax version: "0.6.8+3" the issue is persistent and happens on all devices. If you switch to "0.6.7+2" its fixed.

### Actual results

The app silent crashes on android level and the camera preview is stuck

### Code sample

<details open><summary>Code sample</summary>

```dart
import 'package:camera/camera.dart';
import 'package:flutter/material.dart';

late List<CameraDescription> _cameras;

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  _cameras = await availableCameras();
  runApp(const CameraApp());
}

class CameraApp extends StatelessWidget {
  const CameraApp({super.key});

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Camera App',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const CameraPage(),
    );
  }
}

class CameraPage extends StatefulWidget {
  /// Default Constructor
  const CameraPage({super.key});

  @override
  State<CameraPage> createState() => _CameraPageState();
}

class _CameraPageState extends State<CameraPage> with WidgetsBindingObserver {
  CameraController? controller;

  @override
  void initState() {
    super.initState();
    WidgetsBinding.instance.addObserver(this);
    initCamera();
  }

  initCamera() async {
    var cameras = await availableCameras();
    controller = CameraController(cameras[0], ResolutionPreset.veryHigh);
    controller?.initialize().then((_) {
      if (!mounted) {
        return;
      }
      setState(() {});
    }).catchError((Object e) {
      if (e is CameraException) {
        switch (e.code) {
          case 'CameraAccessDenied':
            // Handle access errors here.
            break;
          default:
            print(e);
            break;
        }
      }
    });
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    super.didChangeAppLifecycleState(state);

    if (controller == null || !controller!.value.isInitialized) {
      return;
    }

    if (state == AppLifecycleState.inactive) {
      controller?.pausePreview();
    } else if (state == AppLifecycleState.resumed) {
      controller?.resumePreview();
    }
  }

  @override
  void dispose() {
    controller?.dispose();
    WidgetsBinding.instance.removeObserver(this);
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    if (controller == null || !controller!.value.isInitialized) {
      return Container();
    }
    return MaterialApp(
      home: CameraPreview(controller!),
    );
  }
}

```

</details>


### Screenshots or Videos

<details open>
<summary>Screenshots / Video demonstration</summary>

[Screen_recording_20240917_142220.webm](https://github.com/user-attachments/assets/f0bb9cd2-0b9b-4ab0-a2ad-7438f65945ac)


</details>


### Logs

<details open><summary>Logs</summary>

```console
D/CameraStateRegistry( 9840): Recalculating open cameras:
D/CameraStateRegistry( 9840): Camera                                       State                 
D/CameraStateRegistry( 9840): -------------------------------------------------------------------
D/CameraStateRegistry( 9840): Camera@48d314e[id=10]                        UNKNOWN               
D/CameraStateRegistry( 9840): Camera@810b77[id=1]                          OPEN                  
D/CameraStateRegistry( 9840): -------------------------------------------------------------------
D/CameraStateRegistry( 9840): Open count: 1 (Max allowed: 1)
D/CameraStateMachine( 9840): New public camera state CameraState{type=OPEN, error=null} from OPEN and null
D/CameraStateMachine( 9840): Publishing new public camera state CameraState{type=OPEN, error=null}
D/UseCaseAttachState( 9840): All use case: [androidx.camera.core.ImageCapture-37d83db3-143b-4eca-8d2d-efc666438751140185753, androidx.camera.core.Preview-50817409-2990-4cce-8950-506b065c63c99934749, androidx.camera.core.ImageAnalysis-5373193f-b794-47db-a97b-7e7e43e123e8201584447] for camera: 1
D/UseCaseAttachState( 9840): Active and attached use case: [androidx.camera.core.ImageCapture-37d83db3-143b-4eca-8d2d-efc666438751140185753, androidx.camera.core.Preview-50817409-2990-4cce-8950-506b065c63c99934749] for camera: 1
D/SyncCaptureSessionBase( 9840): [androidx.camera.camera2.internal.SynchronizedCaptureSessionBaseImpl@3678b83] getSurface...done
D/CaptureSession( 9840): Opening capture session.
D/DeferrableSurface( 9840): use count+1, useCount=2 androidx.camera.core.SurfaceRequest$2@75b2504
D/DeferrableSurface( 9840): New surface in use[total_surfaces=4, used_surfaces=2](androidx.camera.core.impl.ImmediateSurface@eca796e}
D/DeferrableSurface( 9840): use count+1, useCount=1 androidx.camera.core.impl.ImmediateSurface@eca796e
D/DeferrableSurface( 9840): New surface in use[total_surfaces=4, used_surfaces=3](androidx.camera.core.impl.ImmediateSurface@a8be7a}
D/DeferrableSurface( 9840): use count+1, useCount=1 androidx.camera.core.impl.ImmediateSurface@a8be7a
D/CaptureSession( 9840): Attempting to send capture request onConfigured
D/CaptureSession( 9840): Issuing request for session.
D/Camera2CaptureRequestBuilder( 9840): createCaptureRequest
D/CaptureSession( 9840): CameraCaptureSession.onConfigured() mState=OPENED
D/CaptureSession( 9840): CameraCaptureSession.onReady() OPENED
D/EGL_emulation( 9840): app_time_stats: avg=48.03ms min=10.81ms max=283.63ms count=22
D/EGL_emulation( 9840): app_time_stats: avg=33.92ms min=28.40ms max=50.28ms count=30
D/DeferrableSurface( 9840): surface closed,  useCount=2 closed=true androidx.camera.core.SurfaceRequest$2@75b2504
D/DeferrableSurface( 9840): surface closed,  useCount=0 closed=true androidx.camera.core.processing.SurfaceEdge$SettableSurface@e3aab58
D/DeferrableSurface( 9840): Surface terminated[total_surfaces=3, used_surfaces=3](androidx.camera.core.processing.SurfaceEdge$SettableSurface@e3aab58}
D/DeferrableSurface( 9840): use count-1,  useCount=1 closed=true androidx.camera.core.SurfaceRequest$2@75b2504
D/Camera2CameraImpl( 9840): {Camera@810b77[id=1]} Use cases [androidx.camera.core.Preview-50817409-2990-4cce-8950-506b065c63c99934749] now DETACHED for camera
D/UseCaseAttachState( 9840): All use case: [androidx.camera.core.ImageCapture-37d83db3-143b-4eca-8d2d-efc666438751140185753, androidx.camera.core.ImageAnalysis-5373193f-b794-47db-a97b-7e7e43e123e8201584447] for camera: 1
D/Camera2CameraImpl( 9840): mMeteringRepeating is ATTACHED, SessionConfig Surfaces: 2, CaptureConfig Surfaces: 1
D/UseCaseAttachState( 9840): Active and attached use case: [androidx.camera.core.ImageCapture-37d83db3-143b-4eca-8d2d-efc666438751140185753] for camera: 1
D/CaptureSession( 9840): Attempting to submit CaptureRequest after setting
D/CaptureSession( 9840): Skipping issueRepeatingCaptureRequests for no surface.
D/Camera2CameraImpl( 9840): {Camera@810b77[id=1]} Resetting Capture Session
D/Camera2CameraImpl( 9840): {Camera@810b77[id=1]} Releasing session in state OPENED
D/UseCaseAttachState( 9840): All use case: [androidx.camera.core.ImageCapture-37d83db3-143b-4eca-8d2d-efc666438751140185753, androidx.camera.core.ImageAnalysis-5373193f-b794-47db-a97b-7e7e43e123e8201584447] for camera: 1
D/CaptureSession( 9840): onSessionFinished()
D/SyncCaptureSessionBase( 9840): [androidx.camera.camera2.internal.SynchronizedCaptureSessionBaseImpl@3202a30] getSurface...done
D/CaptureSession( 9840): Opening capture session.
D/DeferrableSurface( 9840): use count+1, useCount=2 androidx.camera.core.impl.ImmediateSurface@eca796e
D/DeferrableSurface( 9840): use count+1, useCount=2 androidx.camera.core.impl.ImmediateSurface@a8be7a
D/EGL_emulation( 9840): app_time_stats: avg=33.59ms min=5.88ms max=68.97ms count=30
D/DeferrableSurface( 9840): use count-1,  useCount=0 closed=true androidx.camera.core.SurfaceRequest$2@75b2504
D/DeferrableSurface( 9840): Surface no longer in use[total_surfaces=3, used_surfaces=2](androidx.camera.core.SurfaceRequest$2@75b2504}
D/DeferrableSurface( 9840): Surface terminated[total_surfaces=2, used_surfaces=2](androidx.camera.core.SurfaceRequest$2@75b2504}
D/DeferrableSurface( 9840): use count-1,  useCount=1 closed=false androidx.camera.core.impl.ImmediateSurface@eca796e
D/DeferrableSurface( 9840): use count-1,  useCount=1 closed=false androidx.camera.core.impl.ImmediateSurface@a8be7a
D/CaptureSession( 9840): Attempting to send capture request onConfigured
D/CaptureSession( 9840): Skipping issueRepeatingCaptureRequests for no surface.
D/CaptureSession( 9840): CameraCaptureSession.onConfigured() mState=OPENED
D/CaptureSession( 9840): CameraCaptureSession.onReady() OPENED
D/CaptureSession( 9840): CameraCaptureSession.onReady() OPENED
D/ProfileInstaller( 9840): Installing profile for com.example.camera_resume_test2
D/CameraOrientationUtil( 9840): getRelativeImageRotation: destRotationDegrees=0, sourceRotationDegrees=270, isOppositeFacing=false, result=270
D/CameraOrientationUtil( 9840): getRelativeImageRotation: destRotationDegrees=0, sourceRotationDegrees=270, isOppositeFacing=false, result=270
D/CameraOrientationUtil( 9840): getRelativeImageRotation: destRotationDegrees=0, sourceRotationDegrees=270, isOppositeFacing=false, result=270
D/DynamicRangeResolver( 9840): Resolved dynamic range for use case androidx.camera.core.Preview-50817409-2990-4cce-8950-506b065c63c9 to no compatible HDR dynamic ranges.
D/DynamicRangeResolver( 9840): DynamicRange@fc0b46c{encoding=UNSPECIFIED, bitDepth=0}
D/DynamicRangeResolver( 9840): ->
D/DynamicRangeResolver( 9840): DynamicRange@329f91f{encoding=SDR, bitDepth=8}
D/EGL_emulation( 9840): app_time_stats: avg=340.82ms min=32.02ms max=1555.65ms count=5
D/CameraOrientationUtil( 9840): getRelativeImageRotation: destRotationDegrees=0, sourceRotationDegrees=270, isOppositeFacing=false, result=270
D/DeferrableSurface( 9840): Surface created[total_surfaces=3, used_surfaces=2](androidx.camera.core.processing.SurfaceEdge$SettableSurface@d55a1e1}
D/DeferrableSurface( 9840): Surface created[total_surfaces=4, used_surfaces=2](androidx.camera.core.SurfaceRequest$2@da97b1d}
D/DeferrableSurface( 9840): New surface in use[total_surfaces=4, used_surfaces=3](androidx.camera.core.SurfaceRequest$2@da97b1d}
D/DeferrableSurface( 9840): use count+1, useCount=1 androidx.camera.core.SurfaceRequest$2@da97b1d
D/CameraOrientationUtil( 9840): getRelativeImageRotation: destRotationDegrees=0, sourceRotationDegrees=270, isOppositeFacing=false, result=270
D/Camera2CameraImpl( 9840): {Camera@810b77[id=1]} Use cases [androidx.camera.core.Preview-50817409-2990-4cce-8950-506b065c63c99934749] now ATTACHED
D/UseCaseAttachState( 9840): All use case: [androidx.camera.core.ImageCapture-37d83db3-143b-4eca-8d2d-efc666438751140185753, androidx.camera.core.ImageAnalysis-5373193f-b794-47db-a97b-7e7e43e123e8201584447, androidx.camera.core.Preview-50817409-2990-4cce-8950-506b065c63c99934749] for camera: 1
D/UseCaseAttachState( 9840): Active and attached use case: [androidx.camera.core.ImageCapture-37d83db3-143b-4eca-8d2d-efc666438751140185753] for camera: 1
D/CaptureSession( 9840): Attempting to submit CaptureRequest after setting
D/CaptureSession( 9840): Skipping issueRepeatingCaptureRequests for no surface.
D/Camera2CameraImpl( 9840): {Camera@810b77[id=1]} Resetting Capture Session
D/Camera2CameraImpl( 9840): {Camera@810b77[id=1]} Releasing session in state OPENED
D/UseCaseAttachState( 9840): All use case: [androidx.camera.core.ImageCapture-37d83db3-143b-4eca-8d2d-efc666438751140185753, androidx.camera.core.ImageAnalysis-5373193f-b794-47db-a97b-7e7e43e123e8201584447, androidx.camera.core.Preview-50817409-2990-4cce-8950-506b065c63c99934749] for camera: 1
D/Camera2CameraImpl( 9840): {Camera@810b77[id=1]} Use case androidx.camera.core.Preview-50817409-2990-4cce-8950-506b065c63c99934749 ACTIVE
D/UseCaseAttachState( 9840): Active and attached use case: [androidx.camera.core.ImageCapture-37d83db3-143b-4eca-8d2d-efc666438751140185753, androidx.camera.core.Preview-50817409-2990-4cce-8950-506b065c63c99934749] for camera: 1
D/CaptureSession( 9840): onSessionFinished()
D/DeferrableSurface( 9840): use count-1,  useCount=0 closed=false androidx.camera.core.impl.ImmediateSurface@eca796e
D/DeferrableSurface( 9840): Surface no longer in use[total_surfaces=4, used_surfaces=2](androidx.camera.core.impl.ImmediateSurface@eca796e}
D/DeferrableSurface( 9840): use count-1,  useCount=0 closed=false androidx.camera.core.impl.ImmediateSurface@a8be7a
D/DeferrableSurface( 9840): Surface no longer in use[total_surfaces=4, used_surfaces=1](androidx.camera.core.impl.ImmediateSurface@a8be7a}
D/SyncCaptureSessionBase( 9840): [androidx.camera.camera2.internal.SynchronizedCaptureSessionBaseImpl@f4c8090] getSurface...done
D/CaptureSession( 9840): Opening capture session.
E/Camera-SurfaceUtils-JNI( 9840): getNativeWindow: Surface had no valid native window.
E/Camera-SurfaceUtils-JNI( 9840): SurfaceUtils_nativeDetectSurfaceDimens: Could not retrieve native window from surface.
W/CaptureSession( 9840): Opening session with fail OPENING
W/CaptureSession( 9840): java.lang.IllegalArgumentException: Surface was abandoned
W/CaptureSession( 9840): 	at android.hardware.camera2.utils.SurfaceUtils.getSurfaceSize(SurfaceUtils.java:135)
W/CaptureSession( 9840): 	at android.hardware.camera2.params.OutputConfiguration.<init>(OutputConfiguration.java:563)
W/CaptureSession( 9840): 	at android.hardware.camera2.params.OutputConfiguration.<init>(OutputConfiguration.java:404)
W/CaptureSession( 9840): 	at androidx.camera.camera2.internal.compat.params.OutputConfigurationCompatApi33Impl.<init>(OutputConfigurationCompatApi33Impl.java:37)
W/CaptureSession( 9840): 	at androidx.camera.camera2.internal.compat.params.OutputConfigurationCompat.<init>(OutputConfigurationCompat.java:64)
W/CaptureSession( 9840): 	at androidx.camera.camera2.internal.CaptureSession.getOutputConfigurationCompat(CaptureSession.java:406)
W/CaptureSession( 9840): 	at androidx.camera.camera2.internal.CaptureSession.openCaptureSession(CaptureSession.java:331)
W/CaptureSession( 9840): 	at androidx.camera.camera2.internal.CaptureSession.lambda$open$0$androidx-camera-camera2-internal-CaptureSession(CaptureSession.java:231)
W/CaptureSession( 9840): 	at androidx.camera.camera2.internal.CaptureSession$$ExternalSyntheticLambda1.apply(Unknown Source:8)
W/CaptureSession( 9840): 	at androidx.camera.core.impl.utils.futures.ChainingListenableFuture.run(ChainingListenableFuture.java:203)
W/CaptureSession( 9840): 	at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.workOnQueue(SequentialExecutor.java:231)
W/CaptureSession( 9840): 	at androidx.camera.core.impl.utils.executor.SequentialExecutor$QueueWorker.run(SequentialExecutor.java:173)
W/CaptureSession( 9840): 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
W/CaptureSession( 9840): 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:644)
W/CaptureSession( 9840): 	at java.lang.Thread.run(Thread.java:1012)
D/Camera2CameraImpl( 9840): {Camera@810b77[id=1]} Transitioning camera internal state: OPENED --> OPENED
D/CameraStateMachine( 9840): New public camera state CameraState{type=OPEN, error=StateError{code=4, cause=java.lang.IllegalArgumentException: Surface was abandoned}} from OPEN and StateError{code=4, cause=java.lang.IllegalArgumentException: Surface was abandoned}
D/CameraStateMachine( 9840): Publishing new public camera state CameraState{type=OPEN, error=StateError{code=4, cause=java.lang.IllegalArgumentException: Surface was abandoned}}
```

</details>


### Flutter Doctor output

<details open><summary>Doctor output</summary>

```console


[✓] Flutter (Channel stable, 3.24.2, on macOS 14.3.1 23D60 darwin-arm64, locale en-CZ)
    • Flutter version 3.24.2 on channel stable at /Users/lubomirmolin/Flutter/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 4cf269e36d (2 weeks ago), 2024-09-03 14:30:00 -0700
    • Engine revision a6bd3f1de1
    • Dart version 3.5.2
    • DevTools version 2.37.2

[✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
    • Android SDK at /Users/lubomirmolin/Library/Android/sdk
    • Platform android-34, build-tools 34.0.0
    • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 17.0.10+0-17.0.10b1087.21-11609105)
    • All Android licenses accepted.

[!] Xcode - develop for iOS and macOS
    ✗ Xcode installation is incomplete; a full installation is necessary for iOS and macOS development.
      Download at: https://developer.apple.com/xcode/
      Or install Xcode via the App Store.
      Once installed, run:
        sudo xcode-select --switch /Applications/Xcode.app/Contents/Developer
        sudo xcodebuild -runFirstLaunch
    • CocoaPods version 1.14.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.10+0-17.0.10b1087.21-11609105)

[✓] Connected device (4 available)
    • Active 8 Pro (mobile)       • ACTIVE8PEEA0008006 • android-arm64  • Android 13 (API 33)
    • sdk gphone64 arm64 (mobile) • emulator-5554      • android-arm64  • Android 14 (API 34) (emulator)
    • macOS (desktop)             • macos              • darwin-arm64   • macOS 14.3.1 23D60 darwin-arm64
    • Chrome (web)                • chrome             • web-javascript • Google Chrome 128.0.6613.138

[✓] Network resources
    • All expected network resources are available.

! Doctor found issues in 1 category.
```

</details>