cordova-plugin-camera-preview: Closing very slow

When I call stopCamera() on iOS, there’s about a 10-second delay where the camera image is still visible, and the rest of the app is frozen.

In Xcode, the last log entry when it freezes is:

2015-03-05 11:39:36.886 Investor[8271:1333954] Stopping session

and the first entry after it hides the window is:

2015-03-05 11:39:45.933 Investor[8271:1333841] THREAD WARNING: ['CameraPreview'] took '9047.212891' ms. Plugin should use a background thread.

About this issue

  • Original URL
  • State: closed
  • Created 9 years ago
  • Reactions: 3
  • Comments: 18 (5 by maintainers)

Commits related to this issue

Most upvoted comments

This is easier to reproduce if I start the camera, switch to the back-facing camera, then stop the camera. I can only reproduce it on a real device; not a simulator.

I notice that it’s calling [self.sessionManager.session stopRunning] twice:

  • In CameraPreview’s stopCamera method, it first removes the view. This causes CameraRenderController’s viewWillDisappear method to be called, which calls stopRunning.
  • Then the stopCamera method calls stopRunning directly.

This second call seems to cause the delay. If I comment it out, I don’t see the delay. But I don’t know if this would have any other side-effects. What do you think?

I’ve tried every suggestion here, including @jacobweber 's and using the latest from master. Nothing has made any difference. @shadowjohn – I don’t understand your comment. Is there some change in the code you’ve pasted? It looks the same as what is in the package.

Has this really been resolved for others? Even with the current master?