This repository was archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
[google_maps_flutter] Fix iOS crash by observing map frame change only once #3426
Merged
fluttergithubbot
merged 19 commits into
flutter:main
from
guykogus:google_maps_ios_observer
Mar 21, 2022
Merged
Changes from all commits
Commits
Show all changes
19 commits
Select commit
Hold shift + click to select a range
1f3c635
Fix observing frame change only once
guykogus 2ff340f
Update pubspec and CHANGELOG
guykogus 6a25978
Remove hacky flags
guykogus 94456f9
Add tests
guykogus 416cf25
Update CHANGELOG
guykogus 9bca4e0
Fix formatting
guykogus 9f483b1
Add missing licence
guykogus 6ec103d
Create mock map view to test counting the frame observers
guykogus cb7f8f4
Clean code
guykogus f74a95a
Create modulemap and move test class
guykogus 0529ae2
PR commits
guykogus 672bdbd
Fix formatting
guykogus 5a9477a
Add comment
guykogus a9cc1b4
Clean comment
guykogus 95f8ca3
Fix CHANGELOG
guykogus dbbc976
PR fixes
guykogus f2d83f3
Add JsonConversions.h to plugin header
guykogus 9c39b5e
Move headers to umbrella
guykogus fe83a32
Format
guykogus File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
4 changes: 4 additions & 0 deletions
4
packages/google_maps_flutter/google_maps_flutter/CHANGELOG.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...r/google_maps_flutter/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
.../google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
@import GoogleMaps; | ||
|
||
/** | ||
* Defines a map view used for testing key-value observing. | ||
*/ | ||
@interface PartiallyMockedMapView : GMSMapView | ||
|
||
/** | ||
* The number of times that the `frame` KVO has been added. | ||
*/ | ||
@property(nonatomic, assign, readonly) NSInteger frameObserverCount; | ||
|
||
@end |
34 changes: 34 additions & 0 deletions
34
.../google_maps_flutter/google_maps_flutter/example/ios/RunnerTests/PartiallyMockedMapView.m
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import "PartiallyMockedMapView.h" | ||
|
||
@interface PartiallyMockedMapView () | ||
|
||
@property(nonatomic, assign) NSInteger frameObserverCount; | ||
|
||
@end | ||
|
||
@implementation PartiallyMockedMapView | ||
|
||
- (void)addObserver:(NSObject *)observer | ||
forKeyPath:(NSString *)keyPath | ||
options:(NSKeyValueObservingOptions)options | ||
context:(void *)context { | ||
[super addObserver:observer forKeyPath:keyPath options:options context:context]; | ||
|
||
if ([keyPath isEqualToString:@"frame"]) { | ||
++self.frameObserverCount; | ||
} | ||
} | ||
|
||
- (void)removeObserver:(NSObject *)observer forKeyPath:(NSString *)keyPath { | ||
[super removeObserver:observer forKeyPath:keyPath]; | ||
|
||
if ([keyPath isEqualToString:@"frame"]) { | ||
--self.frameObserverCount; | ||
} | ||
} | ||
|
||
@end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
packages/google_maps_flutter/google_maps_flutter/ios/Classes/GoogleMapController_Test.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import <Flutter/Flutter.h> | ||
#import <GoogleMaps/GoogleMaps.h> | ||
|
||
NS_ASSUME_NONNULL_BEGIN | ||
|
||
@interface FLTGoogleMapController (Test) | ||
|
||
/** | ||
* Initializes a map controller with a concrete map view. | ||
* | ||
* @param mapView A map view that will be displayed by the controller | ||
* @param viewId A unique identifier for the controller. | ||
* @param args Parameters for initialising the map view. | ||
* @param registrar The plugin registrar passed from Flutter. | ||
*/ | ||
- (instancetype)initWithMapView:(GMSMapView *)mapView | ||
viewIdentifier:(int64_t)viewId | ||
arguments:(id _Nullable)args | ||
registrar:(NSObject<FlutterPluginRegistrar> *)registrar; | ||
|
||
@end | ||
|
||
NS_ASSUME_NONNULL_END |
11 changes: 11 additions & 0 deletions
11
packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter-umbrella.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
// Copyright 2013 The Flutter Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
#import <Foundation/Foundation.h> | ||
#import <google_maps_flutter/FLTGoogleMapTileOverlayController.h> | ||
#import <google_maps_flutter/FLTGoogleMapsPlugin.h> | ||
stuartmorgan-g marked this conversation as resolved.
Show resolved
Hide resolved
|
||
#import <google_maps_flutter/JsonConversions.h> | ||
|
||
FOUNDATION_EXPORT double google_maps_flutterVersionNumber; | ||
FOUNDATION_EXPORT const unsigned char google_maps_flutterVersionString[]; |
10 changes: 10 additions & 0 deletions
10
packages/google_maps_flutter/google_maps_flutter/ios/Classes/google_maps_flutter.modulemap
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
framework module google_maps_flutter { | ||
umbrella header "google_maps_flutter-umbrella.h" | ||
|
||
export * | ||
module * { export * } | ||
|
||
explicit module Test { | ||
header "GoogleMapController_Test.h" | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,8 +14,9 @@ Downloaded by pub (not CocoaPods). | |
s.author = { 'Flutter Dev Team' => '[email protected]' } | ||
s.source = { :http => 'https://github.com/flutter/plugins/tree/main/packages/google_maps_flutter/google_maps_flutter' } | ||
s.documentation_url = 'https://pub.dev/packages/google_maps_flutter' | ||
s.source_files = 'Classes/**/*' | ||
s.source_files = 'Classes/**/*.{h,m}' | ||
s.public_header_files = 'Classes/**/*.h' | ||
s.module_map = 'Classes/google_maps_flutter.modulemap' | ||
s.dependency 'Flutter' | ||
s.dependency 'GoogleMaps' | ||
s.static_framework = true | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.