You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
Crash on startup in Simulator — -[MGLMapboxEventsData init] #2687
#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
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");
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.
Activity
picciano commentedon Oct 20, 2015
Also #2683
friedbunny commentedon Oct 20, 2015
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:
friedbunny commentedon Oct 20, 2015
Hrm, this is likely to fail on tvOS, too, if it has to do with
CTTelephonyNetworkInfobeing marked as unavailable.picciano commentedon Oct 20, 2015
FYI...on the iPhone simulator, I am getting an object for
telephonyNetworkInfo, butcarrierVendorcomes back asnil. So, it does appear that the simulator is linking to CT.[ios] Fix for a crash on iPod Touch related to carrier vendor
[ios] Fix for a crash on iPod Touch related to carrier vendor
[ios] fix simulator crash on optional CoreTelephony code
[ios] Fix for a crash on iPod Touch related to carrier vendor