1
我有一個簡單的類,它反向地理編碼,但它會導致應用崩潰(SIGSEGV
),有時(50%)但不一致。MonoTouch:RequestReverseGeocode崩潰
我已經嘗試在UI線程和後臺線程以及ViewController的生命週期的不同部分運行它,但它似乎是隨機的。沒有太多的應用程序正在發生的事情,當它啓動時,大多隻是通過MonoTouch.Dialog構建UI
MKReverseGeocoder coder;
MyMKReverseGeocoderDelegate myMKReverseGeocoderDelegate;
public void RequestReverseGeocode (CLLocationCoordinate2D coordinate, Action<MKPlacemark> callback)
{
myMKReverseGeocoderDelegate= new MyMKReverseGeocoderDelegate (callback);
coder = new MKReverseGeocoder (coordinate);
coder.Delegate = myMKReverseGeocoderDelegate;
coder.Start();
}
internal class MyCLRequestLocationManagerDelegate : CLLocationManagerDelegate
{
Action<CLLocation> callback;
public MyCLRequestLocationManagerDelegate (Action<CLLocation> callback)
{
this.callback = callback;
}
public override void UpdatedLocation (CLLocationManager manager, CLLocation newLocation, CLLocation oldLocation)
{
manager.StopUpdatingLocation();
locationManager = null;
callback (newLocation);
}
public override void Failed (CLLocationManager manager, NSError error)
{
callback (null);
}
}
崩潰,詳情請看這裏:
at (wrapper managed-to-native) MonoTouch.UIKit.UIApplication.UIApplicationMain
(int,string[],intptr,intptr) <IL 0x0009f, 0xffffffff>
at MonoTouch.UIKit.UIApplication.Main (string[],string,string) [0x00042] in
/Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:29
at MonoTouch.UIKit.UIApplication.Main (string[]) [0x00000] in
/Developer/MonoTouch/Source/monotouch/src/UIKit/UIApplication.cs:34
at AlternativeFuelingStationLocator.Application.Main (string[]) [0x00000] in
/Users/vink/Dropbox/Dev/iOS/UNIVERSAL/DOE/AlternativeFuelingStationLocator/AlternativeFuelingStationLocator/Main.cs:16
at (wrapper runtime-invoke) <Module>.runtime_invoke_void_object
(object,intptr,intptr,intptr) <IL 0x00050, 0xffffffff>
Native stacktrace:
0 AlternativeFuelingStationLocator 0x000e1018
mono_handle_native_sigsegv + 408
1 AlternativeFuelingStationLocator 0x00011d9f
mono_sigsegv_signal_handler + 351
2 libsystem_c.dylib 0x9ad7759b _sigtramp + 43
3 ??? 0xffffffff 0x0 + 4294967295
4 MapKit 0x01e3b4cf MKMapRectRemainder +
101422
5 GeoServices 0x0617f3b8 GEOTileKeyContainsKey +
166198
6 GMM 0x092a3f3d
GEOTileKeyFromGMMTilePath + 31777
7 ProtocolBuffer 0x061dfcf1 ProtocolBuffer + 19697
8 Foundation 0x0192aa59
___NSURLConnectionDidFinishLoading_block_invoke_0 + 40
9 Foundation 0x01928e94
__65-[NSURLConnectionInternal
_withConnectionAndDelegate:onlyActive:]_block_invoke_0 + 40
10 Foundation 0x01929eb7
-[NSURLConnectionInternalConnection invokeForDelegate:] + 39
11 Foundation 0x01928e4f
-[NSURLConnectionInternal _withConnectionAndDelegate:onlyActive:] + 201
12 Foundation 0x01928fd5
-[NSURLConnectionInternal _withActiveConnectionAndDelegate:] + 76
13 Foundation 0x0186df6a
_NSURLConnectionDidFinishLoading + 43
14 CFNetwork 0x00c68bbd
_ZN19URLConnectionClient23_clientDidFinishLoadingEPNS_26ClientConnectionEventQueueE
+ 241
15 CFNetwork 0x00d355ea
_ZN19URLConnectionClient26ClientConnectionEventQueue33processAllEventsAndConsumePayloadEP20XConnectionEventInfoI12XClientEvent18XClientEventParamsEl
+ 584
16 CFNetwork 0x00c5f298
_ZN19URLConnectionClient13processEventsEv + 174
17 CFNetwork 0x00d3516b
_ZThn52_N25URLConnectionInstanceData24multiplexerClientPerformEv + 21
18 CFNetwork 0x00c5f137
_ZN17MultiplexerSource7performEv + 259
19 CoreFoundation 0x012ab97f
__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 15
20 CoreFoundation 0x0120eb73 __CFRunLoopDoSources0 +
243
21 CoreFoundation 0x0120e454 __CFRunLoopRun + 1012
22 CoreFoundation 0x0120ddb4 CFRunLoopRunSpecific +
212
23 CoreFoundation 0x0120dccb CFRunLoopRunInMode + 123
24 GraphicsServices 0x0489f879 GSEventRunModal + 207
25 GraphicsServices 0x0489f93e GSEventRun + 114
26 UIKit 0x022a6a9b UIApplicationMain + 1175
27 ??? 0x0e0b6fcd 0x0 + 235630541
28 ??? 0x0e0b6c18 0x0 + 235629592
29 ??? 0x0e0b6184 0x0 + 235626884
30 ??? 0x0e0b5fdc 0x0 + 235626460
31 ??? 0x0e0b612e 0x0 + 235626798
32 AlternativeFuelingStationLocator 0x00011aef mono_jit_runtime_invoke
+ 1407
33 AlternativeFuelingStationLocator 0x0022011a mono_runtime_invoke +
170
34 AlternativeFuelingStationLocator 0x00222e51 mono_runtime_exec_main +
705
35 AlternativeFuelingStationLocator 0x00222061 mono_runtime_run_main +
929
36 AlternativeFuelingStationLocator 0x000ad6df mono_jit_exec + 239
37 AlternativeFuelingStationLocator 0x002f41ca main + 5194
38 AlternativeFuelingStationLocator 0x00003345 start + 53
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.
代碼看起來沒問題。然而,崩潰在iOS代碼中很深,很可能會嘗試訪問不再可用的內容。這可能與線程/ GC有關,然後你的'回調函數'變得非常重要。一個更大的測試用例可能會有所幫助(你可以在bugzilla.xamarin.com上附上一個測試用例) – poupou
我已經移動了對類變量的所有引用,以便GC不收集。這似乎已修復它。謝謝。 –