Capture fails after a restart of the camera
See original GitHub issueDescribe the bug Capture doesn’t work after stopping and restarting the camera in release 2.7.0. An error is not generated and the picture taken listener is not invoked. This showed up in this latest release (2.7.0), it doesn’t seem to occur on 2.6.1.
To Reproduce Steps to reproduce the behavior:
- Start camera using
start
- Stop camera using
stop(false)
- Start camera again using
start
- Call
capture
and the dimming UI animation occurs butaddPictureTakenListener
oraddCameraErrorListener
are never called
Expected behavior Calling capture should call either the error listener or the picture taken listener.
Using ProGuard
- with ProGuard
- without ProGuard
Device (please complete the following information):
- Device: S8+
- OS: 8.0.0
- API: 27
- App version 0.1
Branch Name (if using as a local module)
- master
- development
- release
- other (please specify)
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (4 by maintainers)
Top Results From Across the Web
My camera keeps saying camera failed. How do I fix it? - iFixit
- First of all try this: Open Camera app from the "Application manager" and do "Clear data", then restart the phone. - Second:...
Read more >Tethering problems: the camera does not connect, frequently ...
PROBLEM My camera is not connected to Capture One. ... You will have to restart Capture One after changing any of these parameters:....
Read more >How to FIX Media Capture Failed Event Error Code ... - YouTube
00:00 Intro ; 01:13 Enable Camera Access ; 02:05 Run Windows Store Apps Troubleshooter ; 02:50 Update the Camera Driver ; 03:30 Reset...
Read more >How to Fix the “Unfortunately, Camera Has Stopped” Error on ...
When you encounter an Unfortunately, camera has stopped working error, restarting your camera app is the best way to resolve it quickly.
Read more >capturing fails, zoneminder does not restart zmc
In this state, restarting zmc fixes the situation. Restarting the camera doesn't. The zmc process is just repeatedly doing select() and timing ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@arvinkx good catch that was the exact issue. When a scope is created using
CoroutineScope(coroutineContext)
function, it attaches the scope to a newJob
context. So whencoroutineScope.cooutineContext.cancel()
is called it cancels the job and thus no more coroutines can be created using that scope.@pvasa Not really familiar with Kotlin but I believe the issue is related to this block of code in
CameraView.kt
:Once stop is called without removing the listeners, starting the camera again and calling capture in debug mode in the sample app, gets to the line with
pictureTakenListeners
but doesn’t call the block insidelaunch
when breakpoints are set. Hope this helps as I’m not really familiar enough with Kotlin to know why that block is not being called. I also do see this in the debugger:kotlinx.coroutines.JobCancellationException: Job was cancelled; job=JobImpl{Cancelled}@d922855