(iOS) Prevent app crash (hopefully)
MODIFY
src/ios/GoogleMaps/MyPluginLayer.m
src/ios/GoogleMaps/MyPluginLayer.m
@@ -182,7 +182,6 @@ BOOL hasCordovaStatusBar = NO; // YES if the app has cordova-plugin-statusbar
- (void)updateViewPosition:(GoogleMapsViewController *)mapCtrl {
-
CGFloat zoomScale = self.webView.scrollView.zoomScale;
CGPoint offset = self.webView.scrollView.contentOffset;
@@ -194,17 +193,19 @@ BOOL hasCordovaStatusBar = NO; // YES if the app has cordova-plugin-statusbar
return;
}
- NSDictionary *domInfo = [self.pluginScrollView.debugView.HTMLNodes objectForKey:mapCtrl.mapDivId];
+ NSDictionary *domInfo = nil;
+ @synchronized(self.pluginScrollView.debugView.HTMLNodes) {
+ domInfo = [self.pluginScrollView.debugView.HTMLNodes objectForKey:mapCtrl.mapDivId];
if (domInfo == nil) {
return;
}
+ }
NSString *rectStr = [domInfo objectForKey:@"size"];
if (rectStr == nil || [rectStr isEqual: @"null"]) {
return;
}
-
__block CGRect rect = CGRectFromString(rectStr);
rect.origin.x *= zoomScale;
rect.origin.y *= zoomScale;
@@ -294,7 +295,7 @@ BOOL hasCordovaStatusBar = NO; // YES if the app has cordova-plugin-statusbar
}
CGPoint clickPointAsHtml = CGPointMake(point.x * zoomScale, point.y * zoomScale);
-
+@synchronized(self.pluginScrollView.debugView.HTMLNodes) {
while(mapId = [mapIDs nextObject]) {
mapCtrl = [self.pluginScrollView.debugView.mapCtrls objectForKey:mapId];
if (!mapCtrl.mapDivId) {
@@ -386,7 +387,7 @@ BOOL hasCordovaStatusBar = NO; // YES if the app has cordova-plugin-statusbar
return hitView;
}
-
+}
UIView *hitView =[self.webView hitTest:point withEvent:event];
//NSLog(@"--> (hit test) hit = %@", hitView.class);

MODIFY
src/ios/GoogleMaps/PluginMap.m
src/ios/GoogleMaps/PluginMap.m
[self.mapCtrl.view removeFromSuperview];
[self.mapCtrl.view setFrame:CGRectMake(0, -1000, 100, 100)];
[self.mapCtrl.view setNeedsDisplay];
+
+ NSArray *keys = [self.mapCtrl.plugins allKeys];
+ CDVPlugin<MyPlgunProtocol> *plugin;
+ for (int i = 0; i < [keys count]; i++) {
+ plugin = [self.mapCtrl.plugins objectForKey:[keys objectAtIndex:i]];
+ [plugin pluginUnload];
+ plugin = nil;
+ }
+
+
[self.mapCtrl.plugins removeAllObjects];
self.mapCtrl.map = nil;
self.mapCtrl = nil;

(iOS) Prevent app crash (hopefully)