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

Crash on startup in Simulator — -[MGLMapboxEventsData init] #2687

Closed
1ec5 opened this issue Oct 20, 2015 · 4 comments
Closed

Crash on startup in Simulator — -[MGLMapboxEventsData init] #2687

1ec5 opened this issue Oct 20, 2015 · 4 comments
Assignees
Labels
crash iOS Mapbox Maps SDK for iOS telemetry Integration with Mapbox Telemetry libraries
Milestone

Comments

@1ec5
Copy link
Contributor

1ec5 commented Oct 20, 2015

#2581 introduced a crash on startup in the iPhone 6s Simulator. carrierVendor is nil but is being dereferenced:

#0  0x0000000000000000 in 0x00000000 ()
#1  0x000000010de9c0cd in -[MGLMapboxEventsData init] at /Users/mxn/hub/mapbox-gl-native/platform/ios/MGLMapboxEvents.m:88
#2  0x000000010de9ef11 in -[MGLMapboxEvents resumeMetricsCollection] at /Users/mxn/hub/mapbox-gl-native/platform/ios/MGLMapboxEvents.m:410
#3  0x000000010de9d4d6 in -[MGLMapboxEvents init] at /Users/mxn/hub/mapbox-gl-native/platform/ios/MGLMapboxEvents.m:249
#4  0x000000010de9e172 in __32+[MGLMapboxEvents sharedManager]_block_invoke_2 at /Users/mxn/hub/mapbox-gl-native/platform/ios/MGLMapboxEvents.m:313
#5  0x00000001118a349b in _dispatch_client_callout ()
#6  0x000000011188ee28 in dispatch_once_f ()
#7  0x000000010de9e11e in _dispatch_once [inlined] at /Applications/Xcode+1.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator9.1.sdk/usr/include/dispatch/once.h:68
#8  0x000000010de9e100 in __32+[MGLMapboxEvents sharedManager]_block_invoke at /Users/mxn/hub/mapbox-gl-native/platform/ios/MGLMapboxEvents.m:312
#9  0x000000010de9e054 in +[MGLMapboxEvents sharedManager] at /Users/mxn/hub/mapbox-gl-native/platform/ios/MGLMapboxEvents.m:322
#10 0x000000010dee9b39 in +[MGLAccountManager setAccessToken:] at /Users/mxn/hub/mapbox-gl-native/platform/ios/MGLAccountManager.m:65
#11 0x000000010da97551 in -[MBXAppDelegate application:didFinishLaunchingWithOptions:] at /Users/mxn/hub/mapbox-gl-native/ios/app/MBXAppDelegate.m:23

/cc @friedbunny

@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS crash telemetry Integration with Mapbox Telemetry libraries labels Oct 20, 2015
@1ec5 1ec5 added this to the ios-v2.2.0 milestone Oct 20, 2015
@picciano
Copy link

Also #2683

@friedbunny
Copy link
Contributor

For reasons unknown to me, the simulator always runs the conditional CoreTelephony code, whether or not CoreTelephony is linked. It should never need this code, either way.

This'll fix it, but it's not a cure:

diff --git a/platform/ios/MGLMapboxEvents.m b/platform/ios/MGLMapboxEvents.m
index bc6dfb0..9769e07 100644
--- a/platform/ios/MGLMapboxEvents.m
+++ b/platform/ios/MGLMapboxEvents.m
@@ -78,7 +78,8 @@ const NSTimeInterval MGLFlushInterval = 60;

         // Collect cellular carrier data if CoreTelephony is linked
         Class CTTelephonyNetworkInfo = NSClassFromString(@"CTTelephonyNetworkInfo");
-        if (CTTelephonyNetworkInfo) {
+        if (CTTelephonyNetworkInfo && !TARGET_IPHONE_SIMULATOR) {
             id telephonyNetworkInfo = [[CTTelephonyNetworkInfo alloc] init];

             SEL subscriberCellularProviderSelector = NSSelectorFromString(@"subscriberCellularProvider");

@friedbunny
Copy link
Contributor

Hrm, this is likely to fail on tvOS, too, if it has to do with CTTelephonyNetworkInfo being marked as unavailable.

@picciano
Copy link

FYI...on the iPhone simulator, I am getting an object for telephonyNetworkInfo, but carrierVendor comes back as nil. So, it does appear that the simulator is linking to CT.

screen shot 2015-10-20 at 3 02 24 pm

adam-mapbox added a commit that referenced this issue Oct 22, 2015
Reverts #2691, which only fixed simulator crashing.

Refs #2687
adam-mapbox added a commit that referenced this issue Oct 23, 2015
Reverts #2691, which only fixed simulator crashing.

Refs #2687
AndwareSsj pushed a commit to AndwareSsj/mapbox-gl-native that referenced this issue Nov 6, 2015
AndwareSsj pushed a commit to AndwareSsj/mapbox-gl-native that referenced this issue Nov 6, 2015
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
crash iOS Mapbox Maps SDK for iOS telemetry Integration with Mapbox Telemetry libraries
Projects
None yet
Development

No branches or pull requests

4 participants