mapbox-gl-native-android icon indicating copy to clipboard operation
mapbox-gl-native-android copied to clipboard

The animation of the location component has lags when the RenderMode.COMPASS and mapbox_elevation=0dp are set

Open Copatych opened this issue 3 years ago • 0 comments

Environment

  • Devices affected: Galaxy A50 (Android 11), Redmi Note 7 (Android 10), etc
  • Maps SDK Version: 9.7.2

Observed behavior and steps to reproduce

The animation of the location component has lags when the RenderMode.COMPASS and mapbox_elevation=0dp are set. Code to reproduce the bug

    private lateinit var mapView: MapView

    @SuppressLint("MissingPermission")
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        Mapbox.getInstance(this, getString(R.string.mapbox_access_token))
        setContentView(R.layout.activity_main)

        mapView = findViewById(R.id.mapView)
        mapView.onCreate(savedInstanceState)

        mapView.getMapAsync { mapboxMap ->
            mapboxMap.setStyle(Style.MAPBOX_STREETS) { style ->
                mapboxMap.locationComponent.apply {
                    val options = LocationComponentActivationOptions.builder(this@MainActivity, style)
                        .useDefaultLocationEngine(false)
                        .locationEngine(null)
                        .styleRes(R.style.MapView_LocationComponent)
                        .build()

                    activateLocationComponent(options)
                    isLocationComponentEnabled = true
                    renderMode = RenderMode.COMPASS
                }
            }

            mapboxMap.addOnMapClickListener { point ->
                val location = Location(LocationManager.GPS_PROVIDER).apply {
                    latitude = point.latitude
                    longitude = point.longitude
                    altitude = point.altitude
                    accuracy = 3f
                    bearing = Random.nextFloat() * 360
                    speed = Random.nextFloat() * 15
                    time = System.currentTimeMillis()
                }

                mapboxMap.locationComponent.forceLocationUpdate(LocationUpdate.Builder().location(location).build())

                true
            }
        }
    }
...
<style name="MapView.LocationComponent" parent="@style/mapbox_LocationComponent">
        <item name="mapbox_elevation">0dp</item>
    </style>

Video example of bug:

https://user-images.githubusercontent.com/57287061/180126647-3335745f-2892-451a-a3a3-43c33df2e934.mp4

Notes / preliminary analysis

When RenderMode.GPS or mapbox_elevation=1dp are used, the lags disappear, the animation becomes smooth, beautiful.

Copatych avatar Jul 21 '22 04:07 Copatych