Skip to content

[camera_web] availableCameras throws cameraNotReadable when one video device cannot be opened (e.g. OBS Virtual Camera) #194184

Closed
flutter/packages
#13196

Description

@Anfet

Steps to reproduce

  1. Windows 10 with a working webcam and OBS Studio installed (it registers a DirectShow filter OBS Virtual Camera). Do not start OBS or its virtual camera. Any other camera that is listed by the browser but cannot be opened behaves the same way.
  2. Create an app that depends on camera: ^0.11.0+2 and run it in Chrome (flutter run -d chrome).
  3. Call availableCameras() and grant the camera permission.

Expected results

availableCameras() returns the cameras that can be used (here: the integrated webcam). A device that cannot be opened is skipped.

Actual results

availableCameras() throws CameraException(cameraNotReadable, The camera is not readable due to a hardware error that prevented access to the device.). No camera is returned, although the integrated webcam works.

Cause

In camera_web availableCameras() calls getUserMedia({video: {deviceId: {exact: id}}}) for every video input device (_getVideoStreamForDevice, in the for (final videoInputDevice in videoInputDevices) loop). The only try/catch surrounds the whole method. In Chrome the OBS Virtual Camera device rejects with NotReadableError: Could not start video source. This becomes a CameraWebException that exits the loop, so one unreadable device hides all the others.

The structure is the same in every version I checked (0.3.1+3, 0.3.1+4, 0.3.2+3, 0.3.3, 0.3.4, 0.3.5, 0.3.5+6).

A page with plain navigator.mediaDevices.getUserMedia confirms it, without Flutter:

  • getUserMedia({video: true}) succeeds (Integrated Webcam);
  • getUserMedia({video: {deviceId: {exact: <integrated webcam id>}}}) succeeds;
  • getUserMedia({video: {deviceId: {exact: <OBS Virtual Camera id>}}}) fails with NotReadableError: Could not start video source.

Suggested fix

Handle a failure per device inside the loop and continue with the next device; throw only when no device could be opened (or return an empty list).

Environment

  • camera_web 0.3.5+6 via camera 0.11.x, Flutter 3.44.9 (stable), Windows 10, Chrome 154.0.8037.98.

