Application crashing after 5 mins

Hi Guys,

My Game is crashing after playing it for five Minutes. For debug purpose, I checked and left the game running for another 5 minutes (without touching screen) and it crashed again.
Then I checked by just loading default class that comes with the project: HelloWorld and for strange it crashed again just after 5 mins.

It seems there is bug with the Cocos2D-x? I am using cocos2d-2.1beta3-x-2.1.0

Thanks,
Paras Mendiratta

Did you just build the HelloCpp project in cocos2d-2.1beta3-x-2.1.0 and it crashed after 5 mins?
Or you copied the HelloWorldScene.* to your game project?
And what’s the platform you tested?

Do you have a stack trace of the crash?
In what device are you building?

James:Lance

I used the HelloWorld file that generates by default with the project. The main culprit of crash with HelloWorld was autorelease of CCDirector.

I tested it further and removed the HelloWorld and autorelease of CCDirector this time but still game is crashing exactly after 5 min. I did couple of more test during whole night and I found that when I am using CCLayerGradient or full screen sprite image in the game then it is crashing.
To prove me wrong again, I tested it with again HelloWorld class and added a CCLayerGradient at z index = 1. The project crash just after 5 mins.
However when I check TestCpp project. It is working fine with CCLayerGradient. So definitely, I am doing something wrong here.
Here is the stack trace…
#0 0x031fd9de in void glgConvertTo_32<GLGConverter_ABGR8_ARGB8, (GLGMemory)2>
#1 0x031fa100 in glgProcessPixelsWithProcessor
#2 0x0f397173 in glGetTexImage_Exec
#3 0x0f43e9f3 in gliPresentViewES
#4 0x0073f884 in
[EAGLContext presentRenderbuffer:] ()
#5 0x000bed32 in at /Volumes/Development/tools/Cocos2D-X/cocos2d-2.1beta3-x-2.1.0/TestGame/proj.ios/TestGame/TestGame/libs/cocos2dx/platform/ios/EAGLView.mm:319
#6 0x000b7402 in cocos2d::CCEGLView::swapBuffers at /Volumes/Development/tools/Cocos2D-X/cocos2d-2.1beta3-x-2.1.0/TestGame/proj.ios/TestGame/TestGame/libs/cocos2dx/platform/ios/CCEGLView.mm:70
#7 0x0003c68a in cocos2d::CCDirector::drawScene at /Volumes/Development/tools/Cocos2D-X/cocos2d-2.1beta3-x-2.1.0/TestGame/proj.ios/TestGame/TestGame/libs/cocos2dx/CCDirector.cpp:252
#8 0x0003ea3b in cocos2d::CCDisplayLinkDirector::mainLoop at /Volumes/Development/tools/Cocos2D-X/cocos2d-2.1beta3-x-2.1.0/TestGame/proj.ios/TestGame/TestGame/libs/cocos2dx/CCDirector.cpp:944
#9 0x000b6e95 in
[CCDirectorCaller doCaller:] at /Volumes/Development/tools/Cocos2D-X/cocos2d-2.1beta3-x-2.1.0/TestGame/proj.ios/TestGame/TestGame/libs/cocos2dx/platform/ios/CCDirectorCaller.mm:93
#10 0x0067b2d2 in CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long) ()
#11 0x0067b75f in CA::Display::TimerDisplayLink::callback(CFRunLoopTimer*, void**)
#12 0x02627376 inCFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION_
#13 0x02626e06 in**CFRunLoopDoTimer
#14 0x0260ea82 in*_CFRunLoopRun ()
#15 0x0260df44 in CFRunLoopRunSpecific ()
#16 0x0260de1b in CFRunLoopRunInMode ()
#17 0x030017e3 in GSEventRunModal ()
#18 0x03001668 in GSEventRun ()
#19 0x00d4965c in UIApplicationMain ()
#20 0x000038d6 in main at /Volumes/Development/tools/Cocos2D-X/cocos2d-2.1beta3-x-2.1.0/TestGame/proj.ios/TestGame/TestGame/ios/main.m:14

applicationDidFinishLaunching method code

`bool AppDelegate::applicationDidFinishLaunching()
{
// initialize director
CCDirector *pDirector = CCDirector::sharedDirector();
pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());

CCSize screenSize = CCEGLView::sharedOpenGLView()->getFrameSize();

CCSize designSize = CCSizeMake(480, 320);

if (screenSize.height > 320)
{
    CCSize resourceSize = CCSizeMake(960, 640);
    CCFileUtils::sharedFileUtils()->setResourceDirectory("hd");
    pDirector->setContentScaleFactor(resourceSize.height/designSize.height);
}

CCEGLView::sharedOpenGLView()->setDesignResolutionSize(designSize.width, designSize.height, kResolutionNoBorder);

// turn on display FPS
pDirector->setDisplayStats(true);

// set FPS. the default value is 1.0/60 if you don't call this
pDirector->setAnimationInterval(1.0 / 60);

CCScene * pScene = HelloWorld::scene();
pDirector->runWithScene(pScene);

return true;

}
`

