轉自:http://www.eoeandroid.com/thread-251598-1-1.html
好像有很多朋友都碰到過這個問題,即在真機調試時,按hone鍵返回桌面,再回到app時,app會crash或僵死。同時xcode停留在:
libGPUSupportMercury.dylib`gpus_ReturnNotPermittedKillClient:
0x372fa094: trap
0x372fa096: nop
原因在於AppDelegate.cpp里:
void AppDelegate::applicationDidEnterBackground() { CCDirector::sharedDirector()->pause(); } void AppDelegate::applicationWillEnterForeground() { CCDirector::sharedDirector()->resume(); }
director在app切換至后台時若被pause,它其實並沒有真正暫停,而是仍保持着每秒4幀的繪制速率。但在app處於后台時,ios是不允許app調opengl的。這個原因引發了上述問題。
解決方法是:
void AppDelegate::applicationDidEnterBackground() { CCDirector::sharedDirector()->stopAnimation(); } void AppDelegate::applicationWillEnterForeground() { CCDirector::sharedDirector()->startAnimation(); }
stopAnimation()才讓director真正暫停下來。
另:播放視頻時按home鍵crash問題:
http://blog.k-res.net/archives/1193.html