Repository navigation
Description
Steps to Reproduce
To reproduce the bug, just call the method "availableCameras()" from camera plugin 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.
Code sample
_availableCameras = await availableCameras();
cameraController = CameraController(
_availableCameras!.first,
ResolutionPreset.medium,
imageFormatGroup: ImageFormatGroup.jpeg,
);Logs
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>
❯ flutter analyze
Analyzing my_app...
No issues found! (ran in 4.3s)
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!
Activity
[-]camera plugin not working on Google Chrome[/-][+][web] cannot record videos using camera plugin with Google Chrome[/+]danagbemava-nc commentedon Aug 15, 2022
Hi @Alvarocda, can you provide the complete code sample that you are using? I tested the code sample from the camera package and everything works as expected.
Alvarocda commentedon Aug 15, 2022
Hi @danagbemava-nc
I created a gist with my code with problem
https://gist.github.com/Alvarocda/40c64333cbd93d33158a0d62ae133bec
My webcam model: Microsoft® LifeCam Cinema(TM)
I did some tests with the availableCameras method.
I put several Future.delayeds of 1 second each after each line of the availableCameras method and the camera started to work 100% of the time.
The feeling I have is that it seems that an 'await' is missing inside the availableCameras method, because when I put the Future.delayed it works.
I also made tests on 2 other computers with the same camera, one with linux and the other with Windows.
On the computer with Linux, the same problem happened, on the computer with Windows the camera worked normally.
danagbemava-nc commentedon Aug 16, 2022
Hi @Alvarocda, your sample contains some classes that are not available to us so we cannot run the code. Kindly provide a complete runnable sample so that we can investigate this.
Can you also try the example that comes with the camera package to see whether or not you still reproduce this issue?
Alvarocda commentedon Aug 16, 2022
Hi @danagbemava-nc, I updated the Gist code.
I also tested my gist code along with the example that comes with the camera package, it worked normally.
maheshj01 commentedon Aug 16, 2022
Possible duplicate of #100257
danagbemava-nc commentedon Aug 16, 2022
Hi @Alvarocda, it seems like everything is working properly. Is there anything else for us to do here?
Alvarocda commentedon Aug 16, 2022
I think it's not the same problem, as now I can't even see the camera image.
And as I said, I tested it on 3 different computers, 2 with linux and 1 with Windows using this link: https://cameraweb.netlify.app/#/.
On both computers using Linux the problem happens.
37 remaining items
SittiphanSittisak commentedon Aug 24, 2023
I faced the same issue when I tried to display the camera preview on chrome or edge.
pubspec.yaml
flutter doctor
code
error
codingiswhyicry commentedon Jan 18, 2024
Facing the same issue currently running flutter run -d web-server and accessing through Chrome.
I was using web-server because Chrome was blocking my camera with -d Chrome (#109766).
I have no other applications using my camera based on the fact my web cam light isn't on. However, it only started happening after my Mac used my iPhone camera instead of my web cam, and now that I turned that setting off, it's now showing there's no camera.
Occasionally, it does ask for permission to use my camera, but the camera controller doesn't initialize and doesn't turn the web camera on.
marurur commentedon Feb 10, 2024
I have the same problem
youssefm15 commentedon Dec 2, 2024
Any new updates as still reproducible ?
CubeDr commentedon Dec 15, 2024
+1
Full error:
CubeDr commentedon Dec 15, 2024
For me, it's reproducing 10/10.
I tried with both
flutter run -d chromeandflutter run -d web-serverwithout any luck.No other processes was using the camera at the time.
RoarGronmo commentedon Mar 10, 2025
Are there any working on this issue (or any duplicates of it) ?
It is utterly bad that new models fails in web, but are perfectly well on android native.
lexonli commentedon May 15, 2025
This is still very reproducible on chrome mobile on Android. Any updates?