okay I guess, I create a blank Cocos2d-x iOS project and added a GradientLayer in the HelloWorld.

The application crashes just after 5 mins. I am testing it iPad Retina emulator. :frowning:

StackTrace as follows:-

#0 0x031d999a in void glgConvertTo_32<GLGConverter_ABGR8_ARGB8, (GLGMemory)2>(GLGOperationRec const**, GLDPixelModeRec const**) ()
#1 0x031d6100 in glgProcessPixelsWithProcessor ()
#2 0x0f705780 in gldRestoreTextureData ()
#3 0x031adaf5 in gfxUploadPluginTextureLevel ()
#4 0x0f5132b7 in gleSynchronizeTextureLevelOnCurrentDevicesForRead ()
#5 0x0f46fe26 in glGetTexImage_Exec ()
#6 0x0f5179f3 in gliPresentViewES ()
#7 0x0071b884 in ~~
#8 0x000be752 in~~[EAGLView swapBuffers] at /Volumes/Development/poc/TestProject/TestProject/libs/cocos2dx/platform/ios/EAGLView.mm:319
#9 0x000b6e22 in cocos2d::CCEGLView::swapBuffers() at /Volumes/Development/poc/TestProject/TestProject/libs/cocos2dx/platform/ios/CCEGLView.mm:70
#10 0x0003c0aa in cocos2d::CCDirector::drawScene() at /Volumes/Development/poc/TestProject/TestProject/libs/cocos2dx/CCDirector.cpp:252
#11 0x0003e45b in cocos2d::CCDisplayLinkDirector::mainLoop() at /Volumes/Development/poc/TestProject/TestProject/libs/cocos2dx/CCDirector.cpp:944
#12 0x000b68b5 in -[CCDirectorCaller doCaller:] at /Volumes/Development/poc/TestProject/TestProject/libs/cocos2dx/platform/ios/CCDirectorCaller.mm:93
#13 0x006572d2 in CA::Display::DisplayLink::dispatch(unsigned long long, unsigned long long) ()
#14 0x0065775f in CA::Display::TimerDisplayLink::callback(CFRunLoopTimer*, void**)
#15 0x02603376 inCFRUNLOOP_IS_CALLING_OUT_TO_A_TIMER_CALLBACK_FUNCTION_
#16 0x02602e06 in**CFRunLoopDoTimer
#17 0x025eaa82 in*_CFRunLoopRun ()
#18 0x025e9f44 in CFRunLoopRunSpecific ()
#19 0x025e9e1b in CFRunLoopRunInMode ()
#20 0x02fdd7e3 in GSEventRunModal ()
#21 0x02fdd668 in GSEventRun ()
#22 0x00d2565c in UIApplicationMain ()
#23 0x000032f6 in main at /Volumes/Development/poc/TestProject/TestProject/ios/main.m:14
#24 0x000026b5 in start ()

The code added by me in HelloWorld::init() is as follow
@
ccColor4B startColor = ccc4(255, 255, 255, 255);
ccColor4B endColor = ccc4(255, 0, 0, 255);

CCLayerGradient **gradientLayer = CCLayerGradient::create;
this->addChild;@
Can anybody suggest or guide me what is going wrong here. :frowning:
Thanks,
**Paras Mendiratta*

Yep, I also tested it on iphone simulator. And it crashed too.
Does cocos2d-iphone also crash?

No. With Cocos2d-iPhone there is no crashes.

Strange. I changed the z order to 100, there are no crashes.
Seems that the it crashed into opengl functions.

I tested the project our my iPad with zOrder = –1 only and it didn’t crash. I checked it about 10 mins.
Now I am checking my game over iPad again. Let’s see if that crashes too.

@James:

The game is not crashing over iPad. It is running since past 15 minutes. Looks like it was problem with emulator? not sure.
Let me run it for another 1 hour.

The game is running fine over iPad. Its been an hour and no crash experienced.

I am happy :slight_smile:

Thanks for your time James

Yes, i couldn’t make it crash on my iphone simulator retina 4-inch now. Changing the z order to –1 also can’t make it crash. I don’t know why.
So let me know whether you game run on device crashes after one hour. Thanks.

Paras Mendiratta wrote:

@James:
>
The game is not crashing over iPad. It is running since past 15 minutes. Looks like it was problem with emulator? not sure.
Let me run it for another 1 hour.

I’m glad to hear that. :slight_smile:

Paras Mendiratta wrote:

The game is running fine over iPad. Its been an hour and no crash experienced.
>
I am happy :slight_smile:
>
Thanks for your time James

I do not really understand how you fixed it. Did you changed all orders < 100 ?

I have the same crash stack too. Not really understand the solution, zorder smaller than 100 will fix it?

I solved this problem by disabling GL_EXT_discard_framebuffer extension in CCConfiguration for IOS using

#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
m_bSupportsDiscardFramebuffer = false;
#else
m_bSupportsDiscardFramebuffer = checkForGLExtension(“GL_EXT_discard_framebuffer”);
#endif

This do not solve the problem for my game. it only appear less often.