## Every second Camera preview blank in iOS8 after Calabash.Start

_Submitted by a community member on 2016-02-10 22:42 UTC_


Our application uses a UIImagePickerController with SourceType of Camera to allow our users to capture photos in the application.

In versions of iOS 8, a bug causes Camera preview to be black. Some of the potential problems are explained on Stack Overflow:

We noticed the builds that include Calabash would have the blank preview problem every other time a UIImagePickerController is opened. Specifically, the first time the Camera capture is used, the preview will work and the image will be captured successfully. The second time, the preview will be entirely black, but it will still be able to capture the image. It displays black every two previews.

We tracked it down to the following call, which fixes it if removed:
Xamarin.Calabash.Start ();

One person on Xamarin Forums also ran into this with Calabash:

An example “CameraTesting” application that demonstrates the problem described here is attached. If you click to launch the camera twice in a row, the preview will be black the second time.

Removing the Calabash.Start() call at AppDelegate:16 fixes this.

It seems this could be caused by many different problems, but one possibility is interaction with UIKit from a background thread.

Please let me know if any additional information would be helpful.

Thank you,
Ryan Niebur

* * *

_Xamarin Bugzilla comment 1 by Matt Ward [MSFT] on 2016-02-10 23:14 UTC_

Are you distributing builds to users that include Xamarin.Calabash.Start ()? Normally we would expect a release build to distributed to users so that Calabash.Start () is not called since the #if def is only defined for debug builds. Also I believe Apple will reject an app if it calls Calabash.Start.

Or are you trying to use Xamarin.UITest with the camera and the preview is blank and that is causing you a problem with your tests?

* * *

_Xamarin Bugzilla comment 2 by a community member on 2016-04-11 20:04 UTC_

We are not distributing builds with the Calabash.Start call and do not have a problem with our tests because of this, but we were using the same build configuration for manual QA testing and automated tests.

We have added a separate configuration to our builds for UITests to work around this.

We were also concerned what else may be broken by whatever is causing this, as I believe it is a strange interaction to be seeing.

* * *

_Xamarin Bugzilla comment 3 by Matt Ward [MSFT] on 2016-04-13 14:37 UTC_

I have opened an issue #928 with the UITest team about this.

* * *

_Xamarin Bugzilla comment 4 by Joshua Moody [MSFT] on 2016-05-03 11:11 UTC_

Hi Ryan,

We have investigated this issue and found that linking the Calabash/Test Cloud Agent or calling Calabash.Start does not cause this issue.

> In versions of iOS 8, a bug causes Camera preview to be black.

We found that regardless of whether or not Calabash/Test Cloud Agent is linked, the preview window is not visible on every other launch.

We tested against a new solution and the solution that you provided.

We also tested against a native iOS project.  We could not reproduce "missing preview image" in the native iOS project.

We don't know where the problem is, but linking Calabash or the Test Cloud Agent is not the cause.

* * *

_Xamarin Bugzilla comment 5 by Matt Ward [MSFT] on 2016-05-03 11:35 UTC_

@Ryan - Can you attach the information from the Xamarin Studio about dialog - Show Details page?

If the image preview problem does not occur with a native iOS project then it may be a problem with Xamarin.iOS. Reassigning to the iOS team to take a look.

* * *

_Xamarin Bugzilla comment 6 by Rolf Bjarne Kvinge [MSFT] [MSFT] on 2016-05-09 17:00 UTC_

@Joshua, can you zip up and attach the XS and Xcode projects you created?

* * *

_Xamarin Bugzilla comment 7 by Joshua Moody [MSFT] on 2016-05-11 06:52 UTC_

Created attachment 15964
Xamarin Studio Camera Test - Glenn Wilson and Joshua Moody

* * *

_Xamarin Bugzilla comment 8 by Joshua Moody [MSFT] on 2016-05-11 06:53 UTC_

@Rolf I attached the Xamarin Studio solution we used for testing.

The Objective-C implementation will be part of our public test app.  I will add a link once we have pushed the feature to GitHub.

* * *

_Xamarin Bugzilla comment 9 by Alex Soto [MSFT] [MSFT] on 2016-06-08 19:51 UTC_

Reopened bug, sample is attached

* * *

_Xamarin Bugzilla comment 10 by Rolf Bjarne Kvinge [MSFT] [MSFT] on 2016-10-31 15:12 UTC_

@Joshua, do you have the Objective-C implementation for your test case now?

* * *

_Xamarin Bugzilla comment 11 by Joshua Moody [MSFT] on 2016-11-02 09:56 UTC_

@Rolf Not yet.  I think I might have deleted the local branch.  This has a very low priority for the Frameworks team. :/  Apologies.  If you want this to be a priority, please contact Glenn Wilson.

* * *

<br />

_Reference: <https://bugzilla.xamarin.com/show_bug.cgi?id=38653>_