Select to view content in your preferred language

Crash with NmeaLocationDataSource

447
3
05-31-2022 10:46 AM
JoeHershman
MVP Regular Contributor

Hi, [lets try and write this a second time after GeoNet failed]

We switched over to the NmeaLocationDataSource from our own custom LocationDataSource for collecting from an external iOS device.  Been working great and removed a lot of custom code

But we have gotten a system crash when using the NmeaLocationDataSource.  It has happened both when making initial connection to the unit and once the user is already collecting GPS data.  When it happens while collecting data the user does say they see the LastKnown location indicator (the grey dot).  The stack trace shows occurring in OnStartAsync.  So not sure if it tries to call this again when the connection is dropped.  It seems to me to be an issue with the actual connection between the unit and the iOS device, but possibly is a result of the unit not receiving good data

As much as anything it would be nice to be able to catch the exception so it does not crash the application but I cannot seem to find where one would handle the exception

Thanks

@dotMorten 

Stack trace from crash

NSObject.InitializeHandle (System.IntPtr handle, System.String initSelector) /Users/builder/azdo/_work/2/s/xamarin-macios/src/Foundation/NSObject2.cs:609
/Users/builder/azdo/_work/2/s/xamarin-macios/src/build/ios/native/ExternalAccessory/EASession.g.cs:79
Esri.ArcGISRuntime.Location.NmeaLocationDataSource+EAAccessoryStream..ctor (ExternalAccessory.EAAccessory accessory, System.String protocol) [0x0000d] in <fc2ff9f8183b4871b39c22ae8fb2d60c>:0
NmeaLocationDataSource+<>c__DisplayClass33_0.<FromAccessory>b__0 (Esri.ArcGISRuntime.Location.NmeaLocationDataSource d)
NmeaLocationDataSource+CreateStreamNmeaLocationDataSource.OnStartAsync ()
ArcGISException.HandleCoreError (RuntimeCoreNet.GeneratedWrappers.CoreError error, System.Boolean throwException)

 

Thanks,
-Joe
0 Kudos
3 Replies
dotMorten_esri
Esri Notable Contributor

Thank you for the stack trace, but what is the exception that is thrown? What device is being used?

0 Kudos
JoeHershman
MVP Regular Contributor

Here is what is in the AppCenter Diagnostics:

Application.Main (System.String[] args)

/Users/runner/work/1/s/src/Mobile.Design.iOS/Main.cs, line 15

SIGABRT: Could not initialize an instance of the type 'ExternalAccessory.EASession': the native 'initWithAccessory:forProtocol:' method returned nil. It is possible to ignore this condition by setting ObjCRuntime.Class.ThrowOnInitFailure to false

 

Line 15 is just the startup:   UIApplication.Main(args, null, typeof(AppDelegate));

---------------------------

Stack traces

NSObject.InitializeHandle (System.IntPtr handle, System.String initSelector) /Users/builder/azdo/_work/2/s/xamarin-macios/src/Foundation/NSObject2.cs:609
/Users/builder/azdo/_work/2/s/xamarin-macios/src/build/ios/native/ExternalAccessory/EASession.g.cs:79
Esri.ArcGISRuntime.Location.NmeaLocationDataSource+EAAccessoryStream..ctor (ExternalAccessory.EAAccessory accessory, System.String protocol) [0x0000d] in <fc2ff9f8183b4871b39c22ae8fb2d60c>:0
NmeaLocationDataSource+<>c__DisplayClass33_0.<FromAccessory>b__0 (Esri.ArcGISRuntime.Location.NmeaLocationDataSource d)
NmeaLocationDataSource+CreateStreamNmeaLocationDataSource.OnStartAsync ()
ArcGISException.HandleCoreError (RuntimeCoreNet.GeneratedWrappers.CoreError error, System.Boolean throwException)
Interop.CheckError (System.IntPtr errorHandle, System.Boolean throwOnFailure, System.Runtime.InteropServices.GCHandle wrapperHandle)
CoreTask.Get ()
CoreTaskExtensions+TaskCompletedCallbackHandler.OnCompleted (System.Object sender, System.EventArgs e)
CoreTaskExtensions+TaskCompletedCallbackHandler.CreateInternal (RuntimeCoreNet.GeneratedWrappers.CoreTask task, System.Threading.CancellationToken cancellationToken)
MapViewControl.SetupLocationDataSource ()
AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) /Library/Frameworks/Xamarin.iOS.framework/Versions/Current/src/Xamarin.iOS/mcs/class/referencesource/mscorlib/system/runtime/compilerservices/AsyncMethodBuilder.cs:1021
NSAsyncSynchronizationContextDispatcher.Apply () /Users/builder/azdo/_work/2/s/xamarin-macios/src/Foundation/NSAction.cs:178
(wrapper managed-to-native) UIKit.UIApplication.UIApplicationMain(int,string[],intptr,intptr)
UIApplication.Main (System.String[] args, System.Type principalClass, System.Type delegateClass) /Users/builder/azdo/_work/2/s/xamarin-macios/src/UIKit/UIApplication.cs:85
Application.Main (System.String[] args) /Users/runner/work/1/s/src/Mobile.Design.iOS/Main.cs:15

 

Looking at it I do see a place that I could catch an exception I had not noticed before.  But one thing that really confuses me is the user reporting that this has occurred once they have connected and have collected a point.  The initialization of the LocationDataSource is done when the MapView is initially loaded.  So I am not clear how there would be an additional attempt to connect (and there is always the chance the user who reported things is describing something incorrectly).  It is not an issue that occurs often, it may have only happened on one day.  The device is a Geneq SxBlue.  We have 100 users with the exact same device in the field

Thanks

 

 

Thanks,
-Joe
0 Kudos
dotMorten_esri
Esri Notable Contributor

Thanks. I'm assuming you're already try-catching the `nmeadatasource.StartAsync()` call? You should expect this to fail for a number of reasons (user denies access, device couldn't connect etc).

0 Kudos