-
Notifications
You must be signed in to change notification settings - Fork 310
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce default minimum frame rate to 20 fps #1819
Conversation
@@ -24,7 +24,7 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate { | |||
|
|||
This property takes effect when the application has limited resources for animation, such as when the device is running on battery power. By default, this property is set to `MGLMapViewPreferredFramesPerSecond.lowPower`. | |||
*/ | |||
@objc public var minimumFramesPerSecond = MGLMapViewPreferredFramesPerSecond.lowPower | |||
@objc public var minimumFramesPerSecond = MGLMapViewPreferredFramesPerSecond(20) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
>=
20 should be above the uncanny valley for most pair of eyes.
Just to give a crude sense of the performance improvement, I simulated a half-mile-long (2-minute-long) route along surface streets while on battery power on an iPhone 8 running iOS 12. Over 20 seconds of straightaway, away from maneuvers, the Swift example application posted these times:
Overall, for the entire duration of the session (including the flying animation at the beginning), we posted these times:
|
For reference, I rigged a couple more test runs with some additional variations to the map style to illustrate the impact that they can have:
No symbolsdiff --git a/MapboxNavigation/NavigationMapView.swift b/MapboxNavigation/NavigationMapView.swift
index 8cb35c71..760cbf83 100644
--- a/MapboxNavigation/NavigationMapView.swift
+++ b/MapboxNavigation/NavigationMapView.swift
@@ -968,31 +968,8 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate {
return
}
- let streetsSourceIdentifiers: [String] = style.sources.compactMap {
- $0 as? MGLVectorTileSource
- }.filter {
- $0.isMapboxStreets
- }.map {
- $0.identifier
- }
-
for layer in style.layers where layer is MGLSymbolStyleLayer {
- let layer = layer as! MGLSymbolStyleLayer
- guard let sourceIdentifier = layer.sourceIdentifier,
- streetsSourceIdentifiers.contains(sourceIdentifier) else {
- continue
- }
- guard let text = layer.text else {
- continue
- }
-
- // Road labels should match road signage.
- let locale = layer.sourceLayerIdentifier == "road_label" ? Locale(identifier: "mul") : nil
-
- let localizedText = text.mgl_expressionLocalized(into: locale)
- if localizedText != text {
- layer.text = localizedText
- }
+ style.removeLayer(layer)
}
}
Blankdiff --git a/Examples/Swift/ViewController.swift b/Examples/Swift/ViewController.swift
index fa1a7ce9..f80defb6 100644
--- a/Examples/Swift/ViewController.swift
+++ b/Examples/Swift/ViewController.swift
@@ -282,7 +282,7 @@ extension ViewController: MGLMapViewDelegate {
return
}
- self.mapView?.localizeLabels()
+// self.mapView?.localizeLabels()
if let routes = routes, let currentRoute = routes.first, let coords = currentRoute.coordinates {
mapView.setVisibleCoordinateBounds(MGLPolygon(coordinates: coords, count: currentRoute.coordinateCount).overlayBounds, animated: false)
diff --git a/MapboxNavigation/NavigationMapView.swift b/MapboxNavigation/NavigationMapView.swift
index 8cb35c71..5eb5f5cf 100644
--- a/MapboxNavigation/NavigationMapView.swift
+++ b/MapboxNavigation/NavigationMapView.swift
@@ -968,31 +968,8 @@ open class NavigationMapView: MGLMapView, UIGestureRecognizerDelegate {
return
}
- let streetsSourceIdentifiers: [String] = style.sources.compactMap {
- $0 as? MGLVectorTileSource
- }.filter {
- $0.isMapboxStreets
- }.map {
- $0.identifier
- }
-
- for layer in style.layers where layer is MGLSymbolStyleLayer {
- let layer = layer as! MGLSymbolStyleLayer
- guard let sourceIdentifier = layer.sourceIdentifier,
- streetsSourceIdentifiers.contains(sourceIdentifier) else {
- continue
- }
- guard let text = layer.text else {
- continue
- }
-
- // Road labels should match road signage.
- let locale = layer.sourceLayerIdentifier == "road_label" ? Locale(identifier: "mul") : nil
-
- let localizedText = text.mgl_expressionLocalized(into: locale)
- if localizedText != text {
- layer.text = localizedText
- }
+ for layer in style.layers {
+ style.removeLayer(layer)
}
}
|
Reduced the default minimum frame rate (on battery power away from maneuvers) from 30 fps to 20 fps for improved battery performance. The frame rate while plugged in remains 30 fps, and the frame rate during the 10 seconds around a maneuver remains at 60 fps or 120 fps, depending on the device.
/cc @frederoni @JThramer