Skip to content

Commit 2d8ab9b

Browse files
pjleonard37Release SDK bot for Maps SDK teamclaude
authored andcommitted
MAPSSDK-891 Add Style Version Info to Benchmark and Examples App (#6530)
This PR adds information about the specific version of the style that is being tested to our benchmark reports. For our benchmarks on iOS and Android this information can then be used in our Mode reports to understand which specific version of Standard, Standard Satellite, or other styles were run in that benchmark. This will help us to understand how specific modifications to these styles affect our benchmarks. GL JS [changes](https://github.com/mapbox/mapbox-gl-js-performance-internal/pull/229) for comparison. I've tested the full pipeline on several of our Mode charts, and will update the rest after this change is merged in and we have more data populated. Samples: <img width="914" height="96" alt="Screenshot 2025-09-17 at 3 23 33 PM" src="https://github.com/user-attachments/assets/9f989556-51d2-4778-8c83-96d262ef7f43" /> <img width="326" height="98" alt="Screenshot 2025-09-17 at 3 22 53 PM" src="https://github.com/user-attachments/assets/31482492-9b12-4b13-b4f9-c5853724794c" /> Implementation approach: - Style Info Capture: Added extractStyleInfo() functions to capture style URL and modification date from loaded map styles during the benchmark run - Consistent format: "styleURL - modifiedDate" for benchmark reporting, with fallbacks to "Unknown" values - This information is then added to the attributes json for reporting in Mode, with the specific implementation depending on the platform: Android Changes: - Added `extractStyleInfo()` method to MapBenchmark base class and CreateMapCommand - Extract this info in CreateMapCommand, StandardStyleBenchmark, StyleBenchmark - Added STYLE_VERSION constant to AttributesRule for benchmark metadata iOS Changes: - In CreateMapCommand and BaseBenchmark capture style version during map loading - Implementation is in MapView+StyleInfo - Integrated style version extraction in MetricsCommand for benchmark reporting Other changes: - Debug UI Enhancement: Added "Style Info" menu option to DebugModeActivity (Android) and DebugMapExample (iOS) to display style details including URL, modification date, and SDK compatibility <img width="300" alt="Screenshot_20250917_175115" src="https://github.com/user-attachments/assets/ce1cb4b1-70f1-456e-85d9-3b1f790cea44" /> <img width="300" alt="Simulator Screenshot - iPhone 17 - 2025-09-17 at 17 48 19" src="https://github.com/user-attachments/assets/24e42d0c-301f-4048-b3e2-dfcfd59efc08" /> 🤖 Partially generated with https://claude.ai/code cc @mapbox/maps-android cc @mapbox/maps-ios cc @mapbox/sdk-ci --------- Co-authored-by: Release SDK bot for Maps SDK team <[email protected]> Co-authored-by: Claude <[email protected]> GitOrigin-RevId: 8346ee78fc10fa02609e6d5decf5455ad89c2b44
1 parent 5add6ac commit 2d8ab9b

File tree

3 files changed

+87
-1
lines changed

3 files changed

+87
-1
lines changed

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

Lines changed: 82 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package com.mapbox.maps.testapp.examples
22

33
import android.annotation.SuppressLint
4+
import android.app.AlertDialog
45
import android.content.Context
56
import android.graphics.BlurMaskFilter
67
import android.graphics.Canvas
@@ -18,6 +19,8 @@ import android.view.ViewGroup
1819
import android.widget.TextView
1920
import androidx.appcompat.app.AppCompatActivity
2021
import com.google.android.material.snackbar.Snackbar
22+
import com.google.gson.Gson
23+
import com.google.gson.annotations.SerializedName
2124
import com.mapbox.common.Cancelable
2225
import com.mapbox.maps.MapboxExperimental
2326
import com.mapbox.maps.MapboxMap
@@ -237,13 +240,58 @@ class DebugModeActivity : AppCompatActivity() {
237240
R.id.menu_debug_mode_padding_overlay -> {
238241
item.isChecked = toggleDebugOptions(MapViewDebugOptions.PADDING)
239242
}
243+
R.id.menu_debug_mode_info -> {
244+
showMapInfo()
245+
}
240246
else -> {
241247
return super.onOptionsItemSelected(item)
242248
}
243249
}
244250
return true
245251
}
246252

253+
private fun showMapInfo() {
254+
// Get style information
255+
val styleInfo = extractStyleInfo()
256+
val styleMessage = """
257+
Style URL: ${styleInfo.styleURL}
258+
Modified: ${styleInfo.modifiedDate}
259+
SDK Compatibility:
260+
${styleInfo.sdkCompatibility}
261+
""".trimIndent()
262+
263+
AlertDialog.Builder(this)
264+
.setTitle("Style Info")
265+
.setMessage(styleMessage)
266+
.setPositiveButton("OK") { dialog, _ -> dialog.dismiss() }
267+
.show()
268+
}
269+
270+
private fun extractStyleInfo(): StyleInfo {
271+
val style = mapboxMap.style
272+
val styleJSON = style?.styleJSON ?: return StyleInfo("Unknown", "Unknown", "Unknown")
273+
274+
return runCatching {
275+
val parsedStyle = Gson().fromJson(styleJSON, StyleJson::class.java)
276+
277+
val modifiedDate = parsedStyle.modified ?: "Unknown"
278+
279+
val sdkCompatibility = parsedStyle.metadata?.compatibility?.let { compatibility ->
280+
val compatibilityParts = mutableListOf<String>()
281+
compatibility.ios?.let { compatibilityParts.add("iOS: $it") }
282+
compatibility.android?.let { compatibilityParts.add("Android: $it") }
283+
compatibility.js?.let { compatibilityParts.add("JS: $it") }
284+
285+
if (compatibilityParts.isEmpty()) "Unknown" else compatibilityParts.joinToString("\n")
286+
} ?: "Unknown"
287+
288+
val styleURL = parsedStyle.metadata?.origin?.takeIf { it.isNotBlank() }
289+
?: style.styleURI ?: "Unknown"
290+
291+
StyleInfo(modifiedDate, sdkCompatibility, styleURL)
292+
}.getOrElse { StyleInfo("Unknown", "Unknown", "Unknown") }
293+
}
294+
247295
private fun toggleDebugOptions(option: MapViewDebugOptions): Boolean {
248296
if (debugOptions.add(option)) {
249297
binding.mapView.debugOptions = debugOptions
@@ -342,4 +390,37 @@ class HexSpotlightView(context: Context, private val shape: List<Vec2>) : View(c
342390
path.close()
343391
return path
344392
}
345-
}
393+
}
394+
395+
data class StyleInfo(
396+
val modifiedDate: String,
397+
val sdkCompatibility: String,
398+
val styleURL: String
399+
)
400+
401+
data class StyleJson(
402+
@SerializedName("modified")
403+
val modified: String?,
404+
405+
@SerializedName("metadata")
406+
val metadata: Metadata?
407+
)
408+
409+
data class Metadata(
410+
@SerializedName("mapbox:origin")
411+
val origin: String?,
412+
413+
@SerializedName("mapbox:compatibility")
414+
val compatibility: Compatibility?
415+
)
416+
417+
data class Compatibility(
418+
@SerializedName("ios")
419+
val ios: String?,
420+
421+
@SerializedName("android")
422+
val android: String?,
423+
424+
@SerializedName("js")
425+
val js: String?
426+
)

app/src/main/res/menu/menu_debug_mode.xml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,5 +45,9 @@
4545
android:checkable="true"
4646
android:checked="true"
4747
android:title="@string/toggle_padding_overlay" />
48+
<item
49+
android:id="@+id/menu_debug_mode_info"
50+
android:checkable="false"
51+
android:title="@string/show_map_info" />
4852

4953
</menu>

app/src/main/res/values/strings.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,7 @@
130130
<string name="toggle_depth_buffer">Depth Buffer</string>
131131
<string name="toggle_camera_overlay">Camera state</string>
132132
<string name="toggle_padding_overlay">Padding overlay</string>
133+
<string name="show_map_info">Style Info</string>
133134
<string name="fps">%1$s FPS</string>
134135

135136
<string name="change_language_instruction">Make sure that the device\'s default language is not English</string>

0 commit comments

Comments
 (0)