Bug 13917 - CVPixelFormatDescription.AllTypes crashing due to wrong return type
Summary: CVPixelFormatDescription.AllTypes crashing due to wrong return type
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 6.4.0
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2013-08-12 08:54 UTC by kissling
Modified: 2013-08-12 14:03 UTC (History)
2 users (show)

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

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:
Status:
RESOLVED FIXED

Description kissling 2013-08-12 08:54:57 UTC
The property CVPixelFormatDescription.AllTypes crashes when accessed, as the result type of the corresponding native function is NSNumber[] instead of NSDictionary[].

The corresponding native function is listed here:

https://developer.apple.com/library/ios/documentation/QuartzCore/Reference/CVPixelFormatDescriptionRef/Reference/reference.html#//apple_ref/doc/uid/TP40010034-CH2-SW4

Note that the documentation is wrong. 

Apple states:
An array of Core Foundation dictionaries, each containing a pixel format description. See “Pixel Format Description Keys” for a list of keys relevant to the format description.


However, when invoked and checking the type of the result objects, it is revealed that the NSArray consists of NSNumber which can subsequently be passed to CVPixelFormatDescriptionCreateWithPixelFormatType in order to retrieve additional information.


The following code succeeds, confirming the wrong documentation:

            var types = NSArray.ArrayFromHandle<NSNumber>(CVPixelFormatDescriptionArrayCreateWithAllPixelFormatTypes(IntPtr.Zero));
            foreach (var t in types)
            {
                NSDictionary d = CVPixelFormatDescription.Create(t.IntValue);
                Console.WriteLine(" {0}", d);
            }
Comment 1 Sebastien Pouliot 2013-08-12 09:52:22 UTC
Good catch!
Comment 2 Sebastien Pouliot 2013-08-12 14:03:57 UTC
Fixed in master 7bfbefa3ad135ca6c76a63434d572b71531d2ef2
I reported the documentation issue to Apple.