Repository: flutter
Issue: [camera_web] `flutter run -d chrome` blocks the camera on the web (Mac host) while `-d web-server` works
Labels: platform-mac,platform-web,p: camera,package,has reproducible steps,P2,c: parity,found in release: 3.0,found in release: 3.1,team-web,triaged-web

## Steps to Reproduce

1. Create a new project 

```bash 
flutter create hello
flutter pub add camera
flutter pub add camera_web
```
2. replace `main.dart` with this [code sample](https://pastelog.netlify.app/logs/5a3d1290-cd90-11ed-92ac-9b39e7f8c6cc)
3. execute `flutter run -d chrome`
4. allow the camera permissions

*expected results*: camera preview loads

*actual results*: camera preview fails to load with a blocked message from chrome

<img src="https://user-images.githubusercontent.com/31410839/185346039-29a4a615-97a4-46a8-938d-4b545053a080.png" width ="300"> 

Reproduces on the latest stable and the master channel on a Mac host and works on a Linux host. 
Also on a Mac running `flutter run -d web-server` enables the camera preview. This could potentially be a regression as it used to work in previous versions of the framework/plugin.

<details>
<summary>code sample (in case the link doesn't work)</summary>

```dart
import 'dart:async';

import 'package:camera/camera.dart';
import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: const CameraScreen(),
    );
  }
}

class CameraScreen extends StatefulWidget {
  const CameraScreen({Key? key}) : super(key: key);

  @override
  _CameraScreenState createState() => _CameraScreenState();
}

class _CameraScreenState extends State<CameraScreen>
    with WidgetsBindingObserver {
  late final CameraScreenController _controller =
      CameraScreenController(context: context);

  @override
  Widget build(BuildContext context) {
    return FutureBuilder<void>(
      future: _controller.initializeCamera(),
      builder: (BuildContext context, AsyncSnapshot<void> snapshot) {
        if (snapshot.connectionState != ConnectionState.done) {
          return const Scaffold(
            body: Text('Loading camera'),
          );
        }
        if (snapshot.hasError) {
          return Scaffold(
            appBar: AppBar(
              title: const Text('Gravação'),
            ),
            body: const Center(
              child: Text(
                'Failed to load camera.',
                textAlign: TextAlign.center,
              ),
            ),
          );
        }
        return Scaffold(
          backgroundColor: Colors.black,
          body: Stack(
            alignment: Alignment.bottomCenter,
            children: <Widget>[
              ValueListenableBuilder<CameraLensDirection>(
                valueListenable: _controller.activeCamera,
                builder: (
                  BuildContext context,
                  CameraLensDirection value,
                  Widget? child,
                ) {
                  return CameraPreview(_controller.cameraController!);
                },
              ),
              Container(
                padding: const EdgeInsets.all(16),
                color: Colors.black38,
                child: Column(
                  mainAxisSize: MainAxisSize.min,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: <Widget>[
                    Row(
                      mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                      children: <Widget>[
                        _toggleFlash(),
                        _startStopRecordButton(),
                        _toggleCameraButton(),
                      ],
                    ),
                  ],
                ),
              ),
            ],
          ),
        );
      },
    );
  }

  Widget _toggleFlash() {
    return InkWell(
      onTap: _controller.toggleFlash,
      child: Card(
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(50),
        ),
        color: Colors.white,
        child: Container(
          height: 65,
          width: 65,
          child: ValueListenableBuilder<FlashMode>(
            valueListenable: _controller.flashMode,
            builder: (
              BuildContext context,
              FlashMode flashMode,
              Widget? child,
            ) {
              return Icon(
                flashMode == FlashMode.off ? Icons.flash_off : Icons.flash_on,
                size: 35,
              );
            },
          ),
        ),
      ),
    );
  }

  Widget _toggleCameraButton() {
    return InkWell(
      onTap: _controller.toggleCamera,
      child: Card(
        shape: RoundedRectangleBorder(
          borderRadius: BorderRadius.circular(50),
        ),
        color: Colors.white,
        child: Container(
          height: 65,
          width: 65,
          child: const Icon(
            Icons.switch_camera,
            size: 35,
          ),
        ),
      ),
    );
  }

  Widget _startStopRecordButton() {
    return InkWell(
      onTap: _controller.startStopRecord,
      child: ValueListenableBuilder<bool>(
        valueListenable: _controller.recording,
        builder: (BuildContext context, bool value, Widget? child) {
          return Card(
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(50),
            ),
            color: value ? Colors.white : Colors.red,
            child: Container(
              height: 95,
              width: 95,
              child: Icon(
                value ? Icons.stop : Icons.play_arrow,
                color: value ? Colors.black : Colors.white,
              ),
            ),
          );
        },
      ),
    );
  }

  @override
  void dispose() {
    _controller.dispose();
    super.dispose();
  }

  @override
  void didChangeAppLifecycleState(AppLifecycleState state) {
    CameraController cameraController = _controller.cameraController!;

    if (!cameraController.value.isInitialized) {
      return;
    }
    if (state == AppLifecycleState.inactive) {
      cameraController.dispose();
    } else if (state == AppLifecycleState.resumed) {
      _controller.initializeCamera(
          cameraDescription: cameraController.description);
    }
  }
}

class CameraScreenController {
  final BuildContext context;
  CameraController? cameraController;
  List<CameraDescription>? _availableCameras;
  final ValueNotifier<CameraLensDirection> activeCamera =
      ValueNotifier<CameraLensDirection>(CameraLensDirection.back);
  final ValueNotifier<Duration> recordDuration =
      ValueNotifier<Duration>(Duration.zero);
  final ValueNotifier<bool> recording = ValueNotifier<bool>(false);
  Timer? _timerGravacao;
  final ValueNotifier<FlashMode> flashMode =
      ValueNotifier<FlashMode>(FlashMode.off);

  CameraScreenController({
    required this.context,
  });
  Future<void> initializeCamera({CameraDescription? cameraDescription}) async {
    _availableCameras ??= await availableCameras();
    cameraController = CameraController(
      cameraDescription ?? _availableCameras!.first,
      ResolutionPreset.medium,
      imageFormatGroup: ImageFormatGroup.jpeg,
    );

    await cameraController!.initialize();
    if (!kIsWeb) {
      await cameraController!.setFlashMode(FlashMode.off);
    }
    cameraController!.addListener(() {
      recording.value = cameraController!.value.isRecordingVideo;
    });
  }

  Future<void> toggleFlash() async {
    if (cameraController!.value.flashMode == FlashMode.always) {
      await cameraController!.setFlashMode(FlashMode.off);
    } else {
      await cameraController!.setFlashMode(FlashMode.always);
    }
    flashMode.value = cameraController!.value.flashMode;
  }

  Future<void> toggleCamera() async {
    if (!recording.value) {
      CameraLensDirection camera = activeCamera.value;
      if (activeCamera.value == CameraLensDirection.back) {
        await initializeCamera(cameraDescription: _availableCameras!.last);
        camera = _availableCameras!.last.lensDirection;
      } else {
        await initializeCamera(cameraDescription: _availableCameras!.first);
        camera = _availableCameras!.first.lensDirection;
      }
      activeCamera.value = camera;
    }
  }

  Future<void> startStopRecord() async {
    recording.value = cameraController!.value.isRecordingVideo;
    if (recording.value) {
      XFile xfile = await cameraController!.stopVideoRecording();
      _timerGravacao?.cancel();
      Navigator.of(context).pop(xfile);
    } else {
      await cameraController!.startVideoRecording();
      int miliSegundos = 0;
      _timerGravacao =
          Timer.periodic(const Duration(milliseconds: 100), (Timer timer) {
        miliSegundos += 100;
        recordDuration.value = Duration(milliseconds: miliSegundos);
      });
    }
  }

  void dispose() {
    cameraController?.dispose();
    _timerGravacao?.cancel();
    recording.dispose();
    recordDuration.dispose();
    flashMode.dispose();
  }
}

```
</details> 

<details>
<summary>flutter doctor -v (mac)</summary>

```
[✓] Flutter (Channel stable, 3.0.5, on macOS 12.4 21F79 darwin-arm, locale en-IN)
    • Flutter version 3.0.5 at /Users/mahesh/Documents/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (5 days 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-rc4)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-32, build-tools 33.0.0-rc4
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.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 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5080.8

[✓] VS Code (version 1.67.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.44.0

[✓] Connected device (3 available)
    • sdk gphone arm64 (mobile) • emulator-5554 • android-arm64  • Android 11 (API 30) (emulator)
    • macOS (desktop)           • macos         • darwin-arm64   • macOS 12.4 21F79 darwin-arm
    • Chrome (web)              • chrome        • web-javascript • Google Chrome 103.0.5060.114

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```

```
[✓] Flutter (Channel master, 3.1.0-0.0.pre.2186, on macOS 12.4 21F79 darwin-arm, locale en-IN)
    • Flutter version 3.1.0-0.0.pre.2186 on channel master at
      /Users/mahesh/Documents/flutter_master
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision 458c7b9c65 (8 days ago), 2022-08-10 03:19:07 -0400
    • Engine revision 75e17f1a6f
    • Dart version 2.19.0 (build 2.19.0-81.0.dev)
    • DevTools version 2.16.0

[✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0-rc4)
    • Android SDK at /Users/mahesh/Library/Android/sdk
    • Platform android-32, build-tools 33.0.0-rc4
    • ANDROID_HOME = /Users/mahesh/Library/Android/sdk
    • Java binary at: /Applications/Android Studio.app/Contents/jre/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 11.0.12+0-b1504.28-7817840)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.2.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13C100
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 2021.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 11.0.12+0-b1504.28-7817840)

[✓] IntelliJ IDEA Community Edition (version 2021.2.1)
    • IntelliJ at /Applications/IntelliJ IDEA CE.app
    • Flutter plugin version 61.2.4
    • Dart plugin version 212.5080.8

[✓] VS Code (version 1.69.2)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.46.0

[✓] Connected device (2 available)
    • macOS (desktop) • macos  • darwin-arm64   • macOS 12.4 21F79 darwin-arm
    • Chrome (web)    • chrome • web-javascript • Google Chrome 104.0.5112.79

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```
</details>


<details>
<summary>flutter doctor -v (Linux)</summary>

```
[✓] Flutter (Channel stable, 3.0.5, on Ubuntu 20.04.4 LTS 5.13.0-48-generic, locale en_GB.UTF-8)
    • Flutter version 3.0.5 at /home/mahesh/Development/stable
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision f1875d570e (5 days 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 31.0.0)
    • Android SDK at /home/mahesh/Android/Sdk
    • Platform android-31, build-tools 31.0.0
    • Java binary at:
      /home/mahesh/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/212.5712.43.2112.8609683/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 /home/mahesh/.local/share/JetBrains/Toolbox/apps/AndroidStudio/ch-0/212.5712.43.2112.8609683
    • 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 Ultimate Edition (version 2022.1)
    • IntelliJ at /home/mahesh/.local/share/JetBrains/Toolbox/apps/IDEA-U/ch-0/221.5921.22
    • 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

[✓] VS Code (version 1.68.0)
    • VS Code at /usr/share/code
    • Flutter extension version 3.44.0

[✓] Connected device (2 available)
    • Linux (desktop) • linux  • linux-x64      • Ubuntu 20.04.4 LTS 5.13.0-48-generic
    • Chrome (web)    • chrome • web-javascript • Google Chrome 102.0.5005.115

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!
```
</details>