Skip to content

Commit c824e91

Browse files
persidskiygithub-actions[bot]
authored andcommitted
Merge pull request #3327 from mapbox/nb/maps-android-main-16-4-2025
Update maps-android from internal repo GitOrigin-RevId: 24e944281eae024c1f9b2c37015f8a4899a34018
1 parent 890a9a0 commit c824e91

File tree

90 files changed

+3441
-5873
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

90 files changed

+3441
-5873
lines changed

CHANGELOG.md

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,43 @@
33
Mapbox welcomes participation and contributions from everyone.
44

55
# main
6+
## Features ✨ and improvements 🏁
7+
* Expose `RenderThreadStatsRecorder` as experimental API.
8+
9+
10+
# 11.12.0-rc.1
11+
## Features ✨ and improvements 🏁
12+
* Avoid fetching pixelRatio from gl-native while rendering scalebar to improve CPU usage.
13+
* Promote `MapView.attribution.getMapAttributionDelegate().extraAttributions` to stable.
14+
15+
16+
# 11.12.0-beta.1 April 09, 2025
617

718
## Features ✨ and improvements 🏁
819
* Introduce experimental `colorUseTheme` API for `AmbientLight`, `DirectionalLight`, and `FlatLight` to override color theme of light.
920
* [compose] Introduce experimental `colorUseTheme` API for `AmbientLightState`, `DirectionalLightState`, and `FlatLightState` to override color theme of light.
1021
* [compose] Introduce experimental `vignetteColorUseTheme` and `colorUseTheme` for `RainState` and `SnowState` which allows overriding color theme of precipitations.
22+
* [compose] Annotate `rememberGeoJsonSourceState` as delicate API due to performance implications when used with large GeoJsonData.
23+
* Avoid dynamic view annotation overlapping given symbol layers.
24+
* Vector icons can now also be retrieved via `getStyleImage` API.
25+
* Revert changes to `at` expression and add new `at-interpolated` expression.
26+
* Enable tile pack v2 format by default.
27+
28+
## Bug fixes 🐞
29+
* Fix semi transparent landmark icons.
30+
* Return null for config expression if requested config option is missing.
31+
* Fix clipPath and mask rendering for vector icon rasterization.
32+
* Fix dotted lines on tile borders.
33+
* Fix pattern not found when using imports.
34+
* Fix line layer not rendering if using `line-pattern` inside an imported style.
35+
* Fix ground effect gradient not working with multiple polygons.
36+
* Add simple bounds check to avoid crash during centroid computation.
37+
* Fix invisible line when interpolating line-width from 0 to 1 using line-progress.
38+
* Tile loading speedup.
39+
* Fix URL migration to DB v10.
40+
41+
## Dependencies
42+
* Update gl-native to v11.12.0-beta.1 and common to v24.12.0-beta.1.
1143

1244

1345
# 11.11.0 March 26, 2025

DEVELOPING.md

Lines changed: 30 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -498,6 +498,36 @@ There are 2 types of traces that could be enabled:
498498

499499
It is also possible to enable all the traces with `MapboxTracing.enableAll()`. Tracing could be disabled with `MapboxTracing.disableAll()`.
500500

