-
Notifications
You must be signed in to change notification settings - Fork 117
Closed
Labels
location-layer-pluginIssues that deal with the location layer moduleIssues that deal with the location layer module
Milestone
Description
Hi, I'm using mapbox on my android app and it is working great. But when I try to use the locationPlugin to display the user position, I see the consommation of my memory going up when the user move.
Unfortunately, if the user is constantly moving, the app will crash due to a Out of Memory.
The issue may be related to the locationEngine.setInterval()/setFastestInterval() since in the doc of both we have :
If this rate is faster than your app can handle, you may encounter problems with UI flicker or data overflow
Below is a test that I recreate having the same issue :
`
private LocationLayerPlugin locationPlugin;
private LocationEngine locationEngine;
private MapboxMap map;
@Nullable
@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
super.onCreateView(inflater, container, savedInstanceState);
Mapbox.getInstance(getContext(), MyMapbox.getToken());
binding = DataBindingUtil.inflate(inflater, R.layout.test, container, false);
binding.mapView.onCreate(savedInstanceState);
binding.mapView.getMapAsync(this);
return binding.getRoot();
}
@Override
public void onStart() {
super.onStart();
binding.mapView.onStart();
}
@Override
public void onResume() {
super.onResume();
binding.mapView.onResume();
}
@Override
public void onPause() {
super.onPause();
binding.mapView.onPause();
}
@Override
public void onStop() {
super.onStop();
binding.mapView.onStop();
}
@Override
public void onLowMemory() {
super.onLowMemory();
binding.mapView.onLowMemory();
}
@Override
public void onDestroyView() {
super.onDestroyView();
if (locationEngine != null) {
locationEngine.removeLocationUpdates();
locationEngine.removeLocationEngineListener(this);
locationEngine.deactivate();
}
if (locationPlugin != null) {
locationPlugin.onStop();
}
binding.mapView.onDestroy();
}
@Override
public void onSaveInstanceState(@NonNull Bundle outState) {
super.onSaveInstanceState(outState);
binding.mapView.onSaveInstanceState(outState);
}
@SuppressLint("MissingPermission")
@Override
public void onConnected() {
locationEngine.requestLocationUpdates();
}
@Override
public void onLocationChanged(Location location) {
Log.d(LOG_TAG, "TEST");
}
private void enableLocationPlugin() {
if (locationPlugin == null) {
LocationEngineProvider locationEngineProvider = new LocationEngineProvider(getContext());
locationEngine = locationEngineProvider.obtainBestLocationEngineAvailable();
locationEngine.setPriority(LocationEnginePriority.BALANCED_POWER_ACCURACY);
locationEngine.setFastestInterval(1000);
locationEngine.setInterval(1000);
locationEngine.addLocationEngineListener(this);
locationEngine.activate();
locationPlugin = new LocationLayerPlugin(binding.mapView, map, locationEngine);
}
}
@Override
public void onMapReady(MapboxMap mapboxMap) {
map = mapboxMap;
enableLocationPlugin();
}`
nazmuddin77
Metadata
Metadata
Assignees
Labels
location-layer-pluginIssues that deal with the location layer moduleIssues that deal with the location layer module