Skip to content

Commit

Permalink
Merge commit 'b623557c23567442bb325b3f1f4a46bad39ca022' into eres
Browse files Browse the repository at this point in the history
# Conflicts:
#	package.json
  • Loading branch information
Nizam Moidu committed Apr 23, 2019
2 parents cbf69ca + b623557 commit 7dd560a
Show file tree
Hide file tree
Showing 6 changed files with 29 additions and 13 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ yarn-error.log

# Bundle artifact
*.jsbundle
example/ios/bundles
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Change Log

## 0.24.2 (April 17, 2019 )
* iOS: [#2818](https://github.com/react-native-community/react-native-maps/pull/2818) Google Maps - Weak refs to gesture targets to address memory leak

## 0.24.1 (April 16, 2019 )
* iOS: [#2815](https://github.com/react-native-community/react-native-maps/pull/2815) Google Maps - Free instance variable in getActionForTarget to address memory leak

# Change Log
## 0.24.0 (April 11, 2019 )
* Common: [#2740](https://github.com/react-native-community/react-native-maps/pull/2740) Fix deprecated UIManager usage when accessing component names
Expand Down
4 changes: 2 additions & 2 deletions example/ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ PODS:
- GoogleMaps/Base
- React (0.59.3):
- React/Core (= 0.59.3)
- react-native-google-maps (0.24.0):
- react-native-google-maps (0.24.2):
- Google-Maps-iOS-Utils (= 2.1.0)
- GoogleMaps (= 2.5.0)
- React
- react-native-maps (0.24.0):
- react-native-maps (0.24.2):
- React
- React/Core (0.59.3):
- yoga (= 0.59.3.React)
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ org.gradle.jvmargs=-Xmx1536m
# org.gradle.parallel=true

VERSION_CODE=4
VERSION_NAME=0.24.0
VERSION_NAME=0.24.2
GROUP=com.airbnb.android

POM_DESCRIPTION=React Native Map view component for Android
Expand Down
25 changes: 16 additions & 9 deletions lib/ios/AirGoogleMaps/AIRGoogleMap.m
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ @interface AIRGoogleMap ()

- (id)eventFromCoordinate:(CLLocationCoordinate2D)coordinate;

@property (nonatomic, strong) NSMutableDictionary<NSNumber *, NSDictionary*> *origGestureRecognizersMeta;

@end

@implementation AIRGoogleMap
Expand All @@ -62,7 +64,6 @@ @implementation AIRGoogleMap
BOOL _initialCameraSetOnLoad;
BOOL _didCallOnMapReady;
BOOL _didMoveToWindow;
NSMutableDictionary<NSNumber *, NSDictionary*> *_origGestureRecognizersMeta;
BOOL _zoomTapEnabled;
}

Expand Down Expand Up @@ -91,7 +92,7 @@ - (instancetype)init
options:NSKeyValueObservingOptionNew
context:NULL];

_origGestureRecognizersMeta = [[NSMutableDictionary alloc] init];
self.origGestureRecognizersMeta = [[NSMutableDictionary alloc] init];
}
return self;
}
Expand Down Expand Up @@ -619,6 +620,7 @@ -(SEL)getActionForTarget:(NSObject*)target {
}
}
}
free(ivars);
return action;
}

Expand All @@ -628,7 +630,7 @@ -(void)overrideGestureRecognizersForView:(UIView*)view {
NSArray* grs = view.gestureRecognizers;
for (UIGestureRecognizer* gestureRecognizer in grs) {
NSNumber* grHash = [NSNumber numberWithUnsignedInteger:gestureRecognizer.hash];
if([_origGestureRecognizersMeta objectForKey:grHash] != nil)
if([self.origGestureRecognizersMeta objectForKey:grHash] != nil)
continue; //already patched

//get original handlers
Expand All @@ -639,7 +641,10 @@ -(void)overrideGestureRecognizersForView:(UIView*)view {
NSObject* target = [trg valueForKey:@"target"];
SEL action = [self getActionForTarget:trg];
isZoomTapGesture = [NSStringFromSelector(action) isEqualToString:@"handleZoomTapGesture:"];
[origTargetsActions addObject:@{@"target": target, @"action": NSStringFromSelector(action)}];
[origTargetsActions addObject:@{
@"target": [NSValue valueWithNonretainedObject:target],
@"action": NSStringFromSelector(action)
}];
}
if (isZoomTapGesture && self.zoomTapEnabled == NO) {
[view removeGestureRecognizer:gestureRecognizer];
Expand All @@ -648,15 +653,16 @@ -(void)overrideGestureRecognizersForView:(UIView*)view {

//replace with extendedMapGestureHandler
for (NSDictionary* origTargetAction in origTargetsActions) {
NSObject* target = [origTargetAction objectForKey:@"target"];
NSValue* targetValue = [origTargetAction objectForKey:@"target"];
NSObject* target = [targetValue nonretainedObjectValue];
NSString* actionString = [origTargetAction objectForKey:@"action"];
SEL action = NSSelectorFromString(actionString);
[gestureRecognizer removeTarget:target action:action];
}
[gestureRecognizer addTarget:self action:@selector(extendedMapGestureHandler:)];

[_origGestureRecognizersMeta setObject:@{@"targets": origTargetsActions}
forKey:grHash];
[self.origGestureRecognizersMeta setObject:@{@"targets": origTargetsActions}
forKey:grHash];
}
}

Expand Down Expand Up @@ -734,10 +740,11 @@ - (id)extendedMapGestureHandler:(UIGestureRecognizer*)gestureRecognizer {
}

if (performOriginalActions) {
NSDictionary* origMeta = [_origGestureRecognizersMeta objectForKey:grHash];
NSDictionary* origMeta = [self.origGestureRecognizersMeta objectForKey:grHash];
NSDictionary* origTargets = [origMeta objectForKey:@"targets"];
for (NSDictionary* origTarget in origTargets) {
NSObject* target = [origTarget objectForKey:@"target"];
NSValue* targetValue = [origTarget objectForKey:@"target"];
NSObject* target = [targetValue nonretainedObjectValue];
NSString* actionString = [origTarget objectForKey:@"action"];
SEL action = NSSelectorFromString(actionString);
#pragma clang diagnostic push
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "React Native Mapview component for iOS + Android",
"main": "index.js",
"author": "Leland Richardson <leland.m.richardson@gmail.com>",
"version": "0.24.0-eres",
"version": "0.24.2-eres",
"scripts": {
"start": "node node_modules/react-native/local-cli/cli.js start",
"run:packager": "./node_modules/react-native/scripts/packager.sh",
Expand Down

0 comments on commit 7dd560a

Please sign in to comment.