501+
### Recording traces using Perfetto UI
502+
503+
The Perfetto Record settings can be edited when recording a new trace from [ui.perfetto.dev](https://ui.perfetto.dev/#!/record).
504+
We recommend to enable the following options in Perfetto and combine them with `MapboxTracing.enableAll()` enabled in application code:
505+
506+
In **GPU** section. Enable `GPU frequency`, `GPU memory` and `GPU work period`:
507+
508+
<img src="https://github.com/user-attachments/assets/7cc524c6-5253-4c33-a399-11a95d8f4315" width="400" height="300" alt="image">
509+
510+
511+
In **CPU** section.
512+
Enable `Coarse CPU usage counter`, `Scheduling details` and `CPU frequency and idle states` (with default `Poll interval`).
513+
Please make sure the “Syscalls” **is not** selected, otherwise the trace gets bloated with these records and becomes unreadable.
514+
515+
<img src="https://github.com/user-attachments/assets/2d6a29b1-3087-4501-998f-077db5038bce" width="400" height="300" alt="image">
516+
517+
518+
**Android apps & svcs**
519+
520+
Please make sure the “Atrace userspace annotations” is selected and “Record events from all Android apps and services” is enabled (it is also required to record the Mapbox trace annotations).
521+
522+
<img src="https://github.com/user-attachments/assets/f4978e0d-3165-4aa1-80e0-b747e7eda791" width="400" height="300" alt="image">
523+
524+
Please note that this UI auto-generates the corresponding command line instructions - “Cmdline instructions” section
525+
526+
<img src="https://github.com/user-attachments/assets/f55532df-fdff-4ba2-ac87-823deebfb1c0" width="400" height="300" alt="image">
527+
528+
Produced html file can be opened in https://ui.perfetto.dev viewer.
529+
530+
501531
### Recording traces using Android studio
502532

503533
There are several ways of capturing traces for Android which are described in [official documentation](https://developer.android.com/topic/performance/tracing). As a reference we will describe the steps of recording traces using Android Studio Profiler:
@@ -527,16 +557,6 @@ After we exported trace recording we could use [Perfetto](https://ui.perfetto.de
527557

528558
There are several other ways how to record traces.
529559

530-
#### From ui.perfetto.dev over WebUSB
531-
532-
<img width="240" alt="image" src="https://github.com/mapbox/mapbox-maps-android-internal/assets/1001009/ee1f1ff9-350a-436e-898a-8e0d05fae920">
533-
534-
Enable Atrace events (other optional probes can be enabled if needed).
535-
536-
<img width="70%" alt="image" src="https://github.com/mapbox/mapbox-maps-android-internal/assets/1001009/36cad2eb-9b0b-4545-ab4f-b3fb0cd5da7f">
537-
538-
After `stop recording` is pressed, trace will be visible in the UI.
539-
540560
#### Directly from the device (supported on Google Pixel devices)
541561

542562
<img src="https://github.com/mapbox/mapbox-maps-android-internal/assets/1001009/f81f3217-55a6-4d07-a6c1-b40842cc1d83" width="60%">

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -482,7 +482,7 @@ License: [The Apache Software License, Version 2.0](http://www.apache.org/licens
482482

483483
===========================================================================
484484

485-
### MapboxCoreMaps,11.11.0,Mapbox ToS,Mapbox,https://www.mapbox.com/
485+
### MapboxCoreMaps,11.12.0-beta.1,Mapbox ToS,Mapbox,https://www.mapbox.com/
486486

487487
```
488488
Mapbox Core Maps version 11.0

app/src/main/java/com/mapbox/maps/testapp/examples/SimulateNavigationRouteActivity.kt

Lines changed: 37 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
package com.mapbox.maps.testapp.examples
22

33
import android.os.Bundle
4+
import android.view.WindowManager
45
import androidx.appcompat.app.AppCompatActivity
56
import androidx.lifecycle.lifecycleScope
67
import com.mapbox.api.directions.v5.models.DirectionsResponse
78
import com.mapbox.core.constants.Constants
89
import com.mapbox.geojson.LineString
910
import com.mapbox.geojson.Point
1011
import com.mapbox.maps.MapView
12+
import com.mapbox.maps.MapboxExperimental
1113
import com.mapbox.maps.dsl.cameraOptions
14+
import com.mapbox.maps.logI
15+
import com.mapbox.maps.renderer.RenderThreadStats
16+
import com.mapbox.maps.renderer.RenderThreadStatsRecorder
17+
import com.mapbox.maps.testapp.examples.SimulateNavigationRouteActivity.Companion.SIMULATION_DURATION
1218
import com.mapbox.maps.testapp.examples.annotation.AnnotationUtils
1319
import com.mapbox.maps.testapp.utils.NavigationSimulator
1420
import kotlinx.coroutines.Dispatchers
@@ -18,12 +24,15 @@ import kotlinx.coroutines.withContext
1824

1925
/**
2026
* Simulate a navigation route with pre-defined route (from LA to San Francisco) with location puck,
21-
* route line and camera tracking. The activity has disabled gestures and will run for 20 seconds.
22-
* At the end of the activity, there will be a toast showing the average fps, overtime frames
27+
* route line and camera tracking. Gestures are disabled.
28+
* The simulation will run [repetitions] times, and the network stack will be disabled after the 5th.
29+
* On each iteration, the simulation will run for [SIMULATION_DURATION] milliseconds and some frame
30+
* stats will be logged.
2331
*/
32+
@OptIn(MapboxExperimental::class)
2433
class SimulateNavigationRouteActivity : AppCompatActivity() {
2534

26-
private lateinit var navigationSimulator: NavigationSimulator
35+
private val repetitions = 3
2736

2837
override fun onCreate(savedInstanceState: Bundle?) {
2938
super.onCreate(savedInstanceState)
@@ -37,6 +46,8 @@ class SimulateNavigationRouteActivity : AppCompatActivity() {
3746
zoom(9.0)
3847
}
3948
)
49+
// Prevent screen from sleeping while running the simulation
50+
window.addFlags(WindowManager.LayoutParams.FLAG_KEEP_SCREEN_ON)
4051
lifecycleScope.launch {
4152
val routePoints = withContext(Dispatchers.Default) {
4253
LineString.fromPolyline(
@@ -49,10 +60,13 @@ class SimulateNavigationRouteActivity : AppCompatActivity() {
4960
Constants.PRECISION_6
5061
)
5162
}
52-
navigationSimulator = NavigationSimulator(mapView, routePoints)
53-
navigationSimulator.apply {
54-
disableGestures()
55-
playCustomNavigationScripts(
63+
repeat(repetitions) {
64+
val renderThreadStatsRecorder = RenderThreadStatsRecorder()
65+
mapView.setRenderThreadStatsRecorder(renderThreadStatsRecorder)
66+
val navigationSimulator = NavigationSimulator(mapView, routePoints)
67+
navigationSimulator.disableGestures()
68+
renderThreadStatsRecorder.start()
69+
navigationSimulator.playCustomNavigationScripts(
5670
NavigationSimulator.NavigationStep(INITIAL_OVERVIEW_DELAY_MS) {
5771
setCameraTrackingMode(NavigationSimulator.CameraFollowMode.FOLLOW)
5872
},
@@ -63,22 +77,30 @@ class SimulateNavigationRouteActivity : AppCompatActivity() {
6377
setCameraTrackingMode(NavigationSimulator.CameraFollowMode.FOLLOW)
6478
}
6579
)
80+
delay(SIMULATION_DURATION)
81+
logStats(renderThreadStatsRecorder.end())
82+
navigationSimulator.onDestroy()
6683
}
67-
delay(SIMULATION_DURATION)
6884
finish()
69-
// Uncomment below to play the default navigation script in loop.
70-
// navigationSimulator.playDefaultNavigationScriptsInLoop()
7185
}
7286
}
7387

74-
override fun onDestroy() {
75-
super.onDestroy()
76-
if (this::navigationSimulator.isInitialized) {
77-
navigationSimulator.onDestroy()
78-
}
88+
private fun logStats(renderThreadStats: RenderThreadStats) = with(renderThreadStats) {
89+
logI(TAG, "RenderThread Stats:")
90+
logI(TAG, "\ttotal time: $totalTime ms")
91+
logI(TAG, "\ttotal frames (rendered + skipped): $totalFrames")
92+
logI(TAG, "\taverage FPS: ${(totalFrames / (totalTime / 1000F)).format()}")
93+
logI(TAG, "\tskipped frames: $totalDroppedFrames")
94+
logI(TAG, "\t50 percentile: ${percentile50.format()} ms")
95+
logI(TAG, "\t90 percentile: ${percentile90.format()} ms")
96+
logI(TAG, "\t95 percentile: ${percentile95.format()} ms")
97+
logI(TAG, "\t99 percentile: ${percentile99.format()} ms")
7998
}
8099

100+
private fun Number?.format() = "%.3f".format(this)
101+
81102
companion object {
103+
private const val TAG = "SimulateNavigationRoute"
82104
private const val NAVIGATION_ROUTE_JSON_NAME = "navigation_route.json"
83105
private const val INITIAL_OVERVIEW_DELAY_MS = 3000L
84106
private const val FIRST_FOLLOW_MODE_DELAY_MS = 8000L

app/src/main/java/com/mapbox/maps/testapp/utils/FrameStatsRecorder.kt

Lines changed: 0 additions & 143 deletions
This file was deleted.

app/src/main/java/com/mapbox/maps/testapp/utils/NavigationSimulator.kt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,9 @@ class NavigationSimulator(
195195
)
196196
it.addLayer(casingLayer)
197197
it.addLayer(routeLayer)
198-
mapView.recordFrameStats()
199-
initLocationComponent()
200-
viewportPlugin.transitionTo(overviewViewportState)
201-
enableGestures()
198+
initLocationComponent()
199+
viewportPlugin.transitionTo(overviewViewportState)
200+
enableGestures()
202201
}
203202
}
204203

@@ -342,6 +341,11 @@ class NavigationSimulator(
342341
}
343342

344343
fun onDestroy() {
344+
mapView.mapboxMap.getStyle {
345+
it.removeStyleLayer(casingLayer.layerId)
346+
it.removeStyleLayer(routeLayer.layerId)
347+
it.removeStyleSourceUnchecked(GEOJSON_SOURCE_ID)
348+
}
345349
handler.removeCallbacksAndMessages(null)
346350
mapView.location.removeOnIndicatorPositionChangedListener(this)
347351
mapView.gestures.apply {
@@ -373,7 +377,6 @@ class NavigationSimulator(
373377
)
374378

375379
companion object {
376-
private const val TAG = "NavigationSimulator"
377380
private const val DEFAULT_CAMERA_MODE_SWITCH_INTERVAL_MS = 5000L
378381
private const val DEFAULT_SCRIPT_DURATION_MS = 20000L
379382
private const val DEFAULT_VIEWPORT_TRANSITION_MAX_DURATION = 2000L

0 commit comments

Comments
 (0)