I am using Mapbox navigation in my app, something like Uber, I start a trip and start navigation to some point. Everything is working fine except at some point of the navigation my app freezes and i get a warning that my App isn`t responding.
Here`s my dependency
implementation 'com.mapbox.mapboxsdk:mapbox-android-navigation-ui:0.40.0'
And my Class that recieves the LocationEngineResult:
public class LocationCallback implements LocationEngineCallback<LocationEngineResult> {
private final WeakReference<NavigationFragment> activityWeakReference;
private Location prelocation;
public LocationCallback(NavigationFragment navigationFragment) {
this.activityWeakReference = new WeakReference<NavigationFragment>(navigationFragment);
}
@Override
public void onSuccess(LocationEngineResult result) {
Log.e("Tag", "NavigationFragment locationEngineResult");
NavigationFragment context = activityWeakReference.get();
if (context != null) {
Location location = result.getLastLocation();
Log.d("Tag", "Result location: " + location.toString());
if (location == null) {
return;
}
if(prelocation == null){
context.checkFirstUpdate(location);
context.onLocationChanged(location);
prelocation = location;
}
else{
if(AppHelper.distance(prelocation.getLatitude(), prelocation.getLongitude(), location.getLatitude(), location.getLongitude()) > 0){
context.checkFirstUpdate(location);
context.onLocationChanged(location);
prelocation = location;
}
}
}
}
@Override
public void onFailure(@NonNull Exception exception) {
Log.d("Tag", "On failure exception" + exception.getMessage());
Timber.e(exception);
}
}
I am dealing with this for a few days and i asume my LocationEngine callback stops getting the result of my location.
Here is my Logcat:
PID: 18359
Reason: Broadcast of Intent { act=com.mapbox.android.telemetry.location.locationupdatespendingintent.action.LOCATION_UPDATED flg=0x10 launchParam=MultiScreenLaunchParams { mDisplayId=0 mFlags=0 } (has extras) }
Load: 2.85 / 4.21 / 4.5
CPU usage from 901ms to -4460ms ago (2019-06-14 17:13:07.541 to 2019-06-14 17:13:12.902):
24% 3658/system_server: 13% user + 10% kernel / faults: 7699 minor 6681 major
Pleas, any suggestion may help. I can provide more code. Thanks!
UPDATE
In my case the bug had somethimg to do with crashlitcs, after days of debugging and going to previous commits i ended up removing crashlitics but never could understand the problem. Also the project didn't continue for long so i really can}t be sure if that completley solved the issue. Sory