Repository: flutter
Issue: [web] Camera sometimes doesn't start on Chrome
Labels: c: crash,platform-web,platform-linux,p: camera,package,P2,c: parity,browser: chrome-desktop,team-web,triaged-web

## Steps to Reproduce

To reproduce the bug, just call the method "availableCameras()"  from [camera plugin](https://pub.dev/packages/camera)  using Chrome Browser

**Expected results:** 

The expected result is the method running without throwing exceptions and returning a List of CameraDescription

**Actual results:** 
Only in Chrome, an exception is thrown and printed in the browser console.

> CameraException(cameraNotReadable, The camera is not readable due to a hardware error that prevented access to the device.)


**Notes:**
My camera plugin version is **0.10.0**
My chrome version is **104.0.5112.79 (Official Version) 64 bits**
I am using Linux Mint 20.3 "Una" 5.15.0-46-generic
I tested my app in Firefox and it works fine.
I tested it on other site (https://webcamtests.com/) using Chrome and my camera worked normally.

I found an issue from January 2022 (#97016). In this issue, someone posted a link to test the camera using flutter https://cameraweb.netlify.app/#/.

Accessing this link from Chrome, the same exception occurs.
Accessing from Firefox, it works normally.

I debug the availableCameras method line by line and when I debug it this way, the code works, but only if I go line by line.
For me it's like some part of the code is running without waiting for something to finish before continuing, because if I debug line by line calmly, it works.


<details>
<summary>Code sample</summary>

<!--
      Please create a minimal reproducible sample that shows the problem
      and attach it below between the lines with the backticks.

      To create it you can use `flutter create bug` command and update the `main.dart` file.

      Alternatively, you can use https://dartpad.dev/
      which is capable of creating and running small Flutter apps.

      Without this we will unlikely be able to progress on the issue, and because of that
      we regretfully will have to close it.
-->

```dart
_availableCameras = await availableCameras();
cameraController = CameraController(
  _availableCameras!.first,
  ResolutionPreset.medium,
  imageFormatGroup: ImageFormatGroup.jpeg,
);
```

</details>

<details>
  <summary>Logs</summary>

<!--
      Run your application with `flutter run --verbose` and attach all the
      log output below between the lines with the backticks. If there is an
      exception, please see if the error message includes enough information
      to explain how to solve the issue. If there is a crash, please include
      the entirety of the crash log including the backtrace.
-->

```
CameraException(cameraNotReadable, The camera is not readable due to a hardware error that prevented access to the device.)

dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 251:49  throw_
packages/camera_web/src/camera_web.dart 194:7                                 availableCameras
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 60:31            <fn>
dart-sdk/lib/async/zone.dart 1690:54                                          runBinary
dart-sdk/lib/async/future_impl.dart 162:22                                    handleError
dart-sdk/lib/async/future_impl.dart 778:46                                    handleError
dart-sdk/lib/async/future_impl.dart 799:13                                    _propagateToListeners
dart-sdk/lib/async/future_impl.dart 574:5                                     [_completeError]
dart-sdk/lib/async/future_impl.dart 665:7                                     callback
dart-sdk/lib/async/schedule_microtask.dart 40:11                              _microtaskLoop
dart-sdk/lib/async/schedule_microtask.dart 49:5                               _startMicrotaskLoop
dart-sdk/lib/_internal/js_dev_runtime/patch/async_patch.dart 166:15           <fn>
```

<!--
     Run `flutter analyze` and attach any output of that command below.
     If there are any analysis errors, try resolving them before filing this issue.
-->

```
❯ flutter analyze
Analyzing my_app...                                               
No issues found! (ran in 4.3s)
```

<!-- Finally, paste the output of running `flutter doctor -v` here. -->

```
flutter doctor -v 
[✓] Flutter (Channel stable, 3.0.5, on Linux Mint 20.3 5.15.0-46-generic, locale
    pt_BR.UTF-8)
    • Flutter version 3.0.5 at /mnt/Arquivos/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (4 weeks ago), 2022-07-13 11:24:16 -0700
    • Engine revision e85ea0e79c
    • Dart version 2.17.6
    • DevTools version 2.12.2

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0)
    • Android SDK at /mnt/Arquivos/Android/Sdk
    • Platform android-33, build-tools 33.0.0
    • ANDROID_HOME = /mnt/Arquivos/Android/Sdk
    • Java binary at: /mnt/Arquivos/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Chrome - develop for the web
    • Chrome at google-chrome

[✓] Linux toolchain - develop for Linux desktop
    • clang version 10.0.0-4ubuntu1
    • cmake version 3.16.3
    • ninja version 1.10.0
    • pkg-config version 0.29.1

[✓] Android Studio (version 2021.2)
    • Android Studio at /mnt/Arquivos/android-studio
    • Flutter plugin version 67.1.2
    • Dart plugin version 212.5744
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2022.2)
    • IntelliJ at /mnt/Arquivos/idea-IC-212.5457.46
    • Flutter plugin version 69.0.5
    • Dart plugin version 222.3345.108

[✓] VS Code (version 1.70.1)
    • VS Code at /usr/share/code
    • Flutter extension version 3.46.0

[✓] Connected device (3 available)
    • sdk gphone x86 64 arm64 (mobile) • emulator-5554 • android-x64    • Android 11 (API 30) (emulator)
    • Linux (desktop)                  • linux         • linux-x64      • Linux Mint 20.3 5.15.0-46-generic
    • Chrome (web)                     • chrome        • web-javascript • Google Chrome 104.0.5112.79

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```

</details>


<!--
      Consider also attaching screenshots and/or videos to better
      illustrate the issue.

      You can upload them directly on GitHub.
      Beware that video file size is limited to 10MB.
-->