title: How to avoid crash "OpenGL rendering while app in background state"
body: <p>I got many crash reports recently on fabric. It says Based on the stack trace displayed here, it looks like new calls triggering OpenGL rendering took place while the app was transitioning to, or from, a background state. If you set up OpenGL drawing in your app delegate's methods, make sure that you only did so in applicationDidBecomeActive:, never in application:willFinishLaunchingWithOptions: or application:didFinishLaunchingWithOptions:. </p>
  
  <pre><code>0   libGPUSupportMercury.dylib  gpus_ReturnNotPermittedKillClient
  1   AGXGLDriver (Missing)
  2   libGPUSupportMercury.dylib  gpusSubmitDataBuffers
  3   AGXGLDriver (Missing)
  4   WebCore WebCore::GraphicsContext3D::reshape(int, int) + 580
  5   WebCore WebCore::WebGLRenderingContextBase::initializeNewContext() + 936
  6   WebCore WebCore::WebGLRenderingContextBase::WebGLRenderingContextBase(WebCore::CanvasBase&amp;, WTF::Ref&lt;WebCore::GraphicsContext3D, WTF::DumbPtrTraits&lt;WebCore::GraphicsContext3D&gt; &gt;&amp;&amp;, WebCore::GraphicsContext3DAttributes) + 660
  7   WebCore WebCore::WebGLRenderingContext::create(WebCore::CanvasBase&amp;, WTF::Ref&lt;WebCore::GraphicsContext3D, WTF::DumbPtrTraits&lt;WebCore::GraphicsContext3D&gt; &gt;&amp;&amp;, WebCore::GraphicsContext3DAttributes) + 84
  8   WebCore WebCore::WebGLRenderingContextBase::create(WebCore::CanvasBase&amp;, WebCore::GraphicsContext3DAttributes&amp;, WTF::String const&amp;) + 1416
  9   WebCore WebCore::HTMLCanvasElement::getContext(JSC::ExecState&amp;, WTF::String const&amp;, WTF::Vector&lt;JSC::Strong&lt;JSC::Unknown&gt;, 0ul, WTF::CrashOnOverflow, 16ul&gt;&amp;&amp;) + 904
  10  WebCore  WebCore::jsHTMLCanvasElementPrototypeFunctionGetContext(JSC::ExecState*) + 424
  11  JavaScriptCore  llint_entry + 89612
  12  JavaScriptCore  llint_entry + 82980
  13  JavaScriptCore  llint_entry + 82980
  14  JavaScriptCore  llint_entry + 82980
  15  JavaScriptCore  llint_entry + 82980
  16  JavaScriptCore  llint_entry + 82980
  17  JavaScriptCore  vmEntryToJavaScript + 268
  18  JavaScriptCore  JSC::Interpreter::executeCall(JSC::ExecState*, JSC::JSObject*, JSC::CallType, JSC::CallData const&amp;, JSC::JSValue, JSC::ArgList const&amp;) + 424
  19  JavaScriptCore  JSC::profiledCall(JSC::ExecState*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&amp;, JSC::JSValue, JSC::ArgList const&amp;, WTF::NakedPtr&lt;JSC::Exception&gt;&amp;) + 200
  20  WebCore  WebCore::JSExecState::profiledCall(JSC::ExecState*, JSC::ProfilingReason, JSC::JSValue, JSC::CallType, JSC::CallData const&amp;, JSC::JSValue, JSC::ArgList const&amp;, WTF::NakedPtr&lt;JSC::Exception&gt;&amp;) + 140
  21  WebCore  WebCore::ScheduledAction::executeFunctionInContext(JSC::JSGlobalObject*, JSC::JSValue, WebCore::ScriptExecutionContext&amp;) + 424
  22  WebCore  WebCore::ScheduledAction::execute(WebCore::Document&amp;) + 144
  23  WebCore  WebCore::DOMTimer::fired() + 816
  24  WebCore  WebCore::ThreadTimers::sharedTimerFiredInternal() + 216
  25  WebCore  WebCore::timerFired(__CFRunLoopTimer*, void*) + 28
  26  CoreFoundation  __CFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION__ + 28
  27  CoreFoundation  __CFRunLoopDoTimer + 864
  28  CoreFoundation  __CFRunLoopDoTimers + 248
  29  CoreFoundation  __CFRunLoopRun + 1844
  30  CoreFoundation  CFRunLoopRunSpecific + 436
  31  WebCore RunWebThread(void*) + 600
  32  libsystem_pthread.dylib _pthread_body + 128
  33  libsystem_pthread.dylib _pthread_start + 44
  34  libsystem_pthread.dylib thread_start + 4
  </code></pre>
  
  <p>How to find where the code crashes?</p>