2012-07-31 61 views
3

我修改了源码中基于测试项目的pariticle测试项目。改变Cocos2dxActivity.java文件android应用程序在基于cocos2dx的第二次运行时崩溃1.0.1 0.12.0

public static void terminateProcess(){ 
    android.os.Process.killProcess(android.os.Process.myPid()); 
} 

public static void terminateProcess(){ 
    finish(); 
} 

我用这个变化对cocos2d的-2.0-RC2-X-2.0.1,活动可以成功运行第二次。但是在cocos2d-1.0.1-x-0.12.0(甚至cocos2d-1.0.1-x-0.13.0-beta)上,Activity第一次成功运行,第二次失败,第三次成功。

新的AppDelegate代码失败。

void Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit(
    JNIEnv* env, jobject thiz, jint w, jint h) 
{ 
    if (!cocos2d::CCDirector::sharedDirector()->getOpenGLView()) 
    { 
    cocos2d::CCEGLView *view = &cocos2d::CCEGLView::sharedOpenGLView(); 
     view->setFrameWidthAndHeight(w, h); 
     cocos2d::CCDirector::sharedDirector()->setOpenGLView(view); 
     //Code failed here. 
     AppDelegate *pAppDelegate = new AppDelegate(); 
     cocos2d::CCApplication::sharedApplication().run(); 
    } 
    else 
    { 
     cocos2d::CCTextureCache::reloadAllTextures(); 
     cocos2d::CCDirector::sharedDirector()->setGLDefaultValues(); 
    } 
} 

这里是崩溃日志

