I have a 100% reproducible crash here.
Crash if backgrounding cocos2d 2.1 app in iOS7 while watching Game Center screens (leaderboard, achievement). It crashes instantly when pushing the home button.
Crash on line 275 in CCGLView.m:
if(![_context presentRenderbuffer:GL_RENDERBUFFER])
The itching thing is, I downloaded a fresh copy of official cocos2diphone 2.1 the other second, installed its templates and ran the staple application after hooking it up to the same app id as my problematic app that already have game center leaderboards etc set up. It does not crash. So I ran a diff on the cocos2d folders inside lib, and there is no difference except I added some C functions code in CCDrawingPrimitives.h/m... Should not be the problem. So the problem should not be in cocos2d itself but somehow the use of it or my project setup causes it.
Update:
The problem seems to be in the cocos2d app template in use in 2.1 and possibly earlier. It looks like this:
-(void) applicationDidEnterBackground:(UIApplication*)application
{
if( [navController_ visibleViewController] == director_ )
[director_ stopAnimation];
}
And the obvious fault here is that if you have navController open a Game Center controller, then when pushing the home button the visibleViewController of director_ will be the GC controller, hence the stopAnimation will not get called. This results in a crash with iOS7, but doesn't seem to with iOS6... nor the template cocos2d 2.1 app (still confused here).
The current fix is to comment out if( [navController_ visibleViewController] == director_ )
in order to have stopAnimation always called. Not sure if there are any side effects with that but will go with this for now.