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 render with view-backed annotations present — -[MGLMapView visibleAnnotationsInRect:] #8163
Copy link
Copy link
Closed
Labels
Milestone
Description
Platform: iOS
Mapbox SDK version: 3.4.1
Steps to trigger behaviour
Updated to the latest SDK version and get this error, it has effected over 1000 users in the past 7 days. Could you help me understand it so I can get a fix deployed?
Incident Identifier: D3B3C119-B99F-45D9-96DD-68BEADF88543
CrashReporter Key: 44069ad0adad7f6fe68b477dddc9285b987cc622
Hardware Model: iPhone9,3
Process: Snatch Production [7629]
Path: /private/var/containers/Bundle/Application/9E753DDA-4C28-48DD-A30D-12A2C702B907/Snatch Production.app/Snatch Production
Identifier: com.iPhone.Snatch
Version: 2 (1.2.4)
Code Type: ARM-64 (Native)
Role: Foreground
Parent Process: launchd [1]
Coalition: com.iPhone.Snatch [3379]
Date/Time: 2017-02-20 21:07:17.2052 +0000
Launch Time: 2017-02-20 19:36:04.1710 +0000
OS Version: iPhone OS 10.3 (14E5239e)
Report Version: 104
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXC_CORPSE_NOTIFY
Triggered by Thread: 0
Last Exception Backtrace:
0 CoreFoundation 0x18c5a2fb8 __exceptionPreprocess + 124 (NSException.m:165)
1 libobjc.A.dylib 0x18b008538 objc_exception_throw + 56 (objc-exception.mm:521)
2 CoreFoundation 0x18c484868 -[__NSArrayM insertObject:atIndex:] + 1372 (NSArray.m:654)
3 Mapbox 0x100dbf8c8 -[MGLMapView visibleAnnotationsInRect:] + 260 (MGLMapView.mm:2866)
4 Mapbox 0x100dc94bc -[MGLMapView updateAnnotationViews] + 408 (MGLMapView.mm:4728)
5 Mapbox 0x100dc8aa8 -[MGLMapView notifyMapChange:] + 796 (MGLMapView.mm:4681)
6 Mapbox 0x100dcc9ac MBGLView::notifyMapChange(mbgl::MapChange) + 44 (MGLMapView.mm:5173)
7 Mapbox 0x100e716d4 mbgl::Map::render(mbgl::View&) + 192
8 Mapbox 0x100db5da0 -[MGLMapView glkView:drawInRect:] + 68 (MGLMapView.mm:872)
9 GLKit 0x196d2f9c4 -[GLKView _display:] + 216 (GLKView.m:584)
10 Mapbox 0x100db65d0 -[MGLMapView updateFromDisplayLink] + 68 (MGLMapView.mm:1000)
11 QuartzCore 0x18f86b218 CA::Display::DisplayLinkItem::dispatch(unsigned long long) + 44 (CADisplay.mm:1881)
12 QuartzCore 0x18f86b0c8 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 436 (CADisplay.mm:1347)
13 IOKit 0x18c810308 IODispatchCalloutFromCFMessage + 372 (IOKitLib.c:1205)
14 CoreFoundation 0x18c539938 __CFMachPortPerform + 180 (CFMachPort.c:682)
15 CoreFoundation 0x18c551abc __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56 (CFRunLoop.c:1959)
16 CoreFoundation 0x18c55125c __CFRunLoopDoSource1 + 436 (CFRunLoop.c:2078)
17 CoreFoundation 0x18c54ed70 __CFRunLoopRun + 1752 (CFRunLoop.c:3028)
18 CoreFoundation 0x18c47ed74 CFRunLoopRunSpecific + 424 (CFRunLoop.c:3113)
19 GraphicsServices 0x18dee7074 GSEventRunModal + 100 (GSEvent.c:2245)
20 UIKit 0x1927db988 UIApplicationMain + 208 (UIApplication.m:4068)
21 Snatch Production 0x1000ca21c main + 120 (AppDelegate.swift:21)
22 libdyld.dylib 0x18b48d59c start + 4
I've got quite a few more reports if you need more than one?
Thanks,
Ollie
Activity
boundsj commentedon Feb 22, 2017
Sorry to hear you are having issues @ollie-eman. Can you please tell us what version of our iOS SDK you were using before you updated to
3.4.1? Also, if you can provide repro steps that would most likely help us resolve this issue faster.A similar issue was reported in #6901 and #7170 but that seemed to be resolved by #6924 that landed in version 3.4.0 of our iOS SDK.
Before #6924, an action like panning the map while concurrently removing annotations that are being updated to track the pan gesture could cause this crash. We can add more guards around the NSArray
addObject:call but it'd be really helpful to understand what your application is doing when this crash occurs.ollie-eman commentedon Feb 24, 2017
The version I was using before
3.4.1was3.3.7I don't have any reproducible steps I'm afraid, from the crash reports it effects each user roughly 1.3 times.
The app is similar to Pokemon Go, the user is in the centre of the map and there are two available gestures. These are rotating the camera around the user and pinch to zoom and tilt the camera. When the user moves location I make changes to the current
MGLMapCamerato reflect this.The map shows annotations that represent parcels the user has to tap, these get updated regularly (every 10 seconds).
I use the following code to update the annotations on the map. The class
DefaultPointAnnotationis a subclass ofMGLPointAnnotationboundsj commentedon Feb 27, 2017
Thanks for the information @ollie-eman. We spent some time investigating and still cannot find a code path that would lead to the crash you are seeing. We will keep digging but if you can provide any more information that may help we would appreciate it. Some things that may be useful to know are:
1ec5 commentedon Mar 10, 2017
-updateAnnotationViewsonly calls-visibleAnnotationsInRect:if the delegate implements-mapView:viewForAnnotation:. So it’s likely that @ollie-eman’s application is using view-backed annotations at least, if not also GL point annotations.[-]Can you help me understand this crash report?[/-][+]Crash on render with view-backed annotations present — -[MGLMapView visibleAnnotationsInRect:][/+]boundsj commentedon Mar 10, 2017
I'm leaving this issue open, but since there is no known repro yet I'm going to move this off of the 3.5.0 milestone.
erichoracek commentedon Mar 21, 2017
We're experiencing this same crash as of 3.4.1. We were previously on 3.3.7. We use both view-backed and GL-backed annotations depending on the screen.
1ec5 commentedon Mar 21, 2017
Since
-[MGLMapView visibleAnnotationsInRect:]usesmbgl::Map::queryPointAnnotations()under the hood, I suspect this is a duplicate of #8289, which was fixed in #8374. (/cc @ivovandongen)@ollie-eman @erichoracek, can you check whether this crash still occurs after upgrading to iOS SDK v3.5.0? Thanks!
8 remaining items
boundsj commentedon Mar 29, 2017
Noting that a stopgap landed in #8513 for the iOS v3.5.1 patch release but we will move this issue to the iOS v3.6.0 release and continue to investigate the root cause.
1ec5 commentedon Mar 29, 2017
Here’s one possible way to get a similar crash; there may be others:
-[MGLMapView selectAnnotation:animated:], passing inMGLMapView.userLocation.-selectAnnotation:animated:calls-annotationTagForAnnotation:, which will returnMGLAnnotationTagNotFoundin this case.-selectAnnotation:animated:then calls-positioningRectForCalloutForAnnotationWithTag:, which immediately subscripts_annotationContextsByAnnotationTagwithMGLAnnotationTagNotFound, thereby creating a bogus entry for the keyMGLAnnotationTagNotFound._annotationContextsByAnnotationTag.#8513 papers over the crash by gracefully failing, but I think that just kicks the can down the road. We should supplement that fix with an assertion similar to this assertion in the accessibility code. That way we’ll at least get a more specific crash and the ability to rule out the
MGLAnnotationTagNotFoundcase above./cc @fabian-guerra
fabian-guerra commentedon Mar 30, 2017
@ollie-eman @Laeyoung since it has been difficult reproduce the code that lead to the crash, maybe it's better to try to reproduce the steps in the actual apps, is it possible to you share your apps (the Appstore link) + the device type & OS version?
Laeyoung commentedon Apr 3, 2017
@fabian-guerra I reproduced this issue on my iPhone 5 (os v10.2). And my colleagues got same issues on their various iPhones.
https://itunes.apple.com/us/app/alleys-video-map-vr-travel/id1123458416?mt=8
boundsj commentedon Apr 5, 2017
@fabian-guerra @1ec5 I'm able to reproduce this exact issue by removing all annotations that were added to the map at about the same time but just barely before tapping the map around some annotations and
-[MGLMapView annotationTagAtPoint:persistingResults:]is called insideMGLMapView. Here is the repro:note: you must run in release or comment out the assertion
NSAssert(annotation, @"Unknown annotation found nearby tap");in-[MGLMapView annotationTagAtPoint:persistingResults:]for this to work_annotationContextsByAnnotationTaginMGLMapViewis cleared-[MGLMapView annotationTagAtPoint:persistingResults:]queries mbgl for annotation tags near the tap point_annotationContextsByAnnotationTagis cleared, mbgl is still not caught up and it returns one or more annotation tags that used to be near the tap point-[MGLMapView annotationTagAtPoint:persistingResults:]indexes into_annotationContextsByAnnotationTagfor each annotation tag that came back from mbgl, creating bogus entries for each one-[MGLMapView updateAnnotationViews]is called and the exception is encountered in-[MGLMapView visibleAnnotationsInRect:]because one of the previously added bogus annotation context entries is still considered by mbgl to exist and to be visibleThe problem is that, when annotations are removed,
Map::removeAnnotation()is asynchronous and we currently have no way to keepMGLMapView's notion of annotations up to date with mbgl. Ideally, we would not remove the map view entry until some sort of callback from mbgl confirmed that the annotation was removed.Unfortunately, I think that the guard added in #8513 must stay for now.
boundsj commentedon Apr 5, 2017
Also, I think that while it is true that #8163 (comment) could happen in theory, it is unlikely because of the extremely high value of
MGLAnnotationTagNotFound. The repro described above in #8163 (comment) is more likely to happen because it involves actual annotation tags that were visible at one point.1ec5 commentedon Apr 5, 2017
Your reproduction steps make a lot more sense than mine. 😄
This is also a bug;
_annotationContextsByAnnotationTagshould never have a bogus entry. We should supplement this assertion with a guard that returnstrue(filtering out the annotation) in the event of anilannotation(indicating an annotation that no longer exists due to this race condition).I think this crash also demonstrates that we should eliminate the use of
std::map::operator[]to obtain entries from_annotationContextsByAnnotationTag. Usingstd::map::at()here, for example, gives us greater confidence that thestd::mapisn’t corrupted. An informative crash is still better than a latent bug.👍 As long as defensive guards like that are accompanied by assertions, and as long as we eliminate the unchecked use of
std::map::operator[], at least we have a better chance of diagnosing issues like this.1ec5 commentedon Apr 5, 2017
Implemented in #8637.
boundsj commentedon Apr 5, 2017
Now that #8637, #8513, and #8588 have landed to stabilize release builds and will be included in v3.5.1, I think it is ok to close this.
#8655 tracks tail work to stabilize this situation in debug builds.