Bug 7069 - CBCentralManagerDelegate RetrievedConnectedPeripherals issues
Summary: CBCentralManagerDelegate RetrievedConnectedPeripherals issues
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 5.4.x
Hardware: Macintosh Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2012-09-11 11:51 UTC by Josh
Modified: 2012-09-12 12:07 UTC (History)
2 users (show)

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


Attachments
fixed monotouch.dll (3.45 MB, application/octet-stream)
2012-09-12 12:07 UTC, Sebastien Pouliot
Details


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 Josh 2012-09-11 11:51:56 UTC
I see two issues in the CoreBluetooth api in MT. 

1. I am subclassing CBCentralManagerDelegate for some Bluetooth work and I see that there is a RetrievedConnectedPeripherals method that takes in a CBPeripheral named "peripherals". I believe that this should actually take in a CBPeripheral[] just as the Objective C implementation does and just as the MT RetrievedPeripherals method does on the same class. 

2. I invoke RetrieveConnectedPeripherals() on my CBCentralManager and I do get a callback in my RetrievedConnectedPeripherals method on my CBCentralManagerDelegate--and the peripherals parameter is not null (even though I'm not connected to anything). But it is also not exactly empty either. If I do a Console.WriteLine(peripherals.Name) I get a SIGSEGV crash. 

I'm on the stable branch of MonoDevelop--and I believe I am up-to-date: MonoDevelop 3.0.4.6, XCode 4.4.1, MonoTouch 5.4.0. 

Steps to reproduce:
1. subclass CBCentralManagerDelegate
2. New up a CBCentralManager and give it an instance of your CBCentralManagerDelegate
3. on your CBCentralManager instance, call RetrieveConnectedPeripherals()
4. Add a null check on the peripherals parameter--if it is not null do Console.WriteLine(peripherals.Name);
4. Set a breakpoint inside of RetrievedConnectedPeripherals in your CBCentralManagerDelegate subclass.
5. Notice that peripherals is not null but that you get a on the Console.WriteLine(peripherals.Name) line
Comment 1 Sebastien Pouliot 2012-09-11 13:15:43 UTC
It's a binding bug. The parameter was changed from (the non-strongly typed) NSArray to "CBPeripheral []" for RetrievedPeripherals. However the "[]" was not added for RetrievedConnectedPeripherals.

That's also causing the SIGSEGV later - because the marshaling is based on the (wrong) definition.
Comment 2 Sebastien Pouliot 2012-09-11 13:34:48 UTC
Fixed in
master: 432c360ee6e591b9df9e55bfac389a43989e2e41
monotouch-5.4-series: c58df91b9afb723db9d03c24a703f3c3fe71dc7d

If you wish to try an hotfix just reply to the bug report and I'll attach one once our buildbots have processed the commit.
Comment 3 Josh 2012-09-12 11:56:44 UTC
How would I go about getting this in a hotfix?
Comment 4 Sebastien Pouliot 2012-09-12 12:07:04 UTC
Created attachment 2509 [details]
fixed monotouch.dll

To use the attached assembly (on top of MonoTouch 5.4.0) do:

1) backup your /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll and /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll.mdb files

2) copy (and rename) the attached file to /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll

3) remove the /Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll.mdb symbols (they won't match anymore)

4) clean, rebuild and test your application