首页 > 代码库 > cocos2d-x3.0开发游戏部分机型(显卡类型)闪退问题

cocos2d-x3.0开发游戏部分机型(显卡类型)闪退问题

拓展cocos2d-x3.0底层支持etc图片格式,把游戏中的模型使用etc格式的图片替换。

原先可以运行在联想(lenovo S880,显卡类型是PowerVP SGX 531)的机器上,但是换成etc图片之后进入游戏加载模型的时候就闪退了。
目前大部分其他机型上都没不存在这个问题,只有部分机器会闪退。初步判断有可能是显卡的问题,这个机器的显卡类型是PowerVR SGX 531。不知道各位大大有遇到相同或类似的问题没?

贴上eclipse DDMS上的报错信息:

12-20 15:11:48.559: A/libc(2909): Fatal signal 11 (SIGSEGV) at 0x53f47000 (code=1)
12-20 15:11:48.992: D/NetworkControllerGemini(309): updateTelephonySignalStrength(0) mOldSignalLevel = 4, msg.arg1 = 4, mSignalLevelMsg = true
12-20 15:11:48.993: D/NetworkControllerGemini(309): isSimInserted(0), SimInserted=true
12-20 15:11:48.993: D/NetworkControllerGemini(309): updateSignalBackgroundBySlotId(0), simInserted=true
12-20 15:11:48.993: D/NetworkControllerGemini(309): isSimInserted(0), SimInserted=true
12-20 15:11:48.994: D/NetworkControllerGemini(309): isSimInserted(1), SimInserted=true
12-20 15:11:48.994: D/NetworkControllerGemini(309): updateOperatorInfo, sim1Inserted is true, sim2Inserted is true.
12-20 15:11:48.994: D/NetworkControllerGemini(309): updateSignalBackgroundBySlotId(0), MobileVisible=true, ResId=2130837922
12-20 15:11:48.994: D/NetworkControllerGemini(309): refreshViews(0), DataConnected=true
12-20 15:11:48.994: D/NetworkControllerGemini(309): refreshViews(0), mMobileActivityIconId=2130837889, mMobileActivityIconIdGemini=-1
12-20 15:11:48.994: D/SignalClusterViewGemini(309): setDataConnected(0), dataConnected=true
12-20 15:11:48.994: D/SignalClusterViewGemini(309): apply, mMobileVisible=true mMobileActivityId=2130837889 mMobileTypeId=2130837775
12-20 15:11:48.994: D/SignalClusterViewGemini(309): isSimInserted(0), SimInserted=true
12-20 15:11:48.995: D/SignalClusterViewGemini(309): apply, mSIMBackground=2130837922
12-20 15:11:48.995: D/SignalClusterViewGemini(309): apply, mMobileVisibleGemini=true mMobileActivityIdGemini=0 mMobileTypeIdGemini=0
12-20 15:11:48.996: D/SignalClusterViewGemini(309): isSimInserted(1), SimInserted=true
12-20 15:11:48.996: D/SignalClusterViewGemini(309): apply, mSIMBackgroundGemini=2130837924
12-20 15:11:48.996: D/SignalClusterViewGemini(309): apply, mDataConnected=true mMobileActivityId=2130837889 mMobileTypeId=2130837775; mDataConnectedGemini=false mMobileActivityIdGemini=0 mMobileTypeIdGemini=0
12-20 15:11:48.996: D/SignalClusterViewGemini(309): setDataNetType3G(0), dataNetType3G=true
12-20 15:11:48.996: D/SignalClusterViewGemini(309): apply, mMobileVisible=true mMobileActivityId=2130837889 mMobileTypeId=2130837775
12-20 15:11:48.997: D/SignalClusterViewGemini(309): isSimInserted(0), SimInserted=true
12-20 15:11:48.997: D/SignalClusterViewGemini(309): apply, mSIMBackground=2130837922
12-20 15:11:48.997: D/SignalClusterViewGemini(309): apply, mMobileVisibleGemini=true mMobileActivityIdGemini=0 mMobileTypeIdGemini=0
12-20 15:11:48.998: D/SignalClusterViewGemini(309): isSimInserted(1), SimInserted=true
12-20 15:11:48.998: D/SignalClusterViewGemini(309): apply, mSIMBackgroundGemini=2130837924
12-20 15:11:48.998: D/SignalClusterViewGemini(309): apply, mDataConnected=true mMobileActivityId=2130837889 mMobileTypeId=2130837775; mDataConnectedGemini=false mMobileActivityIdGemini=0 mMobileTypeIdGemini=0
12-20 15:11:48.998: D/NetworkControllerGemini(309): updateTelephonySignalStrength(0) checkNeedtoSmoothSignal(real_asu = 25, new_asu = 25 )
12-20 15:11:49.164: I/DEBUG(92): debuggerd: tmb file path:‘/data/tombstones/tombstone_03‘
12-20 15:11:49.164: I/DEBUG(92): *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***
12-20 15:11:49.164: I/DEBUG(92): Build fingerprint: ‘Lenovo/s880/s880:4.0.3/IML74K/Lenovo_S880_S140_120721:user/release-keys‘
12-20 15:11:49.164: I/DEBUG(92): pid: 2909, tid: 2929  >>> com.test <<<
12-20 15:11:49.164: I/DEBUG(92): signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 53f47000
12-20 15:11:49.165: I/DEBUG(92):  r0 5a1ee720  r1 53f46ff8  r2 000000c0  r3 00000000
12-20 15:11:49.165: I/DEBUG(92):  r4 00000000  r5 00000000  r6 00000000  r7 00000000
12-20 15:11:49.165: I/DEBUG(92):  r8 00000000  r9 000697d0  10 5a1f0700  fp 00000008
12-20 15:11:49.165: I/DEBUG(92):  ip 00000000  sp 520cf734  lr 00000007  pc 400d4ce8  cpsr 20000010
12-20 15:11:49.287: I/DEBUG(92):          #00  pc 0000dce8  /system/lib/libc.so
12-20 15:11:49.287: D/AEE/debuggerd(92): stack_depth:1
12-20 15:11:49.287: I/DEBUG(92):          #01  lr 00000007  <unknown>
12-20 15:11:49.287: I/DEBUG(92): code around pc:
12-20 15:11:49.288: I/DEBUG(92): 400d4cc8 24d15001 44c03001 24c04001 24c05001  .P.$.0.D.@.$.P.$
12-20 15:11:49.288: I/DEBUG(92): 400d4cd8 e2522020 ba000005 f5d1f060 f5d1f080    R.....`.......
12-20 15:11:49.288: I/DEBUG(92): 400d4ce8 e8b151f8 e2522020 e8a051f8 aafffffa  .Q..  R..Q......
12-20 15:11:49.288: I/DEBUG(92): 400d4cf8 e2922020 0a00000c e1b0ce02 28b10078    ..........x..(
12-20 15:11:49.288: I/DEBUG(92): 400d4d08 48b10180 28a00078 48a00180 e1b0cf02  ...Hx..(...H....
12-20 15:11:49.288: I/DEBUG(92): code around lr:
12-20 15:11:49.288: I/DEBUG(92): 00000000 ffffffff ffffffff ffffffff ffffffff  ................
12-20 15:11:49.288: I/DEBUG(92): 00000010 ffffffff ffffffff ffffffff ffffffff  ................
12-20 15:11:49.288: I/DEBUG(92): 00000020 ffffffff ffffffff ffffffff ffffffff  ................
12-20 15:11:49.288: I/DEBUG(92): 00000030 ffffffff ffffffff ffffffff ffffffff  ................
12-20 15:11:49.288: I/DEBUG(92): 00000040 ffffffff ffffffff ffffffff ffffffff  ................
12-20 15:11:49.288: I/DEBUG(92): memory map around addr 53f47000:
12-20 15:11:49.288: I/DEBUG(92): 53edd000-53f47000 
12-20 15:11:49.288: I/DEBUG(92): (no map for address)
12-20 15:11:49.288: I/DEBUG(92): 53f73000-53f74000 /dev/pvrsrvkm
12-20 15:11:49.288: I/DEBUG(92): stack:
12-20 15:11:49.288: I/DEBUG(92):     520cf6f4  00000000  
12-20 15:11:49.288: I/DEBUG(92):     520cf6f8  00000000  
12-20 15:11:49.288: I/DEBUG(92):     520cf6fc  00000000  
12-20 15:11:49.288: I/DEBUG(92):     520cf700  00000000  
12-20 15:11:49.288: I/DEBUG(92):     520cf704  00000008  
12-20 15:11:49.288: I/DEBUG(92):     520cf708  00000000  
12-20 15:11:49.288: I/DEBUG(92):     520cf70c  00000000  
12-20 15:11:49.289: I/DEBUG(92):     520cf710  00000000  
12-20 15:11:49.289: I/DEBUG(92):     520cf714  00000000  
12-20 15:11:49.289: I/DEBUG(92):     520cf718  00000000  
12-20 15:11:49.289: I/DEBUG(92):     520cf71c  00000000  
12-20 15:11:49.289: I/DEBUG(92):     520cf720  00000000  
12-20 15:11:49.289: I/DEBUG(92):     520cf724  00000000  
12-20 15:11:49.289: I/DEBUG(92):     520cf728  df0027ad  
12-20 15:11:49.289: I/DEBUG(92):     520cf72c  00000000  
12-20 15:11:49.289: I/DEBUG(92):     520cf730  020a8108  [heap]
12-20 15:11:49.289: I/DEBUG(92): #00 520cf734  53f470d8  
12-20 15:11:49.289: I/DEBUG(92):     520cf738  00000100  
12-20 15:11:49.289: I/DEBUG(92):     520cf73c  00000009  
12-20 15:11:49.289: I/DEBUG(92):     520cf740  020a8108  [heap]
12-20 15:11:49.289: I/DEBUG(92):     520cf744  53edd008  
12-20 15:11:49.289: I/DEBUG(92):     520cf748  5a1ee700  /dev/pvrsrvkm
12-20 15:11:49.289: I/DEBUG(92):     520cf74c  4ccafff4  /system/vendor/lib/egl/libGLESv2_mtk.so
12-20 15:11:49.289: I/DEBUG(92):     520cf750  00000000  
12-20 15:11:49.289: I/DEBUG(92):     520cf754  00000000  
12-20 15:11:49.289: I/DEBUG(92):     520cf758  00000000  
12-20 15:11:49.289: I/DEBUG(92):     520cf75c  00000000  
12-20 15:11:49.289: I/DEBUG(92):     520cf760  520cf7bc  
12-20 15:11:49.290: I/DEBUG(92):     520cf764  00000000  
12-20 15:11:49.290: I/DEBUG(92):     520cf768  00000000  
12-20 15:11:49.290: I/DEBUG(92):     520cf76c  5a1de700  /dev/pvrsrvkm
12-20 15:11:49.290: I/DEBUG(92):     520cf770  00000000  
12-20 15:11:49.290: I/DEBUG(92):     520cf774  00000000  
12-20 15:11:49.290: I/DEBUG(92):     520cf778  00000037  
12-20 15:11:49.445: D/AEE/debuggerd(92): stack_depth:19


总结出可能导致游戏闪退的原因:
1.资源没有优化好,导致占用太多内存,被系统强制退出;
2.资源太大撑爆显存导致闪退;
3.图片太大(一些低端的机型显卡只支持最大图片大小是1024,那么这个时候就要注意了);
4.图片不是2的幂次方,有些显卡是不支持非2的幂次方的图片(这次闪退的原因就是因为使用etc材质,显卡不支持etc图片非2的幂次方导致,但是支持png为非2的幂次方,所以找了好久才发现这个问题)。
附上我在cocosChina上面的提问链接

cocos2d-x3.0开发游戏部分机型(显卡类型)闪退问题