Skip to content

Commit 737f26c

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 0f49400 commit 737f26c

File tree

1 file changed

+91
-7
lines changed

1 file changed

+91
-7
lines changed

Sources/Examples/All Examples/DebugMapExample.swift

Lines changed: 91 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,12 +71,12 @@ final class DebugMapExample: UIViewController, ExampleProtocol {
7171
style: .plain,
7272
target: self,
7373
action: #selector(openDebugOptionsMenu(_:)))
74-
let tileCover = UIBarButtonItem(
75-
title: "Tiles",
74+
let infoBarItem = UIBarButtonItem(
75+
title: "Info",
7676
style: .plain,
7777
target: self,
78-
action: #selector(tileCover))
79-
navigationItem.rightBarButtonItems = [debugOptionsBarItem, tileCover]
78+
action: #selector(showInfo))
79+
navigationItem.rightBarButtonItems = [debugOptionsBarItem, infoBarItem]
8080
}
8181

8282
override func viewDidAppear(_ animated: Bool) {
@@ -96,10 +96,66 @@ final class DebugMapExample: UIViewController, ExampleProtocol {
9696
present(navigationController, animated: true, completion: nil)
9797
}
9898

99-
@objc private func tileCover() {
99+
private func extractStyleInfo() -> StyleInfo {
100+
let styleJSON = mapView.mapboxMap.styleJSON
101+
102+
guard let data = styleJSON.data(using: .utf8),
103+
let parsedStyle = try? JSONDecoder().decode(StyleJson.self, from: data) else {
104+
return StyleInfo(modifiedDate: "Unknown", sdkCompatibility: "Unknown", styleURL: "Unknown")
105+
}
106+
107+
let modifiedDate = parsedStyle.modified ?? "Unknown"
108+
109+
let sdkCompatibility: String
110+
if let compatibility = parsedStyle.metadata?.compatibility {
111+
var compatibilityParts: [String] = []
112+
if let ios = compatibility.ios {
113+
compatibilityParts.append("iOS: \(ios)")
114+
}
115+
if let android = compatibility.android {
116+
compatibilityParts.append("Android: \(android)")
117+
}
118+
if let js = compatibility.js {
119+
compatibilityParts.append("JS: \(js)")
120+
}
121+
sdkCompatibility = compatibilityParts.isEmpty ? "Unknown" : compatibilityParts.joined(separator: "\n")
122+
} else {
123+
sdkCompatibility = "Unknown"
124+
}
125+
126+
let styleURL: String
127+
if let origin = parsedStyle.metadata?.origin, !origin.isEmpty {
128+
styleURL = origin
129+
} else {
130+
styleURL = mapView.mapboxMap.styleURI?.rawValue ?? "Unknown"
131+
}
132+
133+
return StyleInfo(modifiedDate: modifiedDate, sdkCompatibility: sdkCompatibility, styleURL: styleURL)
134+
}
135+
136+
@objc private func showInfo() {
137+
// Get tiles information
100138
let tileIds = mapView.mapboxMap.tileCover(for: TileCoverOptions(tileSize: 512, minZoom: 0, maxZoom: 22, roundZoom: false))
101-
let message = tileIds.map { "\($0.z)/\($0.x)/\($0.y)" }.joined(separator: "\n")
102-
showAlert(withTitle: "Displayed tiles", and: message)
139+
let tilesMessage = tileIds.map { "\($0.z)/\($0.x)/\($0.y)" }.joined(separator: "\n")
140+
141+
// Get style information
142+
let styleInfo = extractStyleInfo()
143+
let styleMessage = """
144+
Style URL: \(styleInfo.styleURL)
145+
Modified: \(styleInfo.modifiedDate)
146+
SDK Compatibility:
147+
\(styleInfo.sdkCompatibility)
148+
"""
149+
150+
// Combine both
151+
let combinedMessage = """
152+
TILES:
153+
\(tilesMessage)
154+
155+
STYLE INFO:
156+
\(styleMessage)
157+
"""
158+
showAlert(withTitle: "Map Info", and: combinedMessage)
103159
}
104160

105161
private func handle(statistics: PerformanceStatistics) {
@@ -341,3 +397,31 @@ extension PerformanceStatistics {
341397
"""
342398
}
343399
}
400+
401+
struct StyleInfo {
402+
let modifiedDate: String
403+
let sdkCompatibility: String
404+
let styleURL: String
405+
}
406+
407+
struct StyleJson: Codable {
408+
let modified: String?
409+
let metadata: Metadata?
410+
}
411+
412+
struct Metadata: Codable {
413+
let origin: String?
414+
let compatibility: Compatibility?
415+
416+
enum CodingKeys: String, CodingKey {
417+
case origin = "mapbox:origin"
418+
case compatibility = "mapbox:compatibility"
419+
}
420+
}
421+
422+
struct Compatibility: Codable {
423+
let ios: String?
424+
let android: String?
425+
let js: String?
426+
}
427+

0 commit comments

Comments
 (0)