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 rendering the map — mbgl::FillBucket::drawElements, glrAGXRenderVertexArray #5731

Closed

Description

@MikeKasperlik

Platform: iOS
Mapbox SDK version: 3.3.1

We see a high crash rate for this on fabric.

I can't reproduce this crash but it happens randomly when the app is in foreground and doing something with the map.

We use a custom style & draw a single polyline on the map

Crashed: com.apple.main-thread
0  libsystem_platform.dylib       0x181e5a2a0 _platform_memmove + 176
1  AGXGLDriver                    0x193d93f6c glrAGXRenderVertexArray(GLDContextRec*, unsigned int, unsigned int, int, int, unsigned int, void const*, int, void const*)
2  AGXGLDriver                    0x193d93f6c glrAGXRenderVertexArray(GLDContextRec*, unsigned int, unsigned int, int, int, unsigned int, void const*, int, void const*)
3  GLEngine                       0x194b36ea4 glDrawElements_ACC_ES2Exec
4  Mapbox                         0x1017739e4 mbgl::FillBucket::drawElements(mbgl::PlainShader&, mbgl::gl::ObjectStore&) + 284
5  Mapbox                         0x10177dd7c mbgl::Painter::renderFill(mbgl::FillBucket&, mbgl::style::FillLayer const&, mbgl::UnwrappedTileID const&, std::__1::array<double, 16ul> const&) + 3852
6  Mapbox                         0x10177abb0 void mbgl::Painter::renderPass<std::__1::reverse_iterator<std::__1::__wrap_iter<mbgl::RenderItem const*> > >(mbgl::RenderPass, std::__1::reverse_iterator<std::__1::__wrap_iter<mbgl::RenderItem const*> >, std::__1::reverse_iterator<std::__1::__wrap_iter<mbgl::RenderItem const*> >, int, signed char) + 688
7  Mapbox                         0x10177a244 mbgl::Painter::render(mbgl::style::Style const&, mbgl::FrameData const&, mbgl::SpriteAtlas&) + 1424
8  Mapbox                         0x1017682ac mbgl::Map::Impl::render() + 160
9  Mapbox                         0x10176811c mbgl::Map::render() + 128
10 Mapbox                         0x1016ec2a8 -[MGLMapView glkView:drawInRect:] + 48
11 GLKit                          0x18a89136c -[GLKView _display:] + 332
12 Mapbox                         0x1016eca44 -[MGLMapView updateFromDisplayLink] + 68
13 QuartzCore                     0x184d38234 CA::Display::DisplayLinkItem::dispatch() + 40
14 QuartzCore                     0x184d380e8 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 424
15 IOKit                          0x182475e54 IODispatchCalloutFromCFMessage + 372
16 CoreFoundation                 0x18219d030 __CFMachPortPerform + 180
17 CoreFoundation                 0x1821b57d4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
18 CoreFoundation                 0x1821b4f0c __CFRunLoopDoSource1 + 436
19 CoreFoundation                 0x1821b2c64 __CFRunLoopRun + 1800
20 CoreFoundation                 0x1820dcc50 CFRunLoopRunSpecific + 384
21 GraphicsServices               0x1839c4088 GSEventRunModal + 180
22 UIKit                          0x1873c6088 UIApplicationMain + 204
23 PACEApp                        0x1001b9ba8 main (AppDelegate.swift:27)
24 libdispatch.dylib              0x181c7a8b8 (Missing)

Other Threads:

