Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

gpus_ReturnGuiltyForHardwareRestart Crash in [EAGLContext presentRenderbuffer]

I'm getting a lot of crashes in EAGLContext presentRenderbuffer on iOS 11, but only on iPhone 6/6+ and older.

As per this post, I think we've already ruled out VBO-related problems by rewriting everything to not use VBO/VAOs, but the crash wasn't fixed by that.

There are a few other questions on SO about this but no solution -- has anyone else been seeing the uptick in this crash and been able to resolve it?


TL;DR:

Here is what we know so far:

  • The crash is specific to iOS11, iPhone 5S/6/6+. It doesn’t occur on 6S and up.
  • The core of the OpenGL stack returns gpus_ReturnGuiltyForHardwareRestart
  • It occurs when we attempt to invoke [EAGLContext presentRenderbuffer] from a CAEAGLLayer
  • We don’t have a repro.

What we have tried so far:

  • Remove any reference to VBO/VAO in our rendering stack. Didn’t help.
  • We have tried reproing with a large range of drawing scenarios (rotation, resize, background/foreground). No luck.
  • As far as we can tell, there is nothing specific in our application logic between the iPhone 6 family and the iPhone 6S family.

Some clues (that could be relevant but not necessarily):

  • We know that when the presentRenderBuffer is invoked off main thread, and some CATransaction are occurring at the same time on the main thread, the crash rate goes up.
  • When presentRenderBuffer is invoked on main thread (along with the whole drawing pipeline), the crash rate goes slightly down but not drastically.
  • A substantial chunk (~20%) of the crashes occurs when the layer goes off screen and/or gets out of the view hierarchy.

Here is the stack trace:

  libGPUSupportMercury.dylib gpus_ReturnGuiltyForHardwareRestart

1 AGXGLDriver gldUpdateDispatch
2 libGPUSupportMercury.dylib gpusSubmitDataBuffers
3 AGXGLDriver gldUpdateDispatch
4 GLEngine gliPresentViewES_Exec
5 OpenGLES -[EAGLContext presentRenderbuffer:]
like image 421
dzl Avatar asked Oct 05 '17 22:10

dzl


1 Answers

From my experience I get this sort of crashes in these cases:

  1. Calling OpenGL API when application is in UIApplicationStateBackground state.
  2. Using objects (textures, VBO, etc) that was created in OpenGL context that have different shareGroup. This can happened if you don't call [EAGLContext setCurrentContext:..] before rendering or other work with OpenGL object.
  3. Invalid geometry. For example this can happened if you allocate index buffer for bigger size that you need. Fill it with some values and then try to render with size that was used at allocation. Sometimes this works (tail of buffer is filled with 0, and you don't see any visual glitches). Sometimes it will crash (when tail of buffer filled with junk, and reference to point that is out of bounds).

Hope this helps in some way.

P.S. Maybe you tell some more info about your application? I write application that render vector maps at iOS and don't face any troubles with iOS 11 at this moment. Rendering pipeline is pretty simple CADisplayLink call our callback on main thread when we can render next frame. Each view with OpenGL scene can have several background contexts to load resources in background (ofc it have same shareGroup with main context).

like image 76
Arkadi Tolkun Avatar answered Oct 13 '22 20:10

Arkadi Tolkun