我根据源中的测试项目修改了pariticle tests项目。更改Cocos2dxActivity.java文件
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上使用此更改,Activity可以成功运行第二次。但是在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 :(得分: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
你有一个例外。它不是编译错误,您尝试写入音频,但您无法访问。检查文件是否打开,文件是否存在等等。