Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
Restores fix to MGLOpenGLStyleLayer memory-related crash (#10765)
Browse files Browse the repository at this point in the history
Revert this commit to see integration test fail.
  • Loading branch information
Andrew Kitchen authored and akitchen committed Jan 20, 2018
1 parent 2c48871 commit d0193c5
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 21 deletions.
9 changes: 2 additions & 7 deletions platform/darwin/src/MGLOpenGLStyleLayer.mm
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@ void MGLDrawCustomStyleLayer(void *context, const mbgl::style::CustomLayerRender
when creating an OpenGL style layer.
*/
void MGLFinishCustomStyleLayer(void *context) {
//TODO: AK: revert once failing test established
MGLOpenGLStyleLayer *layer = (__bridge MGLOpenGLStyleLayer *)context;
MGLOpenGLStyleLayer *layer = (__bridge_transfer MGLOpenGLStyleLayer *)context;
[layer willMoveFromMapView:layer.style.mapView];
}

Expand Down Expand Up @@ -102,8 +101,7 @@ - (instancetype)initWithIdentifier:(NSString *)identifier {
MGLPrepareCustomStyleLayer,
MGLDrawCustomStyleLayer,
MGLFinishCustomStyleLayer,
//TODO: AK: revert once failing test established
(__bridge void *)self);
(__bridge_retained void *)self);
return self = [super initWithPendingLayer:std::move(layer)];
}

Expand All @@ -118,10 +116,7 @@ - (void)setStyle:(MGLStyle *)style {
[NSException raise:@"MGLLayerReuseException"
format:@"%@ cannot be added to more than one MGLStyle at a time.", self];
}
//TODO: AK: remove once failing test established
_style.openGLLayers[self.identifier] = nil;
_style = style;
_style.openGLLayers[self.identifier] = self;
}

- (void)addToStyle:(MGLStyle *)style belowLayer:(MGLStyleLayer *)otherLayer {
Expand Down
4 changes: 0 additions & 4 deletions platform/darwin/src/MGLStyle.mm
Original file line number Diff line number Diff line change
Expand Up @@ -77,8 +77,6 @@ @interface MGLStyle()
@property (nonatomic, readonly, weak) MGLMapView *mapView;
@property (nonatomic, readonly) mbgl::style::Style *rawStyle;
@property (readonly, copy, nullable) NSURL *URL;
//TODO: AK: remove once failing test established
@property (nonatomic, readwrite, strong) NS_MUTABLE_DICTIONARY_OF(NSString *, MGLOpenGLStyleLayer *) *openGLLayers;
@property (nonatomic) NS_MUTABLE_DICTIONARY_OF(NSString *, NS_DICTIONARY_OF(NSObject *, MGLTextLanguage *) *) *localizedLayersByIdentifier;

@end
Expand Down Expand Up @@ -170,8 +168,6 @@ - (instancetype)initWithRawStyle:(mbgl::style::Style *)rawStyle mapView:(MGLMapV
if (self = [super init]) {
_mapView = mapView;
_rawStyle = rawStyle;
//TODO: AK: remove once failing test established
_openGLLayers = [NSMutableDictionary dictionary];
_localizedLayersByIdentifier = [NSMutableDictionary dictionary];
}
return self;
Expand Down
3 changes: 0 additions & 3 deletions platform/darwin/src/MGLStyle_Private.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,6 @@ namespace mbgl {

- (nullable NS_ARRAY_OF(MGLAttributionInfo *) *)attributionInfosWithFontSize:(CGFloat)fontSize linkColor:(nullable MGLColor *)linkColor;

//TODO: AK: remove once failing test established
@property (nonatomic, readonly, strong) NS_MUTABLE_DICTIONARY_OF(NSString *, MGLOpenGLStyleLayer *) *openGLLayers;

- (void)setStyleClasses:(NS_ARRAY_OF(NSString *) *)appliedClasses transitionDuration:(NSTimeInterval)transitionDuration;

@end
Expand Down
8 changes: 1 addition & 7 deletions platform/ios/app/MBXViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -1683,11 +1683,8 @@ - (IBAction)cycleStyles:(__unused id)sender
numStyleURLMethods, (unsigned long)styleNames.count);
});

MGLStyle *oldStyle = self.mapView.style;
MGLStyleLayer *oldLayer = [oldStyle layerWithIdentifier:@"test-layer"];
[oldStyle removeLayer:oldLayer];

self.styleIndex = (self.styleIndex + 1) % styleNames.count;

self.mapView.styleURL = styleURLs[self.styleIndex];

UIButton *titleButton = (UIButton *)self.navigationItem.titleView;
Expand Down Expand Up @@ -1934,9 +1931,6 @@ - (void)mapView:(MGLMapView *)mapView didFinishLoadingStyle:(MGLStyle *)style
// that a device with an English-language locale is already effectively
// using locale-based country labels.
_usingLocaleBasedCountryLabels = [[self bestLanguageForUser] isEqualToString:@"en"];

MGLOpenGLStyleLayer *glLayer = [[MGLOpenGLStyleLayer alloc] initWithIdentifier:@"test-layer"];
[style addLayer:glLayer];
}

- (void)mapViewRegionIsChanging:(MGLMapView *)mapView
Expand Down

0 comments on commit d0193c5

Please sign in to comment.