From be52499091ac25d67a1e4f68bffc153d6e108585 Mon Sep 17 00:00:00 2001 From: Fabian Guerra Date: Thu, 16 Nov 2017 17:58:18 -0500 Subject: [ios] Test code to reproduce a crash. --- platform/ios/app/MBXViewController.m | 40 + platform/ios/app/Main.storyboard | 28 +- platform/ios/app/metro-line.geojson | 4370 ++++++++++++++++++++++++++++ platform/ios/ios.xcodeproj/project.pbxproj | 4 + 4 files changed, 4433 insertions(+), 9 deletions(-) create mode 100644 platform/ios/app/metro-line.geojson diff --git a/platform/ios/app/MBXViewController.m b/platform/ios/app/MBXViewController.m index 2c3d26b489..cf8c1ba341 100644 --- a/platform/ios/app/MBXViewController.m +++ b/platform/ios/app/MBXViewController.m @@ -1877,6 +1877,46 @@ typedef NS_ENUM(NSInteger, MBXSettingsMiscellaneousRows) { // that a device with an English-language locale is already effectively // using locale-based country labels. _usingLocaleBasedCountryLabels = [[self bestLanguageForUser] isEqualToString:@"en"]; + +} +- (IBAction)crashMe:(id)sender { + dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{ + NSString *path = [[NSBundle mainBundle] pathForResource:@"metro-line" ofType:@"geojson"]; + + NSData *data = [NSData dataWithContentsOfFile:path]; + + dispatch_async(dispatch_get_main_queue(), ^{ + [self drawShapeCollection:data]; + }); + }); +} + +- (void)drawShapeCollection:(NSData *)data { + + // Use [MGLShape shapeWithData:encoding:error:] to create a MGLShapeCollectionFeature from GeoJSON data. + MGLShape *feature = [MGLShape shapeWithData:data encoding:NSUTF8StringEncoding error:NULL]; + + // Create source and add it to the map style. + MGLShapeSource *source = [[MGLShapeSource alloc] initWithIdentifier:@"transit" shape:feature options:nil]; + [self.mapView.style addSource:source]; + + // Create line style layer. + MGLLineStyleLayer *lineLayer = [[MGLLineStyleLayer alloc] initWithIdentifier:@"rail-line" source: source]; + lineLayer.lineJoin = [MGLStyleValue valueWithRawValue:[NSValue valueWithMGLLineJoin:MGLLineJoinRound]]; + lineLayer.lineCap = [MGLStyleValue valueWithRawValue:[NSValue valueWithMGLLineCap:MGLLineCapRound]]; + lineLayer.lineColor = [MGLStyleValue valueWithRawValue:[UIColor redColor]]; + lineLayer.lineWidth = [MGLStyleValue valueWithInterpolationMode:MGLInterpolationModeInterval + cameraStops:@{@14: [MGLStyleValue valueWithRawValue:@5], + @18: [MGLStyleValue valueWithRawValue:@20] + } + options:@{MGLStyleFunctionOptionDefaultValue:[MGLConstantStyleValue valueWithRawValue:@5]}]; +// lineLayer.predicate = [NSPredicate predicateWithFormat:@"TYPE = 'Rail line'"]; + + + + // Add style layers to the map view's style. + [self.mapView.style addLayer:lineLayer]; + } - (void)mapViewRegionIsChanging:(MGLMapView *)mapView diff --git a/platform/ios/app/Main.storyboard b/platform/ios/app/Main.storyboard index 507582213f..43f0ad2a7f 100644 --- a/platform/ios/app/Main.storyboard +++ b/platform/ios/app/Main.storyboard @@ -1,11 +1,11 @@ - + - + @@ -26,6 +26,16 @@ + + + @@ -34,7 +44,7 @@