mapbox-maps-android icon indicating copy to clipboard operation
mapbox-maps-android copied to clipboard

Lag on move map or zoom

Open milenpav opened this issue 1 year ago • 6 comments

Environment

  • Android OS version: Android 10
  • Devices affected: Lenovo TB-8505X
  • Maps SDK Version:1.7.2

I update from version 9 to v 11 but map is verry laggy on this device when is move or zoom.

This is My code ov implementation

private void LoadMapBoxMap(FrameLayout mapLayout) {
        ((DriverApplication) mActivity.getApplication()).setMapView(MAP_VIEW_MAPBOX);

        mMapBoxView = new com.mapbox.maps.MapView(mActivity.getApplicationContext());
        mMapboxMap=mMapBoxView.getMapboxMap();

        var camera = new CameraOptions.Builder()
                .center(Point.fromLngLat(27.916077,43.213116))
                .pitch(50.0)
                .zoom(18.0)
                .build();

        mMapboxMap.setCamera(camera);
        int currentNightMode = DriverApplication.getInstance().getThemeMode();
        mMapboxMap.loadStyle(currentNightMode == AppCompatDelegate.MODE_NIGHT_YES ?
                mActivity.getResources().getString(R.string.mapbox_style_dark) :
                mActivity.getResources().getString(R.string.mapbox_style_light), new Style.OnStyleLoaded() {
            @Override
            public void onStyleLoaded(@NonNull Style style) {
                   style.addImage (MARKER_ADDRESS, generateBitmap(R.drawable.address_marker));
                style.addImage(MARKER_ACCIDENT,  generateBitmap(R.drawable.marker_car_accident));
                style.addImage(MARKER_CLIENT, generateBitmap(R.drawable.marker_client));
                style.addImage(MARKER_CLOSED_ROAD, generateBitmap(R.drawable.marker_closed_road));
                style.addImage(MARKER_POLICE, generateBitmap(R.drawable.marker_police));
                style.addImage(MARKER_IAAA, generateBitmap(R.drawable.marker_iaaa));
                style.addImage(MARKER_REQUEST, generateBitmap(R.drawable.marker_request));
                style.addImage(MARKER_RIDE, generateBitmap(R.drawable.marker_ride));
                style.addImage(MARKER_TRAFFIC, generateBitmap(R.drawable.marker_traffic));
                style.addImage(MARKER_ICE, generateBitmap(R.drawable.marker_danger_road));
                style.addImage(MARKER_CAMERA, generateBitmap(R.drawable.marker_camera));

                enableLocationComponent();
            }
        });
        mapLayout.addView(mMapBoxView);
}
  private void enableLocationComponent() {

        if (ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.ACCESS_FINE_LOCATION) != PackageManager.PERMISSION_GRANTED &&
                ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.ACCESS_COARSE_LOCATION) != PackageManager.PERMISSION_GRANTED) {
            ActivityCompat.requestPermissions(mActivity, new String[]{
                    Manifest.permission.ACCESS_FINE_LOCATION,
                    Manifest.permission.ACCESS_COARSE_LOCATION},0);
            return;
        }
        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q
                &&ActivityCompat.checkSelfPermission(mActivity, Manifest.permission.ACCESS_BACKGROUND_LOCATION) != PackageManager.PERMISSION_GRANTED ) {
            ActivityCompat.requestPermissions(mActivity, new String[]{
                    Manifest.permission.ACCESS_BACKGROUND_LOCATION,
            }, 0);
            return;
        }
        mLocationComponent = mMapBoxView.getPlugin(Plugin.MAPBOX_LOCATION_COMPONENT_PLUGIN_ID);
        mLocationComponent.initialize();
}

Additional links and references

Link to video https://files.fm/u/mkhjsnaqfu

milenpav avatar Nov 06 '24 13:11 milenpav

Thank you for the report. Do you face this issue only on one device (Android 10, Lenovo TB-8505X)? It would be very helpful if you could provide us an example that reproduces a bug.

flasher297 avatar Nov 11 '24 10:11 flasher297

Yes only in device Android 10, Lenovo TB-8505X in devie Xiaomi 2109119DG there is no such kind of lag. also I noticed that lag is when zoom level is 6+. Also i try with debug with profiler thee has a free ram and CPU image

milenpav avatar Nov 12 '24 09:11 milenpav

I try it also on LENOVO Lenovo TB-8504X wich is older device and with 1 Gb Ram and there is no Lag

milenpav avatar Nov 12 '24 11:11 milenpav

Seems that it's device device-specific bug. To continue with it we still need to have a reproducible example.

flasher297 avatar Nov 12 '24 17:11 flasher297

https://github.com/milenpav/MapboxTest here i make reproducible example of test app you need to change in strings.xml <string name="mapbox_access_token" translatable="false">mapAccesToken</string> and in gradle.properties MAPBOX_DOWNLOADS_TOKEN=MapToken

milenpav avatar Nov 14 '24 12:11 milenpav

Some info here @flasher297

milenpav avatar Dec 02 '24 12:12 milenpav