I have integrated Google Maps for iOS SDK into my app, and I am getting a strange crash.
FatalException: GMSBackgroundAppException
Background execution would crash in this scenario
0 CoreFoundation 0x0000000183abe59c __exceptionPreprocess + 132
1 libobjc.A.dylib 0x00000001942080e4 objc_exception_throw + 60
2 CoreFoundation 0x0000000183abe4dc -[NSException initWithCoder:]
3 myApp 0x00000001004c4a04 -[GMSAsyncInitServices sharedInitWithSync:]
4 myApp 0x00000001004c48d4 -[GMSAsyncInitServices initSync]
5 myApp 0x00000001004c5588 +[GMSServices sharedServicesSync]
6 myApp 0x00000001004ba4a8 -[GMSMapView sharedInitWithServices:camera:]
7 myApp 0x00000001004b9e44 -[GMSMapView initWithFrame:camera:]
8 myApp 0x00000001004b9cdc +[GMSMapView mapWithFrame:camera:]
9 myApp 0x0000000100103c88 -[GoogleMapViewController viewDidLoad] (GoogleMapViewController.m:63)
10 UIKit 0x000000018826d184 -[UIViewController loadViewIfRequired] + 692
11 UIKit 0x000000018826ce94 -[UIViewController view] + 32
12 myApp 0x0000000100136cc0 -[BaseViewController viewDidLoad] (BaseViewController.m:93)
13 UIKit 0x000000018826d184 -[UIViewController loadViewIfRequired] + 692
14 UIKit 0x000000018826ce94 -[UIViewController view] + 32
15 UIKit 0x000000018895e90c -[_UIFullscreenPresentationController _setPresentedViewController:] + 76
16 UIKit 0x000000018856787c -[UIPresentationController initWithPresentedViewController:presentingViewController:] + 120
17 UIKit 0x000000018858291c -[UIViewController _presentViewController:withAnimationController:completion:] + 1972
18 UIKit 0x000000018827ace8 +[UIView(Animation) performWithoutAnimation:] + 88
19 UIKit 0x0000000188584dd8 __62-[UIViewController presentViewController:animated:completion:]_block_invoke + 284
20 UIKit 0x000000018835a3d4 -[UIViewController presentViewController:animated:completion:] + 216
21 myApp 0x00000001000cf1e4 -[FirstViewController viewDidAppear:] (FirstViewController.m:49)
22 UIKit 0x000000018828418c -[UIViewController _setViewAppearState:isAnimating:] + 592
23 UIKit 0x00000001882ef5fc -[UIViewController _executeAfterAppearanceBlock] + 64
24 UIKit 0x00000001882ef564 _applyBlockToCFArrayCopiedToStack + 356
25 UIKit 0x0000000188260ea0 _afterCACommitHandler + 572
26 CoreFoundation 0x0000000183a76a50 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 32
27 CoreFoundation 0x0000000183a739dc __CFRunLoopDoObservers + 360
28 CoreFoundation 0x0000000183a73dbc __CFRunLoopRun + 836
29 CoreFoundation 0x00000001839a10a4 CFRunLoopRunSpecific + 396
30 GraphicsServices 0x000000018cb3b5a4 GSEventRunModal + 168
31 UIKit 0x00000001882d2aa4 UIApplicationMain + 1488
32 myApp 0x0000000100266818 main (main.m:16)
33 libdyld.dylib 0x0000000194876a08 start + 4
There was a bug reported for a similar crash on the Google dev website, though I am not 100% sure if this is a Google bug, or some misuse of the SDK:
BaseViewController is the main view of my app, and gets loaded when the app starts (or immediately after a register/login). In it's viewDidLoad() method it initializes my GoogleMapViewController, which is just a UIViewController that holds the map. The viewDidLoad() for the GoogleMapVC is here:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
//We have to stop Google Maps from accessing location when the app goes into the background.
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(appGoingBackground:)
name:UIApplicationDidEnterBackgroundNotification
object:nil];
[[NSNotificationCenter defaultCenter] addObserver:self
selector:@selector(appBecomeActive:)
name:UIApplicationDidBecomeActiveNotification
object:nil];
self.allMarkers = [NSMutableArray array];
double latitude = 40.71448;
double longitude = -74.00598;
GPSManager *manager = [GPSManager sharedInstance];
if (manager.lastKnownLocation) {
latitude = manager.lastKnownLocation.coordinate.latitude;
longitude = manager.lastKnownLocation.coordinate.longitude;
}
GMSCameraPosition *camera = [GMSCameraPosition cameraWithLatitude:latitude
longitude:longitude
zoom:5];
self.mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
[self.mapView setMinZoom:1 maxZoom:15];
self.mapView.myLocationEnabled = YES;
[self.view addSubview:self.mapView];
[self performSelector:@selector(setPadding) withObject:nil afterDelay:0.1];
}
The line that is causing the crash is this one:
self.mapView = [GMSMapView mapWithFrame:self.view.bounds camera:camera];
The title of the crash report would seem to indicate this has something to do with execution in the background, but as I said earlier, this is code that gets executed in viewDidLoad(), when the app starts up.
Is there something I am missing? Any thoughts/suggestions would be appreciated.
Aucun commentaire:
Enregistrer un commentaire