diff options
author | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-07-23 00:13:01 +0300 |
---|---|---|
committer | Alexander Shalamov <alexander.shalamov@mapbox.com> | 2019-07-23 10:37:44 +0300 |
commit | 46972916a87eadb9541899a91f3417b8db459b7f (patch) | |
tree | 8af9094f0db2136604228300b1212a10e135e915 | |
parent | dabf5d0c3a76f9fbe8b866f64f51accf12d1a2a6 (diff) | |
download | qtlocation-mapboxgl-46972916a87eadb9541899a91f3417b8db459b7f.tar.gz |
ios changes
-rw-r--r-- | platform/ios/CHANGELOG.md | 3 | ||||
-rw-r--r-- | platform/ios/app/Info.plist | 28 | ||||
-rw-r--r-- | platform/ios/app/MBXViewController.m | 101 | ||||
-rw-r--r-- | platform/ios/ios.xcodeproj/project.pbxproj | 14 | ||||
-rw-r--r-- | platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme | 2 | ||||
-rw-r--r-- | platform/ios/src/MGLMapView.mm | 9 | ||||
-rw-r--r-- | platform/macos/CHANGELOG.md | 4 |
7 files changed, 126 insertions, 35 deletions
diff --git a/platform/ios/CHANGELOG.md b/platform/ios/CHANGELOG.md index e529607a48..4c2ccd102c 100644 --- a/platform/ios/CHANGELOG.md +++ b/platform/ios/CHANGELOG.md @@ -8,6 +8,9 @@ Mapbox welcomes participation and contributions from everyone. Please read [CONT * Fixed flickering on style change for the same tile set ([#15127](https://github.com/mapbox/mapbox-gl-native/pull/15127)) +### Other changes + +* Improved feature querying performance (focussed on roads). ([#15183](https://github.com/mapbox/mapbox-gl-native/pull/15183)) ## 5.2.0 diff --git a/platform/ios/app/Info.plist b/platform/ios/app/Info.plist index c302f306a6..d5f7d4319f 100644 --- a/platform/ios/app/Info.plist +++ b/platform/ios/app/Info.plist @@ -9,7 +9,7 @@ <key>CFBundleExecutable</key> <string>$(EXECUTABLE_NAME)</string> <key>CFBundleIdentifier</key> - <string>com.mapbox.MapboxGL</string> + <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string> <key>CFBundleInfoDictionaryVersion</key> <string>6.0</string> <key>CFBundleName</key> @@ -26,12 +26,23 @@ <true/> <key>NSHumanReadableCopyright</key> <string>© 2014–2019 Mapbox</string> + <key>NSLocationAlwaysAndWhenInUseUsageDescription</key> + <string>The map will display your location. If you choose Always, the map may also use your location when it isn’t visible in order to improve OpenStreetMap and Mapbox products.</string> <key>NSLocationAlwaysUsageDescription</key> <string>The map will display your location. The map may also use your location when it isn’t visible in order to improve OpenStreetMap and Mapbox products.</string> <key>NSLocationWhenInUseUsageDescription</key> <string>The map will display your location.</string> - <key>NSLocationAlwaysAndWhenInUseUsageDescription</key> - <string>The map will display your location. If you choose Always, the map may also use your location when it isn’t visible in order to improve OpenStreetMap and Mapbox products.</string> + <key>UIApplicationShortcutItems</key> + <array> + <dict> + <key>UIApplicationShortcutItemIconFile</key> + <string>settings</string> + <key>UIApplicationShortcutItemTitle</key> + <string>Settings</string> + <key>UIApplicationShortcutItemType</key> + <string>$(PRODUCT_BUNDLE_IDENTIFIER).settings</string> + </dict> + </array> <key>UILaunchStoryboardName</key> <string>LaunchScreen</string> <key>UIMainStoryboardFile</key> @@ -53,16 +64,5 @@ <string>UIInterfaceOrientationLandscapeLeft</string> <string>UIInterfaceOrientationLandscapeRight</string> </array> - <key>UIApplicationShortcutItems</key> - <array> - <dict> - <key>UIApplicationShortcutItemTitle</key> - <string>Settings</string> - <key>UIApplicationShortcutItemType</key> - <string>$(PRODUCT_BUNDLE_IDENTIFIER).settings</string> - <key>UIApplicationShortcutItemIconFile</key> - <string>settings</string> - </dict> - </array> </dict> </plist> diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 2fb95e1b17..6ce4c77e14 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -17,6 +17,8 @@ #import "../src/MGLMapView_Experimental.h" #import <objc/runtime.h> +#import <os/log.h> +#import <os/signpost.h> static const CLLocationCoordinate2D WorldTourDestinations[] = { { .latitude = 38.8999418, .longitude = -77.033996 }, @@ -63,6 +65,7 @@ typedef NS_ENUM(NSInteger, MBXSettingsAnnotationsRows) { MBXSettingsAnnotationsTestShapes, MBXSettingsAnnotationsCustomCallout, MBXSettingsAnnotationsQueryAnnotations, + MBXSettingsAnnotationsQueryRoadsAroundDC, MBXSettingsAnnotationsCustomUserDot, MBXSettingsAnnotationsRemoveAnnotations, MBXSettingsAnnotationSelectRandomOffscreenPointAnnotation, @@ -215,10 +218,36 @@ CLLocationCoordinate2D randomWorldCoordinate() { @property (nonatomic) NSMutableArray<UIWindow *> *helperWindows; @property (nonatomic) NSMutableArray<UIView *> *contentInsetsOverlays; +@property (nonatomic) os_log_t log; +@property (nonatomic) os_signpost_id_t signpost; +@property (nonatomic) NSMutableArray<dispatch_block_t> *pendingIdleBlocks; + @end +#define OS_SIGNPOST_BEGIN_WITH_SELF(self, name) \ + if (@available(iOS 12.0, *)) { os_signpost_interval_begin(self.log, self.signpost, name); } + +#define OS_SIGNPOST_END_WITH_SELF(self, name) \ + if (@available(iOS 12.0, *)) { os_signpost_interval_end(self.log, self.signpost, name); } + +#define OS_SIGNPOST_BEGIN(name) \ + OS_SIGNPOST_BEGIN_WITH_SELF(self, name) + +#define OS_SIGNPOST_END(name) \ + OS_SIGNPOST_END_WITH_SELF(self, name) + +#define OS_SIGNPOST_EVENT(name, ...) \ + if (@available(iOS 12.0, *)) { os_signpost_event_emit(self.log, self.signpost, name, ##__VA_ARGS__); } + +// Expose properties for testing @interface MGLMapView (MBXViewController) @property (nonatomic) NSDictionary *annotationViewReuseQueueByIdentifier; +- (void)setNeedsRerender; +- (UIEdgeInsets)defaultEdgeInsetsForShowAnnotations; +@end + +@interface MGLStyle (MBXViewController) +@property (nonatomic, readonly, copy) NSArray<MGLVectorStyleLayer *> *roadStyleLayers; @end @implementation MBXViewController @@ -234,6 +263,12 @@ CLLocationCoordinate2D randomWorldCoordinate() { { [super viewDidLoad]; + self.pendingIdleBlocks = [NSMutableArray array]; + self.log = os_log_create("com.mapbox.iosapp", "MBXViewController"); + if (@available(iOS 12.0, *)) { + self.signpost = os_signpost_id_generate(self.log); + } + // Keep track of current map state and debug preferences, // saving and restoring when the application's state changes. self.currentState = [MBXStateManager sharedManager].currentState; @@ -390,6 +425,7 @@ CLLocationCoordinate2D randomWorldCoordinate() { @"Add Test Shapes", @"Add Point With Custom Callout", @"Query Annotations", + @"Query Roads around DC", [NSString stringWithFormat:@"%@ Custom User Dot", (_customUserLocationAnnnotationEnabled ? @"Disable" : @"Enable")], @"Remove Annotations", @"Select an offscreen point annotation", @@ -520,22 +556,22 @@ CLLocationCoordinate2D randomWorldCoordinate() { switch (indexPath.row) { case MBXSettingsAnnotations100Views: - [self parseFeaturesAddingCount:100 usingViews:YES]; + [self parseFeaturesAddingCount:100 usingViews:YES completionHandler:NULL]; break; case MBXSettingsAnnotations1000Views: - [self parseFeaturesAddingCount:1000 usingViews:YES]; + [self parseFeaturesAddingCount:1000 usingViews:YES completionHandler:NULL]; break; case MBXSettingsAnnotations10000Views: - [self parseFeaturesAddingCount:10000 usingViews:YES]; + [self parseFeaturesAddingCount:10000 usingViews:YES completionHandler:NULL]; break; case MBXSettingsAnnotations100Sprites: - [self parseFeaturesAddingCount:100 usingViews:NO]; + [self parseFeaturesAddingCount:100 usingViews:NO completionHandler:NULL]; break; case MBXSettingsAnnotations1000Sprites: - [self parseFeaturesAddingCount:1000 usingViews:NO]; + [self parseFeaturesAddingCount:1000 usingViews:NO completionHandler:NULL]; break; case MBXSettingsAnnotations10000Sprites: - [self parseFeaturesAddingCount:10000 usingViews:NO]; + [self parseFeaturesAddingCount:10000 usingViews:NO completionHandler:NULL]; break; case MBXSettingsAnnotationAnimation: [self animateAnnotationView]; @@ -549,6 +585,25 @@ CLLocationCoordinate2D randomWorldCoordinate() { case MBXSettingsAnnotationsQueryAnnotations: [self testQueryPointAnnotations]; break; + + case MBXSettingsAnnotationsQueryRoadsAroundDC: + { + __weak __typeof__(self) weakSelf = self; + [self parseFeaturesAddingCount:100 usingViews:YES completionHandler:^{ + [weakSelf.mapView setNeedsRerender]; + [weakSelf.pendingIdleBlocks addObject:^{ + __typeof__(self) strongSelf = weakSelf; + NSLog(@"BEGIN: query-roads-batch"); + OS_SIGNPOST_BEGIN_WITH_SELF(strongSelf, "query-roads-batch"); + for (int i = 0; i < 10; i++) { + [strongSelf queryRoads]; + } + OS_SIGNPOST_END_WITH_SELF(strongSelf, "query-roads-batch"); + NSLog(@"END: query-roads-batch"); + }]; + }]; + } + break; case MBXSettingsAnnotationsCustomUserDot: [self toggleCustomUserDot]; break; @@ -815,7 +870,7 @@ CLLocationCoordinate2D randomWorldCoordinate() { #pragma mark - Debugging Actions -- (void)parseFeaturesAddingCount:(NSUInteger)featuresCount usingViews:(BOOL)useViews +- (void)parseFeaturesAddingCount:(NSUInteger)featuresCount usingViews:(BOOL)useViews completionHandler:(nullable dispatch_block_t)completion { [self.mapView removeAnnotations:self.mapView.annotations]; @@ -850,7 +905,11 @@ CLLocationCoordinate2D randomWorldCoordinate() { dispatch_async(dispatch_get_main_queue(), ^ { [self.mapView addAnnotations:annotations]; - [self.mapView showAnnotations:annotations animated:YES]; + UIEdgeInsets insets = [self.mapView defaultEdgeInsetsForShowAnnotations]; + [self.mapView showAnnotations:annotations + edgePadding:insets + animated:YES + completionHandler:completion]; }); } }); @@ -1765,6 +1824,21 @@ CLLocationCoordinate2D randomWorldCoordinate() { return filePath; } +#pragma mark - Query Rendered Features + +- (void)queryRoads +{ + OS_SIGNPOST_BEGIN("query-roads"); + + NSArray *roadStyleLayerIdentifiers = [self.mapView.style.roadStyleLayers valueForKey:@"identifier"]; + NSArray *visibleRoadFeatures = [self.mapView visibleFeaturesInRect:self.mapView.bounds inStyleLayersWithIdentifiers:[NSSet setWithArray:roadStyleLayerIdentifiers]]; + + OS_SIGNPOST_END("query-roads"); + OS_SIGNPOST_EVENT("query-roads-count", "%lu", (unsigned long)visibleRoadFeatures.count); + + NSLog(@"Roads & labels feature count: %lu", (unsigned long)visibleRoadFeatures.count); +} + #pragma mark - Random World Tour - (void)addAnnotations:(NSInteger)numAnnotations aroundCoordinate:(CLLocationCoordinate2D)coordinate radius:(CLLocationDistance)radius { @@ -1989,6 +2063,7 @@ CLLocationCoordinate2D randomWorldCoordinate() { } } } + free(methods); NSAssert(numStyleURLMethods == styleNames.count, @"MGLStyle provides %u default styles but iosapp only knows about %lu of them.", numStyleURLMethods, (unsigned long)styleNames.count); @@ -2047,6 +2122,16 @@ CLLocationCoordinate2D randomWorldCoordinate() { #pragma mark - MGLMapViewDelegate +- (void)mapViewDidBecomeIdle:(MGLMapView *)mapView +{ + NSArray *blocks = [self.pendingIdleBlocks copy]; + [self.pendingIdleBlocks removeAllObjects]; + + for (dispatch_block_t block in blocks) { + block(); + } +} + - (MGLAnnotationView *)mapView:(MGLMapView *)mapView viewForAnnotation:(id<MGLAnnotation>)annotation { if (annotation == mapView.userLocation) diff --git a/platform/ios/ios.xcodeproj/project.pbxproj b/platform/ios/ios.xcodeproj/project.pbxproj index 5f0d29a5e7..c30c9c6c35 100644 --- a/platform/ios/ios.xcodeproj/project.pbxproj +++ b/platform/ios/ios.xcodeproj/project.pbxproj @@ -2977,7 +2977,7 @@ }; DA1DC9491CB6C1C2006E619F = { CreatedOnToolsVersion = 7.3; - DevelopmentTeam = GJZR2MEM28; + DevelopmentTeam = CR2YZVBNH7; LastSwiftMigration = 0820; }; DA2E88501CC036F400F24E7B = { @@ -3945,10 +3945,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; - DEVELOPMENT_TEAM = GJZR2MEM28; + DEVELOPMENT_TEAM = CR2YZVBNH7; INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; + PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL.Alex; PRODUCT_NAME = "Mapbox GL"; }; name = RelWithDebInfo; @@ -4297,10 +4297,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; - DEVELOPMENT_TEAM = GJZR2MEM28; + DEVELOPMENT_TEAM = CR2YZVBNH7; INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; + PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL.Alex; PRODUCT_NAME = "Mapbox GL"; }; name = Debug; @@ -4311,10 +4311,10 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ANALYZER_LOCALIZABILITY_EMPTY_CONTEXT = NO; CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = NO; - DEVELOPMENT_TEAM = GJZR2MEM28; + DEVELOPMENT_TEAM = CR2YZVBNH7; INFOPLIST_FILE = "$(SRCROOT)/app/Info.plist"; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; - PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL; + PRODUCT_BUNDLE_IDENTIFIER = com.mapbox.MapboxGL.Alex; PRODUCT_NAME = "Mapbox GL"; }; name = Release; diff --git a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme index 1f8969faf7..2119066815 100644 --- a/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme +++ b/platform/ios/ios.xcodeproj/xcshareddata/xcschemes/iosapp.xcscheme @@ -65,7 +65,7 @@ </AdditionalOptions> </LaunchAction> <ProfileAction - buildConfiguration = "Release" + buildConfiguration = "RelWithDebInfo" shouldUseLaunchSchemeArgsEnv = "YES" savedToolIdentifier = "" useCustomWorkingDirectory = "NO" diff --git a/platform/ios/src/MGLMapView.mm b/platform/ios/src/MGLMapView.mm index d77f94d8ba..eb332e7c28 100644 --- a/platform/ios/src/MGLMapView.mm +++ b/platform/ios/src/MGLMapView.mm @@ -5050,14 +5050,19 @@ public: completion:NULL]; } -- (void)showAnnotations:(NSArray<id <MGLAnnotation>> *)annotations animated:(BOOL)animated +- (UIEdgeInsets)defaultEdgeInsetsForShowAnnotations { CGFloat maximumPadding = 100; CGFloat yPadding = (self.frame.size.height / 5 <= maximumPadding) ? (self.frame.size.height / 5) : maximumPadding; CGFloat xPadding = (self.frame.size.width / 5 <= maximumPadding) ? (self.frame.size.width / 5) : maximumPadding; - + UIEdgeInsets edgeInsets = UIEdgeInsetsMake(yPadding, xPadding, yPadding, xPadding); + return edgeInsets; +} +- (void)showAnnotations:(NSArray<id <MGLAnnotation>> *)annotations animated:(BOOL)animated +{ + UIEdgeInsets edgeInsets = [self defaultEdgeInsetsForShowAnnotations]; [self showAnnotations:annotations edgePadding:edgeInsets animated:animated completionHandler:nil]; } diff --git a/platform/macos/CHANGELOG.md b/platform/macos/CHANGELOG.md index 88fa37052b..0f3ab870af 100644 --- a/platform/macos/CHANGELOG.md +++ b/platform/macos/CHANGELOG.md @@ -18,13 +18,11 @@ * The `-[MGLMapView setCamera:withDuration:animationTimingFunction:edgePadding:completionHandler:]` method now adds the current value of the `MGLMapView.contentInsets` property to the `edgePadding` parameter. ([#14813](https://github.com/mapbox/mapbox-gl-native/pull/14813)) * Updated "map ID" to the more accurate term "tileset ID" in documentation; updated "style's Map ID" to the more accurate term "style URL". ([#15116](https://github.com/mapbox/mapbox-gl-native/pull/15116)) - -### Other changes - * Added variants of multiple animated `MGLMapView` methods that accept completion handlers ([#14381](https://github.com/mapbox/mapbox-gl-native/pull/14381)): * `-[MGLMapView setVisibleCoordinateBounds:edgePadding:animated:completionHandler:]` * `-[MGLMapView setContentInsets:animated:completionHandler:]` * `-[MGLMapView showAnnotations:edgePadding:animated:completionHandler:]` +* Improved feature querying performance (focussed on roads). ([#15183](https://github.com/mapbox/mapbox-gl-native/pull/15183)) ## 0.14.0 - May 22, 2018 |