Bug 38653 - Every second Camera preview blank in iOS8 after Calabash.Start
Summary: Every second Camera preview blank in iOS8 after Calabash.Start
Status: ASSIGNED
Alias: None
Product: iOS
Classification: Xamarin
Component: General (show other bugs)
Version: unspecified
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Future Cycle (TBD)
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2016-02-10 22:42 UTC by Ryan Niebur
Modified: 2017-08-02 13:09 UTC (History)
6 users (show)

See Also:
Tags:
Is this bug a regression?: ---
Last known good build:


Attachments
Example project demonstrating incorrect behavior (34.82 KB, application/zip)
2016-02-10 22:42 UTC, Ryan Niebur
Details
Xamarin Studio Camera Test - Glenn Wilson and Joshua Moody (12.09 KB, application/zip)
2016-05-11 06:52 UTC, Joshua Moody
Details

Description Ryan Niebur 2016-02-10 22:42:28 UTC
Created attachment 14992 [details]
Example project demonstrating incorrect behavior

Hi!

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:
http://stackoverflow.com/questions/19081701/ios-7-uiimagepickercontroller-has-black-preview

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:
https://forums.xamarin.com/discussion/26550/uiimagepickercontroller-show-black-screen-for-every-second-shot

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
Comment 1 Matt Ward 2016-02-10 23:14:16 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?
Comment 2 Ryan Niebur 2016-04-11 20:04:52 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.
Comment 3 Matt Ward 2016-04-13 14:37:20 UTC
I have opened an issue #928 with the UITest team about this.
Comment 4 Joshua Moody 2016-05-03 11:11:19 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.
Comment 5 Matt Ward 2016-05-03 11:35:04 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.
Comment 6 Rolf Bjarne Kvinge [MSFT] 2016-05-09 17:00:50 UTC
@Joshua, can you zip up and attach the XS and Xcode projects you created?
Comment 7 Joshua Moody 2016-05-11 06:52:26 UTC
Created attachment 15964 [details]
Xamarin Studio Camera Test - Glenn Wilson and Joshua Moody
Comment 8 Joshua Moody 2016-05-11 06:53:55 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.
Comment 9 Alex Soto [MSFT] 2016-06-08 19:51:29 UTC
Reopened bug, sample is attached
Comment 10 Rolf Bjarne Kvinge [MSFT] 2016-10-31 15:12:18 UTC
@Joshua, do you have the Objective-C implementation for your test case now?
Comment 11 Joshua Moody 2016-11-02 09:56:02 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.

Note You need to log in before you can comment on or make changes to this bug.