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

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

Closed

Description

@1ec5

#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

Activity

  1. added
    iOS
    telemetry
    on Oct 20, 2015
  2. added this to the milestone on Oct 20, 2015
  3. picciano commented on Oct 20, 2015

    @picciano

    Also #2683

  4. friedbunny commented on Oct 20, 2015

    @friedbunny
    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");
  5. friedbunny commented on Oct 20, 2015

    @friedbunny
    Contributor

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

  6. picciano commented on Oct 20, 2015

    @picciano

    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

  7. added 2 commits that reference this issue on Nov 6, 2015
    627cc25
    30d3607
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

crashiOStelemetry

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions