Bug 2352 - MKMapView with MKPinAnnotationView dragging crash due to missing Export _original_setCoordinate
Summary: MKMapView with MKPinAnnotationView dragging crash due to missing Export _orig...
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: XI runtime ()
Version: 5.0
Hardware: Other Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Sebastien Pouliot
URL:
Depends on:
Blocks:
 
Reported: 2011-12-05 19:54 UTC by Justin S.
Modified: 2011-12-07 11:46 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 Justin S. 2011-12-05 19:54:14 UTC
Hi,

MT 5.0.1, MD 2.8.2

I have had to re-export the _original_setCoordinate method in my descendant MKAnnotation as it appears the linker removes the one from MT runtime.

This is similar to the following issue except that I think it is because the linker is removing the fix: https://bugzilla.novell.com/show_bug.cgi?id=686788

To fix I have copied the internal SetCoordinate along with Export attribute into my descendant class, and then applied the Preserve(AllMembers=true) to my class.

E.g.
	[Preserve(AllMembers = true)]
	public partial class PropertyAnnotation : MKAnnotation
	{
		...
		[Export ("_original_setCoordinate:")]
		internal void SetCoordinate (CLLocationCoordinate2D coord)
		{
			this.Coordinate = coord;
		}
		...
	}

Perhaps a Preserve is required on the MT MKAnnotation?

Note: I also had tried with "Do not link" and all that did was cause a crash with no discernible debug information on why it was crashing. Compiling with "Link SDK" then showed helpful exception information along with a break point.

Regards,
Justin
Comment 1 Sebastien Pouliot 2011-12-05 20:29:26 UTC
There's likely something else because "Do not link" should not crash if this was only linker related. I'll look into it. Thanks
Comment 2 Justin S. 2011-12-05 21:14:38 UTC
Would it make sense to have the "Export" attribute also apply the same behaviour as the "Preserve" attribute for those fields (if it isn't already)?
Comment 3 Justin S. 2011-12-05 21:16:15 UTC
Yes it probably is a different error for the "Do not link". If you require something to reproduce that one let me know and I'll see if I can get an example for it.
Comment 4 Sebastien Pouliot 2011-12-05 21:43:29 UTC
WRT [Export], no since it would effectively disable linking monotouch.dll adding megabytes to many applications. But there are already rules to avoid removing required [Export]. Anyway first thing is to figure out why it crash without linking - it definitively should not. Once that's identified the linker issue, if it still exists, will likely be easy to pin down.

I'll try to duplicate the issue with the original test case (which is helpful if it was a regression). If I can't duplicate either case (linked or non-linked) then I'll contact you. Thanks!
Comment 5 Sebastien Pouliot 2011-12-06 09:25:43 UTC
I can't duplicate a crash without linking (using the old sample). Could you provide me a sample that does so ?
Comment 6 Sebastien Pouliot 2011-12-07 11:46:00 UTC
That member will now be preserved by MonoTouch (if the type is used) since it's called from ObjectiveC and out of the linker reach. In the mean time your workaround is fine.

Please open a new bug report if you can duplicate (and attach a test case for) the crash that occurs without linking - it's unrelated to this case. Thanks!