Hello,
I am trying to create a custom tile layer to work with MapKit, using overlay views provided with the iPhone SDK 4. My work is based on this example here, but adapted to MonoTouch: http://github.com/mtigas/iOS-MapLayerDemo.
I have managed to bring the tile images but when calling SetNeedsDisplay(MKMapRect, float) method of my overlay view the application crashes (only tried on the simulator, debug mode) with a very long stack trace:
Native stacktrace:
0 iNorcRed 0x000bf0ef mono_handle_native_sigsegv + 343
1 iNorcRed 0x0000f26a mono_sigsegv_signal_handler + 313
2 libSystem.B.dylib 0x9793842b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 iNorcRed 0x0027c411 monotouch_x86_double_abi_stret_trampoline + 144
5 MapKit 0x01403a3e -[MKOverlayView setNeedsDisplayInMapRect:zoomScale:] + 129
6 ??? 0x086128b5 0x0 + 140585141
7 ??? 0x08612846 0x0 + 140585030
8 ??? 0x08611b78 0x0 + 140581752
9 ??? 0x0f2c5818 0x0 + 254564376
10 ??? 0x0f2c5479 0x0 + 254563449
11 ??? 0x0f2c545e 0x0 + 254563422
12 ??? 0x086439df 0x0 + 140786143
13 iNorcRed 0x0000f02e mono_jit_runtime_invoke + 1360
14 iNorcRed 0x001c9d2f mono_runtime_invoke + 137
15 iNorcRed 0x0027a423 monotouch_trampoline + 2012
16 UIKit 0x016d77f8 -[UIApplication sendAction:to:from:forEvent:] + 119
17 UIKit 0x018e368b -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 156
18 UIKit 0x016d77f8 -[UIApplication sendAction:to:from:forEvent:] + 119
19 UIKit 0x01762de0 -[UIControl sendAction:to:forEvent:] + 67
20 UIKit 0x01765262 -[UIControl(Internal) _sendActionsForEvents:withEvent:] + 527
21 UIKit 0x01763e0f -[UIControl touchesEnded:withEvent:] + 458
22 UIKit 0x016fb3d0 -[UIWindow _sendTouchesForEvent:] + 567
23 ??? 0x0e3d948d 0x0 + 238916749
24 ??? 0x0f2c48fd 0x0 + 254560509
25 ??? 0x0f2c4657 0x0 + 254559831
26 ??? 0x0e3d8daf 0x0 + 238914991
27 iNorcRed 0x0000f02e mono_jit_runtime_invoke + 1360
28 iNorcRed 0x001c9d2f mono_runtime_invoke + 137
29 iNorcRed 0x0027a423 monotouch_trampoline + 2012
30 UIKit 0x016dccb4 -[UIApplication sendEvent:] + 447
31 UIKit 0x016e19bf _UIApplicationHandleEvent + 7672
32 GraphicsServices 0x053b4822 PurpleEventCallback + 1550
33 CoreFoundation 0x007b5ff4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 52
34 CoreFoundation 0x00716807 __CFRunLoopDoSource1 + 215
35 CoreFoundation 0x00713a93 __CFRunLoopRun + 979
36 CoreFoundation 0x00713350 CFRunLoopRunSpecific + 208
37 CoreFoundation 0x00713271 CFRunLoopRunInMode + 97
38 GraphicsServices 0x053b300c GSEventRunModal + 217
39 GraphicsServices 0x053b30d1 GSEventRun + 115
40 UIKit 0x016e5af2 UIApplicationMain + 1160
41 ??? 0x0864f3f1 0x0 + 140833777
42 ??? 0x0864e8ba 0x0 + 140830906
43 ??? 0x0864e780 0x0 + 140830592
44 ??? 0x0864e7dc 0x0 + 140830684
45 iNorcRed 0x0000f02e mono_jit_runtime_invoke + 1360
46 iNorcRed 0x001c9d2f mono_runtime_invoke + 137
47 iNorcRed 0x001cb9eb mono_runtime_exec_main + 714
48 iNorcRed 0x001cb311 mono_runtime_run_main + 812
49 iNorcRed 0x00095e14 mono_jit_exec + 200
50 iNorcRed 0x00003ab7 main + 3475
51 iNorcRed 0x00002b09 _start + 208
52 iNorcRed 0x00002a38 start + 40
53 ??? 0x00000002 0x0 + 2
Debug info from gdb:
warning: Could not find object file "/var/folders/7H/7HdwBrBrFGO0dBExvYpYO++++TI/-Tmp-/tmp13f750a5.tmp/main.o" - no debug information available for "/var/folders/7H/7HdwBrBrFGO0dBExvYpYO++++TI/-Tmp-/tmp13f750a5.tmp/main.m".
Error connecting stdout and stderr (127.0.0.1:10001)
Attaching to process 1416.
Reading symbols for shared libraries . done
Reading symbols for shared libraries ........................................................................................................... done
0x978dd619 in read$UNIX2003 ()
9 0x978f1286 in select$DARWIN_EXTSN ()
8 0x978d22fa in mach_msg_trap ()
7 0x978d22fa in mach_msg_trap ()
6 "WebThread" 0x978d22fa in mach_msg_trap ()
5 0x97900262 in __semwait_signal ()
4 0x978d2336 in semaphore_wait_trap ()
3 0x978d22fa in mach_msg_trap ()
2 "com.apple.libdispatch-manager" 0x978f8b42 in kevent ()
* 1 "com.apple.main-thread" 0x978dd619 in read$UNIX2003 ()
Thread 9 (process 1416):
#0 0x978f1286 in select$DARWIN_EXTSN ()
#1 0x00747b5e in __CFSocketManager ()
#2 0x978ffa19 in _pthread_start ()
#3 0x978ff89e in thread_start ()
Thread 8 (process 1416):
#0 0x978d22fa in mach_msg_trap ()
#1 0x978d2a67 in mach_msg ()
#2 0x007b6436 in __CFRunLoopServiceMachPort ()
#3 0x00713984 in __CFRunLoopRun ()
#4 0x00713350 in CFRunLoopRunSpecific ()
#5 0x00713271 in CFRunLoopRunInMode ()
#6 0x013fc770 in TileCachePrivate::runCacheThread ()
#7 0x013fc783 in _runCacheThread ()
#8 0x978ffa19 in _pthread_start ()
#9 0x978ff89e in thread_start ()
Thread 7 (process 1416):
#0 0x978d22fa in mach_msg_trap ()
#1 0x978d2a67 in mach_msg ()
#2 0x007b6436 in __CFRunLoopServiceMachPort ()
#3 0x00713984 in __CFRunLoopRun ()
#4 0x00713350 in CFRunLoopRunSpecific ()
#5 0x00713271 in CFRunLoopRunInMode ()
#6 0x00b5cb86 in +[NSURLConnection(NSURLConnectionReallyInternal) _resourceLoadLoop:] ()
#7 0x00b2776c in -[NSThread main] ()
#8 0x00b276f8 in __NSThread__main__ ()
#9 0x978ffa19 in _pthread_start ()
#10 0x978ff89e in thread_start ()
Thread 6 (process 1416):
#0 0x978d22fa in mach_msg_trap ()
#1 0x978d2a67 in mach_msg ()
#2 0x007b6436 in __CFRunLoopServiceMachPort ()
#3 0x00713984 in __CFRunLoopRun ()
#4 0x00713350 in CFRunLoopRunSpecific ()
#5 0x00713271 in CFRunLoopRunInMode ()
#6 0x066ba3a3 in RunWebThread ()
#7 0x978ffa19 in _pthread_start ()
#8 0x978ff89e in thread_start ()
Thread 5 (process 1416):
#0 0x97900262 in __semwait_signal ()
#1 0x9792be44 in nanosleep$UNIX2003 ()
#2 0x9792bd82 in usleep$UNIX2003 ()
#3 0x00277bcc in monotouch_pump_gc (context=0x0) at monotouch-glue.m:326
#4 0x978ffa19 in _pthread_start ()
#5 0x978ff89e in thread_start ()
Thread 4 (process 1416):
#0 0x978d2336 in semaphore_wait_trap ()
#1 0x0015b89d in finalizer_thread (unused=0x0) at ../../../../mono/metadata/gc.c:1026
#2 0x00203f23 in start_wrapper (data=0x8513c60) at ../../../../mono/metadata/threads.c:661
#3 0x00245362 in thread_start_routine (args=0x9022834) at ../../../../mono/io-layer/wthreads.c:286
#4 0x00274dd7 in GC_start_routine (arg=0x868af60) at ../../../libgc/pthread_support.c:1390
#5 0x978ffa19 in _pthread_start ()
#6 0x978ff89e in thread_start ()
Thread 3 (process 1416):
#0 0x978d22fa in mach_msg_trap ()
#1 0x978d2a67 in mach_msg ()
#2 0x0011d6c6 in mach_exception_thread (arg=0x0) at ../../../../mono/mini/mini-darwin.c:138
#3 0x978ffa19 in _pthread_start ()
#4 0x978ff89e in thread_start ()
Thread 2 (process 1416):
#0 0x978f8b42 in kevent ()
#1 0x978f925c in _dispatch_mgr_invoke ()
#2 0x978f8719 in _dispatch_queue_invoke ()
#3 0x978f84be in _dispatch_worker_thread2 ()
#4 0x978f7f41 in _pthread_wqthread ()
#5 0x978f7d86 in start_wqthread ()
Thread 1 (process 1416):
#0 0x978dd619 in read$UNIX2003 ()
#1 0x000bf29f in mono_handle_native_sigsegv (signal=11, ctx=0xbfffca00) at ../../../../mono/mini/mini-exceptions.c:1826
#2 0x0000f26a in mono_sigsegv_signal_handler (_dummy=10, info=0xbfffc9c0, context=0xbfffca00) at ../../../../mono/mini/mini.c:4846
#3 <signal handler called>
#4 0xffff07c2 in __memcpy ()
#5 0x0027c411 in monotouch_x86_double_abi_stret_trampoline ()
#6 0x01403a3e in -[MKOverlayView setNeedsDisplayInMapRect:zoomScale:] ()
#7 0x086128b5 in ?? ()
#8 0x08612846 in ?? ()
#9 0x08611b78 in ?? ()
#10 0x0f2c5818 in ?? ()
#11 0x0f2c5479 in ?? ()
#12 0x0f2c545e in ?? ()
#13 0x086439df in ?? ()
#14 0x0000f02e in mono_jit_runtime_invoke (method=0x9197d94, obj=0xaee3dc0, params=0xbfffd050, exc=0x0) at ../../../../mono/mini/mini.c:4733
#15 0x001c9d2f in mono_runtime_invoke (method=0x9197d94, obj=0xaee3dc0, params=0xbfffd050, exc=0x0) at ../../../../mono/metadata/object.c:2615
#16 0x0027a423 in monotouch_trampoline (this=0xf3319a0, sel=0x8584d30) at monotouch-glue.m:571
#17 0x016d77f8 in -[UIApplication sendAction:to:from:forEvent:] ()
#18 0x018e368b in -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] ()
#19 0x016d77f8 in -[UIApplication sendAction:to:from:forEvent:] ()
#20 0x01762de0 in -[UIControl sendAction:to:forEvent:] ()
#21 0x01765262 in -[UIControl(Internal) _sendActionsForEvents:withEvent:] ()
#22 0x01763e0f in -[UIControl touchesEnded:withEvent:] ()
#23 0x016fb3d0 in -[UIWindow _sendTouchesForEvent:] ()
#24 0x0e3d948d in ?? ()
#25 0x0f2c48fd in ?? ()
#26 0x0f2c4657 in ?? ()
#27 0x0e3d8daf in ?? ()
#28 0x0000f02e in mono_jit_runtime_invoke (method=0x91e5e04, obj=0x860df50, params=0xbfffd570, exc=0x0) at ../../../../mono/mini/mini.c:4733
#29 0x001c9d2f in mono_runtime_invoke (method=0x91e5e04, obj=0x860df50, params=0xbfffd570, exc=0x0) at ../../../../mono/metadata/object.c:2615
#30 0x0027a423 in monotouch_trampoline (this=0x85eeb30, sel=0x313eb3d) at monotouch-glue.m:571
#31 0x016dccb4 in -[UIApplication sendEvent:] ()
#32 0x016e19bf in _UIApplicationHandleEvent ()
#33 0x053b4822 in PurpleEventCallback ()
#34 0x007b5ff4 in __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ ()
#35 0x00716807 in __CFRunLoopDoSource1 ()
#36 0x00713a93 in __CFRunLoopRun ()
#37 0x00713350 in CFRunLoopRunSpecific ()
#38 0x00713271 in CFRunLoopRunInMode ()
#39 0x053b300c in GSEventRunModal ()
#40 0x053b30d1 in GSEventRun ()
#41 0x016e5af2 in UIApplicationMain ()
#42 0x0864f3f1 in ?? ()
#43 0x0864e8ba in ?? ()
#44 0x0864e780 in ?? ()
#45 0x0864e7dc in ?? ()
#46 0x0000f02e in mono_jit_runtime_invoke (method=0x91f0a24, obj=0x0, params=0xbfffeedc, exc=0x0) at ../../../../mono/mini/mini.c:4733
#47 0x001c9d2f in mono_runtime_invoke (method=0x91f0a24, obj=0x0, params=0xbfffeedc, exc=0x0) at ../../../../mono/metadata/object.c:2615
#48 0x001cb9eb in mono_runtime_exec_main (method=0x91f0a24, args=0xb01f7d0, exc=0x0) at ../../../../mono/metadata/object.c:3581
#49 0x001cb311 in mono_runtime_run_main (method=0x91f0a24, argc=0, argv=0xbffff014, exc=0x0) at ../../../../mono/metadata/object.c:3355
#50 0x00095e14 in mono_jit_exec (domain=0x8604e58, assembly=0x85a9b00, argc=1, argv=0xbffff010) at ../../../../mono/mini/driver.c:1094
#51 0x00003ab7 in main ()
=================================================================
Got a SIGSEGV while executing native code. This usually indicates
a fatal error in the mono runtime or one of the native libraries
used by your application.
=================================================================
Unhandled Exception: System.NullReferenceException: Object reference not set to an instance of an object
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_MKMapRect_float (intptr,intptr,MonoTouch.MapKit.MKMapRect,single)
at MonoTouch.MapKit.MKOverlayView.SetNeedsDisplay (MKMapRect mapRect, Single zoomScale) [0x00000] in <filename unknown>:0
at iNorcRed.MapStreetViewController.ViewWillAppear (Boolean animated) [0x00000] in <filename unknown>:0
at iNorcRed.MapFlipViewController.Flip () [0x00000] in <filename unknown>:0
at iNorcRed.MapFlipViewController.<ViewDidLoad>m__D (System.Object , System.EventArgs ) [0x00000] in <filename unknown>:0
at MonoTouch.UIKit.UIBarButtonItem+Callback.Call (MonoTouch.Foundation.NSObject sender) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) MonoTouch.ObjCRuntime.Messaging:void_objc_msgSendSuper_IntPtr (intptr,intptr,intptr)
at MonoTouch.UIKit.UIWindow.SendEvent (MonoTouch.UIKit.UIEvent evt) [0x00000] in <filename unknown>:0
at iNorcRed.INorcWindow.SendEvent (MonoTouch.UIKit.UIEvent evt) [0x00000] in <filename unknown>:0
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication:UIApplicationMain (int,string[],intptr,intptr)
at MonoTouch.UIKit.UIApplication.Main (System.String[] args, System.String principalClassName, System.String delegateClassName) [0x00000] in <filename unknown>:0
at iNorcRed.Application.Main (System.String[] args) [0x00000] in <filename unknown>:0
I am using MonoTouch 3.1.3. with iPhone SDK 4.1.
Any help is appreciated.