marah
December 10, 2015, 10:10am
1
I’m using cocos2dx version 2.2.6 and facing a crash that occurs randomly while running the scene. In EAGLView.mm swapBuffers method at line
if(![_context presentRenderbuffer:GL_RENDERBUFFER])
I’ve searched about it and most answers were to add these two lines to AppDelegate.cpp
void AppDelegate::applicationDidEnterBackground() {
CCDirector::sharedDirector()->stopAnimation();
}
void AppDelegate::applicationWillEnterForeground() {
CCDirector::sharedDirector()->startAnimation();
}
but It didn’t work.
and I also tried another solution which is to add these lines to CCGLProgram.cpp by changing it to .mm file.
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS)
#define _IPHONE9_0 [[[UIDevice currentDevice] systemVersion] floatValue] == 9.000
#define EXTENSION_STRING "#extension GL_OES_standard_derivatives : enable"
static NSString * g_extensionStr = @EXTENSION_STRING;
#ifdef _IPHONE9_0
NSLog(@"USING IOS9 shaders");
// BEGIN workaround for Xcode 7 ios9----
NSString *sourceStr = [NSString stringWithUTF8String:source];
BOOL hasExtension = [sourceStr containsString:g_extensionStr];
if(hasExtension) {
NSArray *strs = [sourceStr componentsSeparatedByString:g_extensionStr];
assert(strs.count == 2);
sourceStr = [strs componentsJoinedByString:@"\n"];
source = (GLchar *)[sourceStr UTF8String];
}
#endif
#endif
but also didn’t work.
2 Likes
Seems like this issue also persists in later cocos2d-x versions.
1 Like
Receiving similar crash reports from crashlytics for iOS 7 and iOS 9 (on swap buffers). Received them for cocos2dx v3.7 and v3.8, haven’t tried v3.9 yet. Though i have got this issue only once on my iOS 9 device - i’m receiving thousands of such reports.
1 Like
On iOS 7 it belongs to gpus_ReturnNotPermittedKillClient (https://developer.apple.com/library/ios/qa/qa1766/_index.html )
Few stack traces if somebody interested in:
on swapBuffers :
Thread : Crashed: com.apple.main-thread
0 libGPUSupportMercury.dylib 0x348428f6 gpus_ReturnNotPermittedKillClient + 9
1 libGPUSupportMercury.dylib 0x34843391 gpusSubmitDataBuffers + 104
2 IMGSGX535GLDriver 0x2eb6350f <redacted> + 122
3 GLEngine 0x32051a01 gliPresentViewES_Exec + 172
4 GLEngine 0x3205190f gliPresentViewES + 134
5 OpenGLES 0x3205c0cd -[EAGLContext presentRenderbuffer:] + 64
6 app-mobile 0xb2a95b -[CCEAGLView swapBuffers] + 3563390
7 app-mobile 0xabcc67 cocos2d::Director::drawScene() + 3113610
8 app-mobile 0xabdff7 cocos2d::DisplayLinkDirector::mainLoop() + 3118618
9 QuartzCore 0x322a2df3 CA::Display::DisplayLinkItem::dispatch() + 98
10 QuartzCore 0x322a2b9d CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 344
11 IOMobileFramebuffer 0x3501b75d IOMobileFramebufferVsyncNotifyFunc + 104
12 IOKit 0x30aa5451 IODispatchCalloutFromCFMessage + 248
13 CoreFoundation 0x2fd79ea9 __CFMachPortPerform + 136
14 CoreFoundation 0x2fd84a67 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
15 CoreFoundation 0x2fd84a03 __CFRunLoopDoSource1 + 346
16 CoreFoundation 0x2fd831d7 __CFRunLoopRun + 1398
17 CoreFoundation 0x2fcedebf CFRunLoopRunSpecific + 522
18 CoreFoundation 0x2fcedca3 CFRunLoopRunInMode + 106
19 GraphicsServices 0x34bf3663 GSEventRunModal + 138
20 UIKit 0x3263a14d UIApplicationMain + 1136
21 app-mobile 0x156ddf main (main.m:5)
22 libdyld.dylib 0x3aa77ab7 start + 2
On cocos2d::CameraBackgroundDepthBrush::drawBackground(cocos2d::Camera ) *
Thread : Crashed: com.apple.main-thread
0 libGPUSupportMercury.dylib 0x32b788f6 gpus_ReturnNotPermittedKillClient
1 libGPUSupportMercury.dylib 0x32b79391 gpusSubmitDataBuffers
2 IMGSGX543GLDriver 0x2ce10cd5 SubmitQueuedPackets
3 IMGSGX543GLDriver 0x2ce108c3 glrVendBeginPrimitiveBuffer
4 GLEngine 0x302e5405 gleBeginPrimitiveTCLFunc
5 GLEngine 0x302b7ce7 gleDrawArraysOrElements_ExecCore
6 GLEngine 0x302b51d5 glDrawElements_ES2Exec
7 OpenGLES 0x30339e73 glDrawElements + 38
8 app-mobile 0xa8f97f cocos2d::CameraBackgroundDepthBrush::drawBackground(cocos2d::Camera*) + 3596194
9 app-mobile 0xa501cb cocos2d::Scene::render(cocos2d::Renderer*) + 3336174
10 app-mobile 0xa19c07 cocos2d::Director::drawScene() + 3113514
11 app-mobile 0xa1aff7 cocos2d::DisplayLinkDirector::mainLoop() + 3118618
12 QuartzCore 0x30584df3 CA::Display::DisplayLinkItem::dispatch() + 98
13 QuartzCore 0x30584b9d CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 344
14 IOMobileFramebuffer 0x3335175d IOMobileFramebufferVsyncNotifyFunc + 104
15 IOKit 0x2ed87451 IODispatchCalloutFromCFMessage + 248
16 CoreFoundation 0x2e05bea9 __CFMachPortPerform + 136
17 CoreFoundation 0x2e066a67 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
18 CoreFoundation 0x2e066a03 __CFRunLoopDoSource1 + 346
19 CoreFoundation 0x2e0651d7 __CFRunLoopRun + 1398
20 CoreFoundation 0x2dfcfebf CFRunLoopRunSpecific + 522
21 CoreFoundation 0x2dfcfca3 CFRunLoopRunInMode + 106
22 GraphicsServices 0x32f29663 GSEventRunModal + 138
23 UIKit 0x3091c14d UIApplicationMain + 1136
24 app-mobile 0xb3ddf main (main.m:5)
25 libdyld.dylib 0x38e23ab7 start + 2
On cocos2d::Renderer::drawBatchedTriangles()
Thread : Crashed: com.apple.main-thread
0 libGPUSupportMercury.dylib 0x3391b932 gpus_ReturnNotPermittedKillClient + 9
1 libGPUSupportMercury.dylib 0x3391c3d1 gpusSubmitDataBuffers + 104
2 IMGSGX543RC2GLDriver 0x2dbbd2fd <redacted> + 108
3 IMGSGX543RC2GLDriver 0x2dbbe1a1 <redacted> + 3644
4 GLEngine 0x31055f7d glDrawElements_ACC_ES2Exec + 400
5 OpenGLES 0x310d9edb glDrawElements + 38
6 app-mobile 0xb184cf cocos2d::Renderer::drawBatchedTriangles() + 3480306
7 app-mobile 0xb18931 cocos2d::Renderer::flush2D() + 3481428
8 app-mobile 0xb18943 cocos2d::Renderer::flush() + 3481446
9 app-mobile 0xb18b5b cocos2d::Renderer::visitRenderQueue(cocos2d::RenderQueue&) + 3481982
10 app-mobile 0xb18c4b cocos2d::Renderer::render() + 3482222
11 app-mobile 0xaf51e1 cocos2d::Scene::render(cocos2d::Renderer*) + 3336196
12 app-mobile 0xabec07 cocos2d::Director::drawScene() + 3113514
13 app-mobile 0xabfff7 cocos2d::DisplayLinkDirector::mainLoop() + 3118618
14 QuartzCore 0x31325eef CA::Display::DisplayLinkItem::dispatch() + 98
15 QuartzCore 0x31325c99 CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 344
16 IOMobileFramebuffer 0x340f575d IOMobileFramebufferVsyncNotifyFunc + 104
17 IOKit 0x2fb165c9 IODispatchCalloutFromCFMessage + 248
18 CoreFoundation 0x2edebc55 __CFMachPortPerform + 136
19 CoreFoundation 0x2edf6847 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 34
20 CoreFoundation 0x2edf67e3 __CFRunLoopDoSource1 + 346
21 CoreFoundation 0x2edf4faf __CFRunLoopRun + 1406
22 CoreFoundation 0x2ed5f769 CFRunLoopRunSpecific + 524
23 CoreFoundation 0x2ed5f54b CFRunLoopRunInMode + 106
24 GraphicsServices 0x33ccc6d3 GSEventRunModal + 138
25 UIKit 0x316be891 UIApplicationMain + 1136
26 app-mobile 0x158ddf main (main.m:5)
27 libdyld.dylib 0x39ac0ab7 start + 2
@marah , is this issue reproducible for you?
I have few assumptions but can’t check them as can’t reliably reproduce it…
marah
December 13, 2015, 2:46pm
8
can you please tell me what are the assumptions and I’ll check them
What is the call stack when the crashes happen?
Is it crashing just while using an app? no incoming calls or other app interruption, so app is active?
My first assumption to check whether app and gl context are active at time of crash. Usually that crash indicates that opengl used in incorrect application state.
Insert next two lines in file CCEAGLView-ios.mm at beginning of the method - (void) swapBuffers:
const UIApplicationState appState = [UIApplication sharedApplication].applicationState;
const BOOL contextIsActive = [EAGLContext currentContext] == context_;
Then when app will crash navigate in call stack to the method swapBuffers and check values of these two variables by executing in lldb:
po appState
po contextIsActive
marah
December 14, 2015, 8:44am
11
@MikhailSh The values are:
appState: nil
but when I hover on it the value is 0
contextIsActive: YES
marah
December 14, 2015, 9:03am
12
@slackmoehrle this’s the call stack
thread #1: tid = libsystem_kernel.dylib`__pthread_kill + 8, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
* frame #0: libsystem_kernel.dylib`__pthread_kill + 8
frame #1: libsystem_pthread.dylib`pthread_kill + 112
frame #2: libsystem_c.dylib`abort + 140
frame #3: libsystem_malloc.dylib`szone_error + 440
frame #4: libsystem_malloc.dylib`free_list_checksum_botch + 36
frame #5: libsystem_malloc.dylib`tiny_free_list_remove_ptr + 156
frame #6: libsystem_malloc.dylib`szone_free + 1884
frame #7: CoreFoundation`CFRelease + 1088
frame #8: IOAccelerator`IOAccelContextSubmitDataBuffersExt + 172
frame #9: libGPUSupportMercury.dylib`gpusSubmitDataBuffers + 140
frame #10: GLEngine`gliPresentViewES_Exec + 176
frame #11: GLEngine`gliPresentViewES + 84
frame #12: OpenGLES`-[EAGLContext presentRenderbuffer:] + 72
frame #13: [EAGLView swapBuffers](self=0x000000014ce89210, _cmd="swapBuffers") + 688 at EAGLView.mm:320
frame #14: cocos2d::CCEGLView::swapBuffers(this=0x00000001006131b8) + 64 at CCEGLView.mm:70
frame #15: cocos2d::CCDirector::drawScene(this=0x000000014cea5c70) + 260 at CCDirector.cpp:295
frame #16: cocos2d::CCDisplayLinkDirector::mainLoop(this=0x000000014cea5c70) + 92 at CCDirector.cpp:1081
frame #17: [CCDirectorCaller doCaller:](self=0x000000014cd6c860, _cmd="doCaller:", sender=0x000000014cd781f0) + 148 at CCDirectorCaller.mm:98
frame #18: QuartzCore`CA::Display::DisplayLinkItem::dispatch() + 40
frame #19: QuartzCore`CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 424
frame #20: IOKit`IODispatchCalloutFromCFMessage + 372
frame #21: CoreFoundation`__CFMachPortPerform + 180
frame #22: CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION__ + 56
frame #23: CoreFoundation`__CFRunLoopDoSource1 + 436
frame #24: CoreFoundation`__CFRunLoopRun + 1800
frame #25: CoreFoundation`CFRunLoopRunSpecific + 384
frame #26: GraphicsServices`GSEventRunModal + 180
frame #27: UIKit`UIApplicationMain + 204
frame #28: main.m:14
frame #29: start + 4
I am working to reproduce this so I can ask the team to help.
1 Like
I created a new project: $ ./create_project.py -project MyGame -package com.MyCompany.AwesomeGame -language cpp
opened it in Xcode 7.2 with a base SDK of 9.2, targeting an iPone 6.
It works.
I added a Sprite and a RepeatForever action and it is running just fine, letting it run in the background.
Hi,
I am using cocos2dx v3.8.1 and I have the same issue with iOS9. I can’t reproduce the crash but I get a lot of crashes from users.
Did you find any solution with that?
Thank you
2 Likes
Please don’t clog this topic with v3.8.1, it was about 2.2.6. If you have a new problem, please start a new topic. If it is related, tag this thread in it.
marah
December 28, 2015, 2:33pm
18
I still have the problem after updating xCode to 7.2
Anybody manage to find a solution for this that worked? I too am affected.
@grimfate We can’t reproduce this, that I know of. I had asked for it to be looked in to.
Do you have any more info that can help us track down why this happens?
And to confirm, iOS 9 with 2.2.6?