07-31 15:30:05.520: I/Adreno200-EGLSUB(134): <CreateImage:896>: Android Image 
07-31 15:30:05.520: I/Adreno200-EGLSUB(134): <GetImageAttributes:1105>: RGBA_8888 
07-31 15:30:05.540: V/PhoneStatusBar(435): setLightsOn(true) 
07-31 15:30:05.600: D/memalloc(134): ion: Allocated buffer base:0x4239c000 size:1658880 fd:53 1000000 0 
07-31 15:30:05.600: D/memalloc(803): ion: Mapped buffer base:0x5cfd1000 size:1658880 offset:0 fd:81 
07-31 15:30:05.610: I/Adreno200-EGLSUB(803): <ConfigWindowMatch:2104>: Format RGB_565. 
07-31 15:30:05.610: D/memalloc(134): ion: Allocated buffer base:0x425f0000 size:798720 fd:60 1000000 0 
07-31 15:30:05.610: D/memalloc(803): ion: Mapped buffer base:0x5d166000 size:798720 offset:0 fd:84 
07-31 15:30:05.630: I/Adreno200-EGLSUB(134): <CreateImage:896>: Android Image 
07-31 15:30:05.630: I/Adreno200-EGLSUB(134): <GetImageAttributes:1105>: RGBA_8888 
07-31 15:30:05.640: I/ActivityManager(315): Displayed com.test.benchmark/org.cocos2dx.tests.TestsDemoV1: +167ms 
07-31 15:30:05.640: D/particle(803): Enter OpenCLView 
07-31 15:30:05.640: D/particle(803): Enter OpenCLView 2 
07-31 15:30:05.640: D/particle(803): Enter OpenCLView 3 
07-31 15:30:05.650: D/particle(803): Enter OpenCLView 4 
07-31 15:30:05.650: A/libc(803): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1) 
07-31 15:30:05.660: D/memalloc(803): ion: Unmapping buffer base:0x5c2d9000 size:1658880 
07-31 15:30:05.660: D/memalloc(134): ion: Freeing buffer base:0x42f50000 size:1658880 fd:47 
07-31 15:30:05.660: D/memalloc(134): ion: Unmapping buffer base:0x42f50000 size:1658880 
07-31 15:30:05.660: D/memalloc(803): ion: Unmapping buffer base:0x5c56e000 size:1658880 
07-31 15:30:05.990: D/memalloc(134): ion: Freeing buffer base:0x4315c000 size:1658880 fd:56 
07-31 15:30:05.990: D/memalloc(134): ion: Unmapping buffer base:0x4315c000 size:1658880 
07-31 15:30:06.000: V/AudioHardwareMSM8660(137): AudioStreamOutMSM72xx::write(0x1c918, 4800) dev = speaker_stereo_rx 
07-31 15:30:06.160: I/DEBUG(30740): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** 
07-31 15:30:06.160: I/DEBUG(30740): Build fingerprint: 'Xiaomi/mione_plus/mione_plus:4.0.4/IMM76D/2.7.20:user/release-keys' 
07-31 15:30:06.160: I/DEBUG(30740): pid: 803, tid: 921 >>> com.ludashi.benchmark <<< 
07-31 15:30:06.160: I/DEBUG(30740): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr deadbaad 
07-31 15:30:06.160: I/DEBUG(30740): r0 deadbaad r1 00000001 r2 40000000 r3 00000000 
07-31 15:30:06.160: I/DEBUG(30740): r4 00000000 r5 00000027 r6 00000000 r7 581adf48 
07-31 15:30:06.160: I/DEBUG(30740): r8 5ca51c10 r9 581adf40 10 00000008 fp 5ca51c24 
07-31 15:30:06.160: I/DEBUG(30740): ip 00000000 sp 5ca51b90 lr 400cd4b9 pc 400c9c18 cpsr 60000030 
07-31 15:30:06.160: I/DEBUG(30740): d0 3a6432736f636f63 d1 696c70704143433a 
07-31 15:30:06.160: I/DEBUG(30740): d2 3a3a6e6f69746163 d3 63696c7070414343 
07-31 15:30:06.160: I/DEBUG(30740): d4 0000000000000000 d5 0000000000000000 
07-31 15:30:06.160: I/DEBUG(30740): d6 0000000000000000 d7 0000000000000000 
07-31 15:30:06.160: I/DEBUG(30740): d8 436a000043340000 d9 43f00000000000ea 
07-31 15:30:06.160: I/DEBUG(30740): d10 0000000044138000 d11 0000000000000000 
07-31 15:30:06.170: I/DEBUG(30740): d12 0000000000000000 d13 0000000000000000 
07-31 15:30:06.170: I/DEBUG(30740): d14 0000000000000000 d15 0000000000000000 
07-31 15:30:06.170: I/DEBUG(30740): d16 64656c6961662022 d17 2220656c6966203a 
07-31 15:30:06.170: I/DEBUG(30740): d18 0000000000000000 d19 0000000000000000 
07-31 15:30:06.170: I/DEBUG(30740): d20 0000000000000000 d21 0000000000000000 
07-31 15:30:06.170: I/DEBUG(30740): d22 0000000000000000 d23 0000000000000000 
07-31 15:30:06.170: I/DEBUG(30740): d24 3f582b387b22f3c1 d25 3f6dcabc4571abc1 
07-31 15:30:06.170: I/DEBUG(30740): d26 3f30837711244472 d27 3f4375429245411f 
07-31 15:30:06.170: V/AudioPolicyManager(137): stopOutput() output 1, stream 1 
07-31 15:30:06.170: V/AudioPolicyManagerBase(137): changeRefCount() stream 1, count 0 
07-31 15:30:06.170: V/AudioPolicyManagerBase(137): getNewDevice() selected device 0 
07-31 15:30:06.170: V/AudioPolicyManager(137): setOutputDevice() output 1 device 0 delayMs 0 
07-31 15:30:06.170: V/AudioPolicyManager(137): setOutputDevice() setting same device 0 or null device for output 1 
07-31 15:30:06.180: I/DEBUG(30740): d28 3f133abc51b768d7 d29 3f1420ec8fb87f66 
07-31 15:30:06.180: I/DEBUG(30740): d30 3efb2a7074bf7ad4 d31 3ff0000000000000 
07-31 15:30:06.180: I/DEBUG(30740): scr 60000012 
07-31 15:30:06.360: I/DEBUG(30740):   #00 pc 00017c18 /system/lib/libc.so 
07-31 15:30:06.360: I/DEBUG(30740):   #01 pc 0001edb4 /system/lib/libc.so (__assert2) 
07-31 15:30:06.360: I/DEBUG(30740):   #02 pc 0011ff4c 

任何人可以帮助我这个问题?我试图寻找任何固定的更新日志,但没有想法。 谢谢。

+0

您能否提供崩溃日志? – 2012-07-31 07:20:10

+0

@SaurabhVerma感谢您的回复。我已发布日志。 – cattom2000 2012-07-31 07:43:44

回答

4
Check this line: 07-31 15:30:05.650: A/libc(803): Fatal signal 11 (SIGSEGV) at 0xdeadbaad (code=1) 

trying 

07-31 15:30:06.000: V/AudioHardwareMSM8660(137): AudioStreamOutMSM72xx::write(0x1c918, 4800) dev = speaker_stereo_rx

你有个例外。它不是编译错误,你正在尝试写入音频,但你没有访问。检查文件是否打开,文件是否存在等。

+1

我猜为什么发生这种情况是finish()方法不会终止程序,而是暂停,后来onResume()调用时,mEGLView正在寻找一些资源,但实际上已经由android完成了。所以当你第二次开始你的游戏时,它实际上是在寻找前一个暂停过程,并发现该过程不能再运行,因此系统会将其终止。这解释了为什么第二次运行总是失败,因为只有第三次运行是真正的重新开始。第二次运行只能尝试恢复。 – 2012-08-02 03:29:36

相关问题