DefaultFileSource
0  libsystem_kernel.dylib         0x181d7cfd8 mach_msg_trap + 8
1  libsystem_kernel.dylib         0x181d7ce54 mach_msg + 72
2  CoreFoundation                 0x1821b4c60 __CFRunLoopServiceMachPort + 196
3  CoreFoundation                 0x1821b2964 __CFRunLoopRun + 1032
4  CoreFoundation                 0x1820dcc50 CFRunLoopRunSpecific + 384
5  CoreFoundation                 0x18212a3a4 CFRunLoopRun + 112
6  Mapbox                         0x10181b438 void mbgl::util::Thread<mbgl::DefaultFileSource::Impl>::run<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>, 0ul, 1ul>(std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>&&, std::__1::integer_sequence<unsigned long, 0ul, 1ul>) + 156
7  Mapbox                         0x10181b358 std::__1::__thread_proxy<std::__1::tuple<mbgl::util::Thread<mbgl::DefaultFileSource::Impl>::Thread<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&, unsigned long long&>(mbgl::util::ThreadContext const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&&&, unsigned long long&&&)::'lambda'()> >(void*, void*) + 136
8  libsystem_pthread.dylib        0x181e63b28 _pthread_body + 156
9  libsystem_pthread.dylib        0x181e63a8c _pthread_body + 154
10 libsystem_pthread.dylib        0x181e61028 thread_start + 4
AssetFileSource
0  libsystem_kernel.dylib         0x181d7cfd8 mach_msg_trap + 8
1  libsystem_kernel.dylib         0x181d7ce54 mach_msg + 72
2  CoreFoundation                 0x1821b4c60 __CFRunLoopServiceMachPort + 196
3  CoreFoundation                 0x1821b2964 __CFRunLoopRun + 1032
4  CoreFoundation                 0x1820dcc50 CFRunLoopRunSpecific + 384
5  CoreFoundation                 0x18212a3a4 CFRunLoopRun + 112
6  Mapbox                         0x101816150 void mbgl::util::Thread<mbgl::AssetFileSource::Impl>::run<std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>, 0ul>(std::__1::tuple<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>&&, std::__1::integer_sequence<unsigned long, 0ul>) + 104
7  Mapbox                         0x1018160a4 std::__1::__thread_proxy<std::__1::tuple<mbgl::util::Thread<mbgl::AssetFileSource::Impl>::Thread<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&>(mbgl::util::ThreadContext const&, std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> > const&&&)::'lambda'()> >(void*, void*) + 136
8  libsystem_pthread.dylib        0x181e63b28 _pthread_body + 156
9  libsystem_pthread.dylib        0x181e63a8c _pthread_body + 154
10 libsystem_pthread.dylib        0x181e61028 thread_start + 4

And a lot of worker threads that all look the same

Worker
0  libsystem_kernel.dylib         0x181d7cfd8 mach_msg_trap + 8
1  libsystem_kernel.dylib         0x181d7ce54 mach_msg + 72
2  CoreFoundation                 0x1821b4c60 __CFRunLoopServiceMachPort + 196
3  CoreFoundation                 0x1821b2964 __CFRunLoopRun + 1032
4  CoreFoundation                 0x1820dcc50 CFRunLoopRunSpecific + 384
5  CoreFoundation                 0x18212a3a4 CFRunLoopRun + 112
6  Mapbox                         0x10180c924 void mbgl::util::Thread<mbgl::Worker::Impl>::run<std::__1::tuple<> >(std::__1::tuple<>&&, std::__1::integer_sequence<unsigned long>) + 88
7  Mapbox                         0x10180c888 std::__1::__thread_proxy<std::__1::tuple<mbgl::util::Thread<mbgl::Worker::Impl>::Thread<>(mbgl::util::ThreadContext const&)::'lambda'()> >(void*, void*) + 136
8  libsystem_pthread.dylib        0x181e63b28 _pthread_body + 156
9  libsystem_pthread.dylib        0x181e63a8c _pthread_body + 154
10 libsystem_pthread.dylib        0x181e61028 thread_start + 4

