我把cocos2dx 集成到原生,当原生IOS进入到cocos2dx游戏的时候有时候会出现奔溃,一下是bugly的堆栈
devide:iphone XS
system:12.2 (16E227)
CPU:arm64-v8a
cocos2dx版本是:cocos2dx-lua 3.2
bugly
0 Pokio | -[CCDirectorCaller doCaller:] + 44 |
---|---|
1 Pokio | -[CCDirectorCaller doCaller:] + 36 |
2 QuartzCore | CA::Display::DisplayLink::dispatch_items(unsigned long long, unsigned long long, unsigned long long) + 632 |
3 QuartzCore | 0x000000023f24a000 + 12570716441273504 |
4 CoreFoundation | 0x000000023ad4a000 + 14995689335973380 |
5 CoreFoundation | 0x000000023ad4a000 + 28161241567125504 |
6 CoreFoundation | 0x000000023ad4a000 + 3857636546762488 |
7 CoreFoundation | 0x000000023ad4a000 + 23166709997929104 |
8 CoreFoundation | CFRunLoopRunSpecific + 27275035194425796 |
9 GraphicsServices | GSEventRunModal + 9267233754710124 |
10 UIKitCore | UIApplicationMain + 29370704356966616 |
11 Pokio | 0x0000000102608000 + 26707137445028260 |
12 libdyld.dylib | _start + 4 |
我尝试过使用这个方式,可是还是会出现:
https://discuss.cocos2d-x.org/t/drawnumberofquads-crash-on-multiple-opengl-contexts/43647
参照以上链接修改后的代码
-(void) doCaller: (id) sender
{
if (isAppActive) {
cocos2d::Director* director = cocos2d::Director::getInstance();
EAGLContext* cocos2dxContext = [(CCEAGLView*)director->getOpenGLView()->getEAGLView() context];
if (cocos2dxContext != [EAGLContext currentContext])
{
glFinish();
[EAGLContext setCurrentContext: cocos2dxContext];
}
director->mainLoop();
}
}