question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Capture fails after a restart of the camera

See original GitHub issue

Describe 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:

  1. Start camera using start
  2. Stop camera using stop(false)
  3. Start camera again using start
  4. Call capture and the dimming UI animation occurs but addPictureTakenListener or addCameraErrorListener 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:closed
  • Created 5 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
pvasacommented, Jan 20, 2019

I also do see this in the debugger: kotlinx.coroutines.JobCancellationException: Job was cancelled; job=JobImpl{Cancelled}@d922855

@arvinkx good catch that was the exact issue. When a scope is created using CoroutineScope(coroutineContext) function, it attaches the scope to a new Job context. So when coroutineScope.cooutineContext.cancel() is called it cancels the job and thus no more coroutines can be created using that scope.

0reactions
arvinkxcommented, Jan 18, 2019

@pvasa Not really familiar with Kotlin but I believe the issue is related to this block of code in CameraView.kt:

override fun onPictureTaken(imageData: ByteArray) {
    coroutineScope.launch {
        pictureTakenListeners.forEach {
               it(imageData)
           }
      }
}

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 inside launch 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

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found