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

Crash deallocating MGLMapView after adding a point annotation #4805

Closed
1ec5 opened this issue Apr 22, 2016 · 0 comments
Closed

Crash deallocating MGLMapView after adding a point annotation #4805

1ec5 opened this issue Apr 22, 2016 · 0 comments
Assignees
Labels
crash iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS
Milestone

Comments

@1ec5
Copy link
Contributor

1ec5 commented Apr 22, 2016

MGLMapView doesn’t explicitly remove all its annotations when it gets deallocated, so the dangling KVO observations on the point annotations’ coordinate key paths cause a reliable crash. This regression was introduced in #3835. Here’s an example stack trace:

2016-04-22 12:37:39.870 Mapbox GL[71509:10483627] Ignoring exception raised in void run_cocoa_block(void *): An instance 0x60800088b950 of class DroppedPinAnnotation was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x600000446510> (
<NSKeyValueObservance 0x6080000d45f0: Observer: 0x101749f70, Key path: coordinate, Options: <New: NO, Old: NO, Prior: NO> Context: 0x0, Property: 0x60800024b880>
)
2016-04-22 12:37:39.878 Mapbox GL[71509:10483627] An uncaught exception was raised
2016-04-22 12:37:39.878 Mapbox GL[71509:10483627] An instance 0x600000097f70 of class DroppedPinAnnotation was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x608000441a10> (
<NSKeyValueObservance 0x6000000dfcd0: Observer: 0x101749f70, Key path: coordinate, Options: <New: NO, Old: NO, Prior: NO> Context: 0x1, Property: 0x60800024b880>
)
2016-04-22 12:37:39.878 Mapbox GL[71509:10483627] (
    0   CoreFoundation                      0x00007fff902e64f2 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff9534af7e objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff9034d4bd +[NSException raise:format:] + 205
    3   Foundation                          0x00007fff94c37f00 NSKVODeallocate + 294
    4   AppKit                              0x00007fff889c82a6 -[NSViewController dealloc] + 279
    5   AppKit                              0x00007fff88732aad -[NSViewController release] + 133
    6   AppKit                              0x00007fff887f6579 -[NSAutounbinder dealloc] + 51
    7   libobjc.A.dylib                     0x00007fff95340b3b _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 477
    8   CoreFoundation                      0x00007fff90219c12 _CFAutoreleasePoolPop + 50
    9   AppKit                              0x00007fff8888011d __42-[NSPersistentUIManager acquireDirtyState]_block_invoke + 77
    10  libdispatch.dylib                   0x0000000100d03cc5 _dispatch_client_callout + 8
    11  libdispatch.dylib                   0x0000000100d16ba6 _dispatch_source_latch_and_call + 3387
    12  libdispatch.dylib                   0x0000000100d08cd8 _dispatch_source_invoke + 978
    13  libdispatch.dylib                   0x0000000100d1b012 _dispatch_main_queue_callback_4CF + 1153
    14  CoreFoundation                      0x00007fff9029b9e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    15  CoreFoundation                      0x00007fff9025a8dd __CFRunLoopRun + 1949
    16  CoreFoundation                      0x00007fff90259ed8 CFRunLoopRunSpecific + 296
    17  HIToolbox                           0x00007fff975d8935 RunCurrentEventLoopInMode + 235
    18  HIToolbox                           0x00007fff975d876f ReceiveNextEventCommon + 432
    19  HIToolbox                           0x00007fff975d85af _BlockUntilNextEventMatchingListInModeWithFilter + 71
    20  AppKit                              0x00007fff886e8efa _DPSNextEvent + 1067
    21  AppKit                              0x00007fff886e832a -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
    22  AppKit                              0x00007fff886dce84 -[NSApplication run] + 682
    23  AppKit                              0x00007fff886a646c NSApplicationMain + 1176
    24  Mapbox GL                           0x00000001000098a2 main + 34
    25  libdyld.dylib                       0x00007fff91a205ad start + 1
)
2016-04-22 12:37:39.878 Mapbox GL[71509:10483627] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'An instance 0x600000097f70 of class DroppedPinAnnotation was deallocated while key value observers were still registered with it. Current observation info: <NSKeyValueObservationInfo 0x608000441a10> (
<NSKeyValueObservance 0x6000000dfcd0: Observer: 0x101749f70, Key path: coordinate, Options: <New: NO, Old: NO, Prior: NO> Context: 0x1, Property: 0x60800024b880>
)'
*** First throw call stack:
(
    0   CoreFoundation                      0x00007fff902e64f2 __exceptionPreprocess + 178
    1   libobjc.A.dylib                     0x00007fff9534af7e objc_exception_throw + 48
    2   CoreFoundation                      0x00007fff9034d4bd +[NSException raise:format:] + 205
    3   Foundation                          0x00007fff94c37f00 NSKVODeallocate + 294
    4   AppKit                              0x00007fff889c82a6 -[NSViewController dealloc] + 279
    5   AppKit                              0x00007fff88732aad -[NSViewController release] + 133
    6   AppKit                              0x00007fff887f6579 -[NSAutounbinder dealloc] + 51
    7   libobjc.A.dylib                     0x00007fff95340b3b _ZN12_GLOBAL__N_119AutoreleasePoolPage3popEPv + 477
    8   CoreFoundation                      0x00007fff90219c12 _CFAutoreleasePoolPop + 50
    9   AppKit                              0x00007fff8888011d __42-[NSPersistentUIManager acquireDirtyState]_block_invoke + 77
    10  libdispatch.dylib                   0x0000000100d03cc5 _dispatch_client_callout + 8
    11  libdispatch.dylib                   0x0000000100d16ba6 _dispatch_source_latch_and_call + 3387
    12  libdispatch.dylib                   0x0000000100d08cd8 _dispatch_source_invoke + 978
    13  libdispatch.dylib                   0x0000000100d1b012 _dispatch_main_queue_callback_4CF + 1153
    14  CoreFoundation                      0x00007fff9029b9e9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
    15  CoreFoundation                      0x00007fff9025a8dd __CFRunLoopRun + 1949
    16  CoreFoundation                      0x00007fff90259ed8 CFRunLoopRunSpecific + 296
    17  HIToolbox                           0x00007fff975d8935 RunCurrentEventLoopInMode + 235
    18  HIToolbox                           0x00007fff975d876f ReceiveNextEventCommon + 432
    19  HIToolbox                           0x00007fff975d85af _BlockUntilNextEventMatchingListInModeWithFilter + 71
    20  AppKit                              0x00007fff886e8efa _DPSNextEvent + 1067
    21  AppKit                              0x00007fff886e832a -[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
    22  AppKit                              0x00007fff886dce84 -[NSApplication run] + 682
    23  AppKit                              0x00007fff886a646c NSApplicationMain + 1176
    24  Mapbox GL                           0x00000001000098a2 main + 34
    25  libdyld.dylib                       0x00007fff91a205ad start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 
@1ec5 1ec5 self-assigned this Apr 22, 2016
@1ec5 1ec5 added iOS Mapbox Maps SDK for iOS macOS Mapbox Maps SDK for macOS crash labels Apr 22, 2016
@1ec5 1ec5 added this to the ios-v3.3.0 milestone Apr 22, 2016
1ec5 added a commit that referenced this issue Apr 22, 2016
Fixed a crash when deallocating an MGLMapView that has point annotations. Now we explicitly remove all the annotations from the view and thus remove all remaining KVO observers on those annotations.

Fixes #4805.
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 macOS Mapbox Maps SDK for macOS
Projects
None yet
Development

No branches or pull requests

1 participant