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

Random crashes when displaying MapView #5924

Closed
irgendeinich opened this issue Aug 10, 2016 · 4 comments
Closed

Random crashes when displaying MapView #5924

irgendeinich opened this issue Aug 10, 2016 · 4 comments
Assignees
Labels
crash iOS Mapbox Maps SDK for iOS
Milestone

Comments

@irgendeinich
Copy link

Platform: iOS
Mapbox SDK version: 3.3.3

Steps to trigger behavior

  1. Display a MapView

Expected behavior

The MapView should be displayed and the app shouldn't crash

Actual behavior

The app crashes on some devices but not all

Stacktrace

This is the stacktrace I got from Crashlytics, sadly the symbols for Mapbox were not included.

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x245edb0b __exceptionPreprocess
1  libobjc.A.dylib                0x23daadff objc_exception_throw
2  CoreFoundation                 0x24501d0d -[__NSArrayM insertObject:atIndex:]
3  Mapbox                         0x1047649 (Missing)
4  Mapbox                         0x1047a55 (Missing)
5  Mapbox                         0x104f635 (Missing)
6  Mapbox                         0x104fa0f (Missing)
7  Mapbox                         0x104f98d (Missing)
8  Mapbox                         0x101aba1 (Missing)
9  Mapbox                         0x1018f8b (Missing)
10 MyApp                        0x45a3a5 -[TSRMMapView initWithFrame:styleURL:] (TSRMMapView.m:21)
11 MyApp                        0x427011 -[TSMapView setup] (TSMapView.m:222)
12 CoreFoundation                 0x245f2664 __invoking___
13 CoreFoundation                 0x245178bd -[NSInvocation invoke]
14 MyApp                        0xf4e3d __ASPECTS_ARE_BEING_CALLED__ (Aspects.m:491)
15 CoreFoundation                 0x245f0f4d ___forwarding___
16 CoreFoundation                 0x2451b298 _CF_forwarding_prep_0
17 MyApp                        0x3abacf -[TSRouteView setup] (TSRouteView.m:80)
18 MyApp                        0x4266b3 -[TSMapView initWithCoder:] (TSMapView.m:97)
19 UIKit                          0x2907ddcb -[UIClassSwapper initWithCoder:]
20 UIKit                          0x291964e5 UINibDecoderDecodeObjectForValue
21 UIKit                          0x29196477 UINibDecoderDecodeObjectForValue
22 UIKit                          0x291961cd -[UINibDecoder decodeObjectForKey:]
23 UIKit                          0x28ec2ee1 -[UIView initWithCoder:]
24 UIKit                          0x291e8821 -[UITableViewCellContentView initWithCoder:]
25 UIKit                          0x291964e5 UINibDecoderDecodeObjectForValue
26 UIKit                          0x29196477 UINibDecoderDecodeObjectForValue
27 UIKit                          0x291961cd -[UINibDecoder decodeObjectForKey:]
28 UIKit                          0x28ec2ee1 -[UIView initWithCoder:]
29 UIKit                          0x29050139 -[UITableViewCell initWithCoder:]
30 UIKit                          0x2907ddcb -[UIClassSwapper initWithCoder:]
31 UIKit                          0x291964e5 UINibDecoderDecodeObjectForValue
32 UIKit                          0x291961cd -[UINibDecoder decodeObjectForKey:]
33 UIKit                          0x2907daab -[UIRuntimeConnection initWithCoder:]
34 UIKit                          0x291964e5 UINibDecoderDecodeObjectForValue
35 UIKit                          0x29196477 UINibDecoderDecodeObjectForValue
36 UIKit                          0x291961cd -[UINibDecoder decodeObjectForKey:]
37 UIKit                          0x2907d03f -[UINib instantiateWithOwner:options:]
38 UIKit                          0x28d104b7 -[UITableView _dequeueReusableViewOfType:withIdentifier:]
39 MyApp                        0x36e7ef __52-[OURouteDetailDataSource setupDynamicRowController]_block_invoke (OURouteDetailDataSource.m:162)
40 MyApp                        0x33829b -[DynamicRow cellForTableView:] (DynamicRow.m:16)
41 MyApp                        0x3387f1 -[DynamicRowController cellForRowAtIndexPath:] (DynamicRowController.m:54)
42 MyApp                        0x3710d5 -[OURouteDetailDataSource tableView:cellForRowAtIndexPath:] (OURouteDetailDataSource.m:520)
43 UIKit                          0x28f0ee21 -[UITableView _createPreparedCellForGlobalRow:withIndexPath:willDisplay:]
44 UIKit                          0x28f0ef61 -[UITableView _createPreparedCellForGlobalRow:willDisplay:]
45 UIKit                          0x28efe43d -[UITableView _updateVisibleCellsNow:isRecursive:]
46 UIKit                          0x28f13747 -[UITableView _performWithCachedTraitCollection:]
47 UIKit                          0x28cb0a6f -[UITableView layoutSubviews]
48 UIKit                          0x28bc16fb -[UIView(CALayerDelegate) layoutSublayersOfLayer:]
49 QuartzCore                     0x26c32569 -[CALayer layoutSublayers]
50 QuartzCore                     0x26c2dd2d CA::Layer::layout_if_needed(CA::Transaction*)
51 QuartzCore                     0x26c2dbbd CA::Layer::layout_and_display_if_needed(CA::Transaction*)
52 QuartzCore                     0x26c2d081 CA::Context::commit_transaction(CA::Transaction*)
53 QuartzCore                     0x26c2cd55 CA::Transaction::commit()
54 UIKit                          0x28bb87f5 _afterCACommitHandler
55 CoreFoundation                 0x245af2b1 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__
56 CoreFoundation                 0x245ad5a7 __CFRunLoopDoObservers
57 CoreFoundation                 0x245ad9e5 __CFRunLoopRun
58 CoreFoundation                 0x244fc1c9 CFRunLoopRunSpecific
59 CoreFoundation                 0x244fbfbd CFRunLoopRunInMode
60 GraphicsServices               0x25b18af9 GSEventRunModal
61 UIKit                          0x28c2e435 UIApplicationMain
62 MyApp                        0xcfb05 main (main.m:15)
63 libdispatch.dylib              0x241a8873 (Missing)

