Closed jasonmereckixpo closed 4 years ago
Our app has reported a crash, the exception is:
System.NullReferenceException: Object reference not set to an instance of an object
with the following stack trace:
GeofenceImplementation+<OnConnected>d__59.MoveNext () AsyncMethodBuilderCore+<>c.<ThrowAsync>b__6_0 (System.Object state)
Since this seems to happen inside the OnConnected method, I'm guessing the issue is that accessing var location = await mFusedLocationProviderClient.GetLastLocationAsync(); is the problem
var location = await mFusedLocationProviderClient.GetLastLocationAsync();
https://github.com/CrossGeeks/GeofencePlugin/blob/b5de5e77e7666ae5b82a6d1d7891f87016dda2f1/src/Plugin.Geofence/GeofenceImplementation.android.cs#L524
Because the instance variable mFusedLocationProviderClient is only initialized in the IsLocationEnabled method:
https://github.com/CrossGeeks/GeofencePlugin/blob/b5de5e77e7666ae5b82a6d1d7891f87016dda2f1/src/Plugin.Geofence/GeofenceImplementation.android.cs#L149
Seems possible to have OnConnected executed by a thread before IsLocationEnabled is executed (or would be executed by a different thread).
@jasonmereckixpo Thanks for fixing this issue.
Our app has reported a crash, the exception is:
System.NullReferenceException: Object reference not set to an instance of an object
with the following stack trace:
Since this seems to happen inside the OnConnected method, I'm guessing the issue is that accessing
var location = await mFusedLocationProviderClient.GetLastLocationAsync();
is the problemhttps://github.com/CrossGeeks/GeofencePlugin/blob/b5de5e77e7666ae5b82a6d1d7891f87016dda2f1/src/Plugin.Geofence/GeofenceImplementation.android.cs#L524
Because the instance variable mFusedLocationProviderClient is only initialized in the IsLocationEnabled method:
https://github.com/CrossGeeks/GeofencePlugin/blob/b5de5e77e7666ae5b82a6d1d7891f87016dda2f1/src/Plugin.Geofence/GeofenceImplementation.android.cs#L149
Seems possible to have OnConnected executed by a thread before IsLocationEnabled is executed (or would be executed by a different thread).