Activity

  1. added
    iOS
    on Jul 20, 2016
  2. 1ec5 commented on Jul 23, 2016

    @1ec5
    Contributor

    We’ve seen some reports of this exact crash as well, on iOS 9.2.1 on an iPhone 6, several minutes after launch. It looks vaguely similar to #1792. From your crash logs, are you able to tell whether the application is in the foreground, background, or background mode? Never mind, you said foreground already.

  3. changed the title [-]Crash in AGXGLDriver[/-] [+]Crash rendering the map — mbgl::FillBucket::drawElements, glrAGXRenderVertexArray[/+] on Jul 23, 2016
  4. added
    Core
    on Jul 23, 2016
  5. 1ec5 commented on Jul 23, 2016

    @1ec5
    Contributor

    Also, does anything appear in the console around the time of the crash, as suggested in this Apple Developer Forums thread?

    /cc @kkaefer @brunoabinader @jfirebaugh

  6. added this to the ios-v3.4.0 milestone on Jul 23, 2016
  7. 1ec5 commented on Jul 27, 2016

    @1ec5
    Contributor

    Based on other reports we’ve received, as well as some automated reports via an internal testing tool, this issue appears to be triggered or exacerbated by continuous animation of the viewport for long stretches of time. Does that describe your situation, @MikeKasperlik?

  8. MikeKasperlik commented on Jul 28, 2016

    @MikeKasperlik
    Author

    We animate the viewport, but not for a long time. Based on what the user does, it can happen that the viewport gets animated often, but that are separate animations. I checked the logs and in some cases we do had similar entries as described in the developer thread.

  9. incanus commented on Aug 22, 2016

    @incanus
    Contributor

    @MikeKasperlik Any chance you can share a minimal piece of code that triggers (always or frequently) this problem? Going to start looking into this.

  10. self-assigned this
    on Aug 22, 2016
  11. incanus commented on Aug 22, 2016

    @incanus
    Contributor

    Going to try to repro myself and investigate.

  12. incanus commented on Aug 22, 2016

    @incanus
    Contributor

    Also @MikeKasperlik more info welcome on device and/or version. Haven't documented this on devices newer than iPhone 6 or iOS later than 9.2.1 yet.

  13. 1ec5 commented on Aug 22, 2016

    @1ec5
    Contributor

    Actually, we’re seeing some reports internally of similar crashes on iOS 9.3.3 on iPhone 6 Plus.

  14. MikeKasperlik commented on Aug 23, 2016

    @MikeKasperlik
    Author

    @incanus I can't say whats triggering this unfortunately. I do can provide you some more information:

    Device stats:

    iPhone 6 - 53%
    iPhone 6 Plus -31%
    iPhone 6s - 12%
    Other… - 4%
    

    Operating system:

    9.3.3 - 69%
    9.3.4 - 31%
    

    Device status:

    App in-focus - 100%
    

    What's strange about this is, that we received quite a lot crashes until August 18th. Since then not a single crash without updating our app - maybe something with the delivered tiles ?

  15. 20 remaining items

  16. u10int commented on Oct 7, 2016

    @u10int

    This is by far one of the most frequent crashes we're also seeing within our app since upgrading to v3.3.x of the Mapbox iOS SDK, among many other OpenGL-related crashes. Others have provided similar stacktraces related to this same issue, but here's another from our app which is using v3.3.4 of the SDK:

    Crashed: com.apple.main-thread
    0  libsystem_platform.dylib       0x1821de2a0 _platform_memmove + 176
    1  AGXGLDriver                    0x19412bf6c glrAGXRenderVertexArray(GLDContextRec*, unsigned int, unsigned int, int, int, unsigned int, void const*, int, void const*)
    2  AGXGLDriver                    0x19412bf6c glrAGXRenderVertexArray(GLDContextRec*, unsigned int, unsigned int, int, int, unsigned int, void const*, int, void const*)
    3  GLEngine                       0x194eceea4 glDrawElements_ACC_ES2Exec
    4  Mapbox                         0x100c9b94c mbgl::FillBucket::drawElements(mbgl::PlainShader&, mbgl::gl::ObjectStore&) + 284
    5  Mapbox                         0x100ca5ce4 mbgl::Painter::renderFill(mbgl::FillBucket&, mbgl::style::FillLayer const&, mbgl::UnwrappedTileID const&, std::__1::array<double, 16ul> const&) + 3852
    6  Mapbox                         0x100ca2b18 void mbgl::Painter::renderPass<std::__1::reverse_iterator<std::__1::__wrap_iter<mbgl::RenderItem const*> > >(mbgl::RenderPass, std::__1::reverse_iterator<std::__1::__wrap_iter<mbgl::RenderItem const*> >, std::__1::reverse_iterator<std::__1::__wrap_iter<mbgl::RenderItem const*> >, int, signed char) + 688
    7  Mapbox                         0x100ca21ac mbgl::Painter::render(mbgl::style::Style const&, mbgl::FrameData const&, mbgl::SpriteAtlas&) + 1424
    8  Mapbox                         0x100c901d8 mbgl::Map::Impl::render() + 160
    9  Mapbox                         0x100c90048 mbgl::Map::render() + 128
    10 Mapbox                         0x100c14270 -[MGLMapView glkView:drawInRect:] + 48
    11 GLKit                          0x18ac1d36c -[GLKView _display:] + 332
    12 Mapbox                         0x100c14a0c -[MGLMapView updateFromDisplayLink] + 68
    13 QuartzCore                     0x1850bc22c CA::Display::DisplayLinkItem::dispatch() + 40
    14 QuartzCore                     0x1850bc0e0 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 424
    15 IOKit                          0x1827f9e54 IODispatchCalloutFromCFMessage + 372
    16 CoreFoundation                 0x182521030 __CFMachPortPerform + 180
    17 CoreFoundation                 0x1825397d4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
    18 CoreFoundation                 0x182538f0c __CFRunLoopDoSource1 + 436
    19 CoreFoundation                 0x182536c64 __CFRunLoopRun + 1800
    20 CoreFoundation                 0x182460c50 CFRunLoopRunSpecific + 384
    21 GraphicsServices               0x183d48088 GSEventRunModal + 180
    22 UIKit                          0x18774e088 UIApplicationMain + 204
    23 TheOutbound                    0x1001aa050 main (AppDelegate.swift:19)
    24 libdispatch.dylib              0x181ffe8b8 (Missing)
    

    Haven't really seen any of these crashes come in for iOS 10 yet as most are from iOS 9.0. Also, it doesn't appear as if it's memory-related as several crashes were reporting free RAM > 15%.

  17. jfirebaugh commented on Oct 12, 2016

    @jfirebaugh
    Contributor

    A common thread in all the stack traces is that the crash occurs when rendering the opaque pass for a fill layer. (You can tell it's the opaque pass because Painter::renderPass is specialized for reverse_iterator in the stack trace.) And from a couple complete crash logs, it appears to be a SIGSEGV on 0x0.

    I saw a crash like this when working on #6468. It happened when I introduced a bug that resulted in calling glDrawElements when the currently-bound VAO had no element buffer binding. This is equivalent to calling glDrawElements with no element buffer bound, in which case it interprets the final argument (whose value is usually (void*)0) as a pointer to CPU memory and tries to read from it.

    As a test, I reintroduced the bug in #6468 and I get almost exactly the same stack trace as seen here. In particular, the top of the stack trace is _platform_memmove + 176 -- the same symbol and offset. So I'm somewhat confident this crash is caused by calling glDrawElements with a VAO in which no element buffer is bound.

    How would this happen? A VAO will have an unbound element buffer if:

    1. You forget to call glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, …) after binding the VAO. (This was what the bug in C++ bindings for OpenGL #6468 was.)
    2. You call glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0) with the VAO bound.
    3. You call glDeleteBuffers(…) on the bound buffer, with the VAO bound.
    4. You call glDeleteBuffers(…) on the bound buffer, without the VAO bound. (This is supposedly ok per the spec but problematic in practice.)

    I think this list is exhaustive. @kkaefer @ansis Can you think of anything I'm missing?

    I've combed through the code, and I can't see where any of these issues are present. In particular:

    • We always immediately bind an element buffer after creating a new VAO. I don't see any way in which this would be short circuited. So (1) seems very unlikely.
    • We delete the relevant element buffer only when we're also deleting the VAO in which it's bound. So (3) and (4) seem unlikely.
    • (2) seems like a more plausible cause -- we leave the VAO bound until the next VAO binding, or until the end of the current frame. So, if there is some code that is unaware that a VAO is bound, it could potentially unbind the current element buffer, which would affect the VAO. However, the only way I can see that being possible is with a custom layer, and we do unbind the VAO before rendering custom layers.
    • The only other place in the code that even calls glBindBuffer is Buffer::bind. Is it somehow possible that Buffer::buffer winds up containing a gl::UniqueBuffer value of 0? That would happen if glGenBuffers produced 0, or merely did not overwrite the 0 that we initialize to. However, this seems implausible; I can't find any indications that glGenBuffers can really "fail".

    Another question that might be the key to unravelling this is: why do we only see crashes in fill layers, and not any other layer type? If it was really a bug with VAO state, I'd expect at least some crashes on other layer types, since our use of VAOs isn't specific to fill layers.

  18. jfirebaugh commented on Oct 12, 2016

    @jfirebaugh
    Contributor

    Other hypotheses explored, none of which seem plausible:

    • The call to VertexArrayObject::bind in question is sometimes called with 4 arguments (no element buffer) and sometimes 5. Doesn't seem to be the case.
    • Multiple VertexArrayObjects are somehow improperly sharing a single VAO id. Implausible.
    • Third party GL code is getting injected somehow and running on the main thread while our GL context is active. Implausible.
    • glGenVertexArrays or glBindVertexArray fail, producing VAO id 0 or an unbound VAO. In this situation, the first call to glDrawElements would work: VertexArrayObject::bind would bind the necessary buffers, and it would look to glDrawElements like you're simply not using a VAO. But then the second time glDrawElements was called, VertexArrayObject::bound_shader would be non-zero so VertexArrayObject::bind wouldn't do anything.

    Perhaps if a build that calls glGetError after every GL API call were widely distributed (i.e. define MBGL_CHECK_ERROR even in Release configuration), we would catch some invalid API use that precedes the crash.

  19. aish504 commented on Oct 13, 2016

    @aish504

    Hi Mapbox,
    We got the same crash, caught in Crashlytics

    Crashed: com.apple.main-thread
    0  libsystem_platform.dylib       0x18248e2a0 _platform_memmove + 176
    1  AGXGLDriver                    0x19429bf6c glrAGXRenderVertexArray(GLDContextRec*, unsigned int, unsigned int, int, int, unsigned int, void const*, int, void const*)
    2  AGXGLDriver                    0x19429bf6c glrAGXRenderVertexArray(GLDContextRec*, unsigned int, unsigned int, int, int, unsigned int, void const*, int, void const*)
    3  GLEngine                       0x19503eea4 glDrawElements_ACC_ES2Exec
    4  Mapbox                         0x100f4b94c mbgl::FillBucket::drawElements(mbgl::PlainShader&, mbgl::gl::ObjectStore&) + 284
    5  Mapbox                         0x100f55ce4 mbgl::Painter::renderFill(mbgl::FillBucket&, mbgl::style::FillLayer const&, mbgl::UnwrappedTileID const&, std::__1::array<double, 16ul> const&) + 3852
    6  Mapbox                         0x100f52b18 void mbgl::Painter::renderPass<std::__1::reverse_iterator<std::__1::__wrap_iter<mbgl::RenderItem const*> > >(mbgl::RenderPass, std::__1::reverse_iterator<std::__1::__wrap_iter<mbgl::RenderItem const*> >, std::__1::reverse_iterator<std::__1::__wrap_iter<mbgl::RenderItem const*> >, int, signed char) + 688
    7  Mapbox                         0x100f521ac mbgl::Painter::render(mbgl::style::Style const&, mbgl::FrameData const&, mbgl::SpriteAtlas&) + 1424
    8  Mapbox                         0x100f401d8 mbgl::Map::Impl::render() + 160
    9  Mapbox                         0x100f40048 mbgl::Map::render() + 128
    10 Mapbox                         0x100ec4270 -[MGLMapView glkView:drawInRect:] + 48
    11 GLKit                          0x18aec536c -[GLKView _display:] + 332
    12 Mapbox                         0x100ec4a0c -[MGLMapView updateFromDisplayLink] + 68
    13 QuartzCore                     0x18536422c CA::Display::DisplayLinkItem::dispatch() + 40
    14 QuartzCore                     0x1853640e0 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 424
    15 IOKit                          0x182aa9e54 IODispatchCalloutFromCFMessage + 372
    16 CoreFoundation                 0x1827d1030 __CFMachPortPerform + 180
    17 CoreFoundation                 0x1827e97d4 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
    18 CoreFoundation                 0x1827e8f0c __CFRunLoopDoSource1 + 436
    19 CoreFoundation                 0x1827e6c64 __CFRunLoopRun + 1800
    20 CoreFoundation                 0x182710c50 CFRunLoopRunSpecific + 384
    21 GraphicsServices               0x183ff8088 GSEventRunModal + 180
    22 UIKit                          0x1879f6088 UIApplicationMain + 204
    23 ABAS Beta                      0x1001208d0 main (main.m:14)
    24 libdispatch.dylib              0x1822ae8b8 (Missing)
    

    Any immediate fix?

  20. jfirebaugh commented on Oct 19, 2016

    @jfirebaugh
    Contributor

    As a data-gathering mechanism, 596f9c5 enables error checking for all GL calls. We're not going to apply it in mainline releases because there may be usage scenarios where it would have a performance impact, but we can make targeted test builds that include it and see if they reveal anything interesting.

    /cc @frederoni

  21. MarcosMunoz commented on Oct 21, 2016

    @MarcosMunoz

    For us it is happening very often in different devices, we use a map with a custom style.

    #0. Crashed: com.apple.main-thread
    0  libsystem_platform.dylib       0x189b26e30 _platform_memmove + 48
    1  AppleMetalGLRenderer           0x1a5df89e4 (Missing)
    2  AppleMetalGLRenderer           0x1a5df89e4 (Missing)
    3  AppleMetalGLRenderer           0x1a5df91cc (Missing)
    4  GLEngine                       0x19f46611c glDrawElements_ACC_ES2Exec
    5  Mapbox                         0x101f0b94c mbgl::FillBucket::drawElements(mbgl::PlainShader&, mbgl::gl::ObjectStore&) + 284
    6  Mapbox                         0x101f15ce4 mbgl::Painter::renderFill(mbgl::FillBucket&, mbgl::style::FillLayer const&, mbgl::UnwrappedTileID const&, std::__1::array<double, 16ul> const&) + 3852
    7  Mapbox                         0x101f12b18 void mbgl::Painter::renderPass<std::__1::reverse_iterator<std::__1::__wrap_iter<mbgl::RenderItem const*> > >(mbgl::RenderPass, std::__1::reverse_iterator<std::__1::__wrap_iter<mbgl::RenderItem const*> >, std::__1::reverse_iterator<std::__1::__wrap_iter<mbgl::RenderItem const*> >, int, signed char) + 688
    8  Mapbox                         0x101f121ac mbgl::Painter::render(mbgl::style::Style const&, mbgl::FrameData const&, mbgl::SpriteAtlas&) + 1424
    9  Mapbox                         0x101f001d8 mbgl::Map::Impl::render() + 160
    10 Mapbox                         0x101f00048 mbgl::Map::render() + 128
    11 Mapbox                         0x101e84270 -[MGLMapView glkView:drawInRect:] + 48
    12 GLKit                          0x19499bb50 -[GLKView _display:] + 216
    13 Mapbox                         0x101e84a0c -[MGLMapView updateFromDisplayLink] + 68
    14 QuartzCore                     0x18dc9f640 CA::Display::DisplayLinkItem::dispatch(unsigned long long) + 44
    15 QuartzCore                     0x18dc9f4ec CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 444
    16 IOKit                          0x18ad08570 IODispatchCalloutFromCFMessage + 372
    17 CoreFoundation                 0x18aa3256c __CFMachPortPerform + 180
    18 CoreFoundation                 0x18aa4a934 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
    19 CoreFoundation                 0x18aa4a0e8 __CFRunLoopDoSource1 + 436
    20 CoreFoundation                 0x18aa47bcc __CFRunLoopRun + 1840
    21 CoreFoundation                 0x18a976048 CFRunLoopRunSpecific + 444
    22 GraphicsServices               0x18c3f9198 GSEventRunModal + 180
    23 UIKit                          0x190950628 -[UIApplication _run] + 684
    24 UIKit                          0x19094b360 UIApplicationMain + 208
    25 CycleWE                        0x1004076e4 main (AppDelegate.swift:18)
    26 libdispatch.dylib              0x1899585b8 (Missing)
    
  22. jfirebaugh commented on Nov 9, 2016

    @jfirebaugh
    Contributor

    I was finally able to reproduce the bug locally and determine the cause. The crash is triggered when an application which uses multiple map views encounters a low-memory situation. In such a situation, Map::onLowMemory() is called for each map. This method in turn calls a function which deletes unused but not yet deleted OpenGL resources, including VAOs.

    However, Map::onLowMemory() failed to ensure the activation of the GL context to which those resources belong. Thus, the resources would get deleted in whichever context happens to be current at the time, most likely a context belonging to one of the other maps, which may be actively using identically-numbered resources. When this context subsequently attempts to use those resources, an error occurs. The error that I observed was glBindVertexArray returning GL_INVALID_OPERATION -- we didn't observe this in the wild, but 596f9c5 was on the right track and may have eventually helped. In the absence of that change, the glBindVertexArray failure would have gone unnoticed, and I can easily see ways in which a subsequent draw operation with an unbound element buffer could occur.

    The fix is simple: #6972. We'll need to cherry pick this to the iOS and Android release branches, and should also consider an iOS 3.3.6 release that includes it -- I'm not sure that 057b7b7 will end up helping much.

  23. 1ec5 commented on Nov 9, 2016

    @1ec5
    Contributor

    I'm not sure that 057b7b7 will end up helping much.

    Should we revert 057b7b7 for v3.3.6?

  24. jfirebaugh commented on Nov 9, 2016

    @jfirebaugh
    Contributor

    Yep.

  25. boundsj commented on Nov 10, 2016

    @boundsj
    Contributor

    Published ios-v3.3.6

  26. volonbolon commented on Nov 14, 2016

    @volonbolon

    Upgraded to 3.3.6 and still crashing

    * thread #1: tid = 0xafecb, 0x00000001026bbc2c Mapbox`mbgl::LineAtlas::upload(mbgl::gl::ObjectStore&), queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x567b0a78c6f5)
        frame #0: 0x00000001026bbc2c Mapbox`mbgl::LineAtlas::upload(mbgl::gl::ObjectStore&)
        frame #1: 0x00000001026d15e0 Mapbox`mbgl::Painter::render(mbgl::style::Style const&, mbgl::FrameData const&, mbgl::SpriteAtlas&) + 360
        frame #2: 0x00000001026bf9e8 Mapbox`mbgl::Map::Impl::render() + 160
        frame #3: 0x00000001026bf858 Mapbox`mbgl::Map::render() + 128
        frame #4: 0x00000001026437f4 Mapbox`___lldb_unnamed_function437$$Mapbox + 48
        frame #5: 0x0000000194b44b50 GLKit`-[GLKView _display:] + 216
        frame #6: 0x0000000102643f90 Mapbox`___lldb_unnamed_function444$$Mapbox + 68
        frame #7: 0x0000000103087b1c GPUToolsCore`-[DYDisplayLinkInterposer forwardDisplayLinkCallback:] + 176
        frame #8: 0x000000018dde71bc QuartzCore`CA::Display::DisplayLinkItem::dispatch(unsigned long long) + 44
        frame #9: 0x000000018dde7068 QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 444
        frame #10: 0x000000018ae47138 IOKit`IODispatchCalloutFromCFMessage + 372
        frame #11: 0x000000018ab7056c CoreFoundation`__CFMachPortPerform + 180
        frame #12: 0x000000018ab88934 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
        frame #13: 0x000000018ab880e8 CoreFoundation`__CFRunLoopDoSource1 + 436
        frame #14: 0x000000018ab85bcc CoreFoundation`__CFRunLoopRun + 1840
        frame #15: 0x000000018aab4048 CoreFoundation`CFRunLoopRunSpecific + 444
        frame #16: 0x000000018c53a198 GraphicsServices`GSEventRunModal + 180
        frame #17: 0x0000000190aa02fc UIKit`-[UIApplication _run] + 684
        frame #18: 0x0000000190a9b034 UIKit`UIApplicationMain + 208
      * frame #19: 0x00000001000b8c74 Vigilante`main + 144 at AppDelegate.swift:18
        frame #20: 0x0000000189a985b8 libdyld.dylib`start + 4
    (lldb) 
    
  27. jfirebaugh commented on Nov 14, 2016

    @jfirebaugh
    Contributor

    @volonbolon That is a different crash signature, one that I don't believe we've seen before. Can you please open a separate issue?

  28. volonbolon commented on Nov 14, 2016

    @volonbolon

    Sure

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    CorecrashiOS

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions