按Home鍵切換到后台后會觸發libGPUSupportMercury.dylib: gpus_ReturnNotPermittedKillClient導致crash


轉自: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


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM