title: cocos2d-x game crashes when entered background
body: <p>my cocos2d-x game crashes when entering background. here is some code from AppDelegate: </p>
  
  <pre><code>// This function will be called when the app is inactive. When comes a phone call,it's be invoked too
  void AppDelegate::applicationDidEnterBackground()
  {
  
      CCDirector::sharedDirector()-&gt;pause();
  
      CCUserDefault::sharedUserDefault()-&gt;flush();
  
      CocosDenshion::SimpleAudioEngine::sharedEngine()-&gt;pauseBackgroundMusic();
  
  }
  
  // this function will be called when the app is active again
  void AppDelegate::applicationWillEnterForeground()
  {
  
  
      CCDirector::sharedDirector()-&gt;resume();
  
      CocosDenshion::SimpleAudioEngine::sharedEngine()-&gt;resumeBackgroundMusic();
  }
  </code></pre>
  
  <p>and the error message: </p>
  
  <pre><code>libGPUSupportMercury.dylib`gpus_ReturnNotPermittedKillClient:
  0x3797e094:  trap   
  0x3797e096:  nop    
  </code></pre>
  
  <p>note that it always crashes for iPhone, but 99% crashes on Android (okay when the game haven't load large images etc)</p>
  
  <p>EDIT:
  I've tried CCDirector::sharedDirector()->stopAnimation() and it works great for iOS. But still crashes for Android (not immediately. when returning back to the app, the screen become black (but i think it is still running because background music is still playing. then about 5 seconds later it crashes)</p>
  
  <p>EDIT 2: 
  The error message in Eclipse: </p>
  
  <pre><code>libEGL   call to OpenGL ES API with no current context (logged once per thread)      (red warning text)
  
  libc     Fatal signal 11 (SIGSEGV) at 0x5f012000 (code=2)                  (black text)
  </code></pre>