Activity

  1. puneetkukreja98 commented on Oct 12, 2026

    @puneetkukreja98
    Contributor

    @Anfet Thanks for reporting it, I was able to reproduce it, after installing OBS studio from Microsoft store.
    camera: ^0.12.1

    Sample code:

    import 'package:flutter/material.dart';
    import 'package:camera/camera.dart';
    
    void main() {
      runApp(const MaterialApp(home: CameraReproPage()));
    }
    
    class CameraReproPage extends StatefulWidget {
      const CameraReproPage({super.key});
    
      @override
      State<CameraReproPage> createState() => _CameraReproPageState();
    }
    
    class _CameraReproPageState extends State<CameraReproPage> {
      String _status = 'Tap below to check available cameras.';
      List<CameraDescription> _cameras = [];
      bool _isLoading = false;
    
      Future<void> _fetchCameras() async {
        setState(() {
          _isLoading = true;
          _status = 'Fetching available cameras...';
        });
    
        try {
          final cameras = await availableCameras();
          setState(() {
            _cameras = cameras;
            _status =
                'Found ${cameras.length} camera(s):\n' +
                cameras.map((c) => '• ${c.name} (${c.lensDirection})').join('\n');
          });
        } on CameraException catch (e) {
          setState(() {
            _status =
                'CameraException caught:\n'
                'Code: ${e.code}\n'
                'Description: ${e.description}';
          });
        } catch (e) {
          setState(() {
            _status = 'Unexpected error: $e';
          });
        } finally {
          setState(() {
            _isLoading = false;
          });
        }
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(title: const Text('Camera Web Repro')),
          body: Center(
            child: Padding(
              padding: const EdgeInsets.all(24.0),
              child: Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  if (_isLoading)
                    const CircularProgressIndicator()
                  else
                    ElevatedButton(
                      onPressed: _fetchCameras,
                      child: const Text('Get Available Cameras'),
                    ),
                  const SizedBox(height: 24),
                  SelectableText(
                    _status,
                    textAlign: TextAlign.center,
                    style: const TextStyle(fontSize: 16),
                  ),
                ],
              ),
            ),
          ),
        );
      }
    }
    

    Screen-shot:

    Image

    flutter doctor -v:

    [√] Flutter (Channel stable, 3.47.7, on Microsoft Windows [Version 10.0.26200.9457], locale en-IN) [572ms]
        • Flutter version 3.47.7 on channel stable at C:\Developer\flutter
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision abaf9c5237 (4 days ago), 2026-10-08 09:51:21 -0700
        • Engine revision deb287481e
        • Dart version 3.13.5
        • DevTools version 2.60.0
        • Feature flags: enable-web, enable-linux-desktop, enable-macos-desktop, enable-windows-desktop, enable-android, enable-ios, cli-animations,
          enable-native-assets, enable-record-use, enable-swift-package-manager, omit-legacy-version-file, enable-lldb-debugging, enable-uiscene-migration
    
    [√] Windows Version (Windows 11 or higher, 25H2, 2009) [3.1s]
    
    [√] Android toolchain - develop for Android devices (Android SDK version 37.0.0) [4.6s]
        • Android SDK at C:\Users\Puneet\AppData\Local\Android\sdk
        • Emulator version 36.6.11.0 (build_id 15507667) (CL:N/A)
        • Platform android-37.1, build-tools 37.0.0
        • Java binary at: C:\Program Files\Android\Android Studio1\jbr\bin\java
          This is the JDK bundled with the latest Android Studio installation on this machine.
          To manually set the JDK path, use: `flutter config --jdk-dir="path/to/jdk"`.
        • Java version OpenJDK Runtime Environment (build 21.0.10+-14961533-b1163.108)
        • All Android licenses accepted.
    
    [√] Chrome - develop for the web [277ms]
        • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe
    
    [√] Visual Studio - develop Windows apps (Visual Studio Community 2026 18.3.2) [276ms]
        • Visual Studio at C:\Program Files\Microsoft Visual Studio\18\Community
        • Visual Studio Community 2026 version 18.3.11520.95
        • Windows 10 SDK version 10.0.26100.0
    
    [√] Connected device (3 available) [363ms]
        • Windows (desktop) • windows • windows-x64    • Microsoft Windows [Version 10.0.26200.9457]
        • Chrome (web)      • chrome  • web-javascript • Google Chrome 155.0.8059.40
        • Edge (web)        • edge    • web-javascript • Microsoft Edge 155.0.4283.45
    
    [√] Network resources [886ms]
        • All expected network resources are available.
    
    • No issues found!
  2. puneetkukreja98 commented on Oct 12, 2026

    @puneetkukreja98
    Contributor

    Similar issues:
    #97016
    #109453

  3. added
    packageflutter/packages repository. See also p: labels.
    team-webOwned by Web platform team
    fyi-ecosystemFor the attention of Ecosystem team
    platform-webWeb applications specifically
    and removed
    in triagePresently being triaged by the triage team
    on Oct 12, 2026
  4. added
    triaged-webTriaged by Web platform team
    P1High-priority issues at the top of the work list
    P2Important issues not at the top of the work list
    and removed
    P2Important issues not at the top of the work list
    on Oct 21, 2026
  5. github-actions commented on Nov 10, 2026

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

  6. locked as resolved and limited conversation to collaborators on Nov 10, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

P1High-priority issues at the top of the work listp: cameraThe camera pluginpackageflutter/packages repository. See also p: labels.platform-webWeb applications specificallyteam-webOwned by Web platform teamtriaged-webTriaged by Web platform teamwaiting for PR to land (fixed)A fix is in flight

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions