Bug 28948 - ImagePicker image preview is black before taking a picture on classic API only
Summary: ImagePicker image preview is black before taking a picture on classic API only
Alias: None
Product: iOS
Classification: Xamarin
Component: General ()
Version: XI 8.8.0
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
Depends on:
Reported: 2015-04-09 15:56 UTC by John Miller [MSFT]
Modified: 2015-04-10 13:46 UTC (History)
2 users (show)

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

Test Case (8.21 KB, application/zip)
2015-04-09 15:56 UTC, John Miller [MSFT]
TestImagePickerController.cs (2.24 KB, application/octet-stream)
2015-04-10 13:45 UTC, Rolf Bjarne Kvinge [MSFT]

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description John Miller [MSFT] 2015-04-09 15:56:29 UTC
Created attachment 10691 [details]
Test Case


   The attached project reproduces an issue where an image picker preview of an image will be all black. This is slightly different than Bug #24098 because it is _before_ a picture is taken. 

**Steps to Reproduce:**

   1. Run the attached sample on an iOS Device (Tested with an iPhone 5s)
   2. Press the button and choose Take a Picture
   3. Capture a photo and press Use Photo
   4. Repeat 2-3 about 3 times or until the preview is black.

**Actual Results:**

   The camera preview will be black. You can still take a photo and that preview will be OK. 

**Expected Results:**

   The live camera preview should not be black. 

**Build Date & Platform:**

   XI 8.8
   Classic API only

**Additional Information:**

   Using the Unified API does not reproduce this.
Comment 1 Rolf Bjarne Kvinge [MSFT] 2015-04-10 08:08:50 UTC
There is no button in the app (it seems to be a Photo filter extension, with a dummy app; did you attach the correct test case?)
Comment 2 John Miller [MSFT] 2015-04-10 09:39:21 UTC

Yes, this is the correct project. Are you sure you opened the correct solution? 
This is what I am seeing: http://screencast.com/t/OLx3slmty
Comment 4 Rolf Bjarne Kvinge [MSFT] 2015-04-10 13:45:06 UTC
Created attachment 10715 [details]

OK, my bad, I somehow managed to open the wrong folder.

This is an iOS bug, I can reproduce it with an Xcode project. The problem is the viewController argument to the [Did|Will]ShowViewController events - when ObjC calls us for those methods, we'll automatically create a ViewController instance for the argument, which lives until the next GC, but somehow the UIImagePickerController expects those view controllers to be freed timely.

A potential workaround is to not use any events, but the Delegate property instead (see attached TestImagePickerViewController.cs for an example).
Comment 5 Rolf Bjarne Kvinge [MSFT] 2015-04-10 13:46:07 UTC
I've also fixed it in Xamarin.iOS so that the workaround won't be required in the future.

maccore/master: 621a8f124193c5a975d363d382556a43309667ea