Solution

I tracked the issue down to this line https://github.com/mapbox/mapbox-gl-native/blob/master/platform/ios/src/MGLAPIClient.m#L66
It seems the NSURLSession sometimes returns nil for the dataTask. Although I wasn't able to reproduce it on my end, making the method do nothing did fix all the crashes our app was experiencing.

@tobrun tobrun added iOS Mapbox Maps SDK for iOS crash labels Aug 10, 2016
@boundsj boundsj added this to the ios-v3.4.0 milestone Aug 10, 2016
@boundsj boundsj self-assigned this Aug 10, 2016
@boundsj
Copy link
Contributor

boundsj commented Aug 10, 2016

Thanks @irgendeinich. We've patched this in #5932

The app crashes on some devices but not all

Can you please let us know what types of devices you see this issue happen on? Also, if you can provide any additional details about what you are doing in your MapView subclass that would be interesting for us to know as well.

Also, it seems like you are building the library yourself. The Mapbox.framework.dSYM file is available in the build output and you should include it in your app's set of dSYMs for better stack traces in the future. In any case, ideally you would implement a similar guard of the apparent nil NSURLSessionDataTask as opposed to disabling the postEvents: method entirely.

@irgendeinich
Copy link
Author

Thanks for responding so quickly.
Devices might have been a poor choice of word, it seems to happen on all devices/OS versions but only for about 5% of our users. In any case these are some of the device/OS combinations I've had reports from:

  • iPhone SE - 9.3.3 (13G34)
  • iPhone 6S - 9.3.3 (13G34)
  • iPhone 6 - 8.1.2 (12B440), 10.0.0 (14A5322e)
  • iPhone 5 - 9.3.2 (13F69), 9.3.3 (13G34)
  • iPhone 4S - 8.1.2 (12B440), 9.3.3 (13G34)
  • iPad Air - 9.3.3 (13G34)
  • iPad Mini 2 - 9.3.1 (13E238)
  • iPad Mini - 9.3.2 (13F69)
  • iPad 4 - 9.3.3 (13G34)
  • iPad 6,4 - 9.3.3 (13G34)

Our MapView subclass just sets up the correct style url. The crash also doesn't always happen when the first MapView is displayed, it sometimes only happens on the second or third map, it also sometimes happens when postEvents: is called to send the batched events

Fatal Exception: NSInvalidArgumentException
0  CoreFoundation                 0x255f9b0b __exceptionPreprocess
1  libobjc.A.dylib                0x24db6dff objc_exception_throw
2  CoreFoundation                 0x2550dd0d -[__NSArrayM insertObject:atIndex:]
3  Mapbox                         0xf87649 (Missing)
4  Mapbox                         0xf9077f (Missing)
5  libdispatch.dylib              0x2518bcbf _dispatch_call_block_and_release
6  libdispatch.dylib              0x25195e7f _dispatch_queue_drain
7  libdispatch.dylib              0x2518ee17 _dispatch_queue_invoke
8  libdispatch.dylib              0x251976a1 _dispatch_root_queue_drain
9  libdispatch.dylib              0x2519707b _dispatch_worker_thread3
10 libsystem_pthread.dylib        0x2532ae0d _pthread_wqthread
11 libsystem_pthread.dylib        0x2532a9fc start_wqthread

We are actually just using the regular dynamic framework release, and all the openGL related crashes do have proper symbols for Mapbox its just this issue where they are missing.

@boundsj
Copy link
Contributor

boundsj commented Aug 11, 2016

Thanks for the additional information @irgendeinich. This issue was closed automatically when #5932 was merged. I'll open a new issue to investigate the missing symbol issue you described.

@boundsj
Copy link
Contributor

boundsj commented Oct 5, 2016

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
Projects
None yet
Development

No branches or pull requests

3 participants