cocos2d / cocos2d-x

Cocos2d-x is a suite of open-source, cross-platform, game-development tools utilized by millions of developers across the globe. Its core has evolved to serve as the foundation for Cocos Creator 1.x & 2.x.
https://www.cocos.com/en/cocos2d-x
18.21k stars 7.06k forks source link

Random Crash At Launch - cocos2d::RenderState::StateBlock::setBlend(bool) #16414

Open ermanhaskan opened 8 years ago

ermanhaskan commented 8 years ago

Hello

We are getting this very rare crash at launch across many android devices and all android versions. This error has been occurring in all cocos2d-x versions v3.x including the latest one. We tried everything to solve the crash but failed. We can cause the crash by rapidly closing and launching the app, crash occurs randomly.

signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000010

00 pc 00ae0c2c ***/lib/libcocos2dcpp.so (cocos2d::RenderState::StateBlock::setBlend(bool))

01 pc 00aee5dc ***/lib/libcocos2dcpp.so

02 pc 00a9e6d0 ***/lib/libcocos2dcpp.so (cocos2d::Director::setGLDefaultValues()+24)

03 pc 00a9f824 **/lib/libcocos2dcpp.so (cocos2d::Director::setOpenGLView(cocos2d::GLView)+112)

04 pc 009ef22b ***/lib/libcocos2dcpp.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit+230)

00 -> /renderer/CCRenderState.cpp:732 -> _blendEnabled = enabled;

01 -> /renderer/ccGLStateCache.cpp:120 -> RenderState::StateBlock::_defaultState->setBlend(true);

02 -> /base/CCDirector.cpp:682

04 -> /base/CCDirector.cpp:404

Version: cocos2d-x-3.12

The crash is caused by RenderState::StateBlock::_defaultState being nullptr. Other crashes happen if a control for nullptr is added for the crash line.

Do you have any ideas about this problem?

Thanks

minggo commented 8 years ago

@ermanhaskan could you please also paste the java log info? And what's the API level you build with?

ermanhaskan commented 8 years ago

Build fingerprint: 'samsung/j1nlteub/j1nlte:4.4.4/KTU84P/J100MUUBU0APD1:user/release-keys' Revision: '0' pid: 8596, tid: 8615, name: Thread-568 >>> XXX <<< signal 11 (SIGSEGV), code 1 (SEGV_MAPERR), fault addr 00000010

..

backtrace:

00 pc 00ae0c2c /mnt/asec/XXX-1/lib/libcocos2dcpp.so (cocos2d::RenderState::StateBlock::setBlend(bool))

#01  pc 00aee5dc  /mnt/asec/XXX-1/lib/libcocos2dcpp.so
#02  pc 00a9e6d0  /mnt/asec/XXX-1/lib/libcocos2dcpp.so (cocos2d::Director::setGLDefaultValues()+24)
#03  pc 00a9f824  /mnt/asec/XXX-1/lib/libcocos2dcpp.so (cocos2d::Director::setOpenGLView(cocos2d::GLView_)+112)
#04  pc 009ef22b  /mnt/asec/XXX-1/lib/libcocos2dcpp.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit+230)
#05  pc 0001e50c  /system/lib/libdvm.so (dvmPlatformInvoke+112)
#06  pc 00041f27  /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const_, JValue_, Method const_, Thread_)+398)
#07  pc 00043919  /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const_, JValue_, Method const_, Thread_)+184)
#08  pc 0006e920  /system/lib/libdvm.so
#09  pc 0002497c  /system/lib/libdvm.so (dvmMterpStd(Thread_)+76)
#10  pc 00022028  /system/lib/libdvm.so (dvmInterpret(Thread_, Method const_, JValue_)+184)
#11  pc 00051f3b  /system/lib/libdvm.so (dvmCallMethodV(Thread_, Method const_, Object_, bool, JValue_, std::__va_list)+338)
#12  pc 00051f5f  /system/lib/libdvm.so (dvmCallMethod(Thread_, Method const_, Object_, JValue*, ...)+20)
#13  pc 0007f4cb  /system/lib/libdvm.so
#14  pc 0000d220  /system/lib/libc.so (__thread_entry+72)
#15  pc 0000d3bc  /system/lib/libc.so (pthread_create+240)
ermanhaskan commented 8 years ago

compileSdkVersion 24 buildToolsVersion '24.0.0' minSdkVersion 11 targetSdkVersion 24

minggo commented 8 years ago

@ermanhaskan will you please change AndroidMenifest.xml to

android:configChanges="orientation", "screenSize">

to have a try? More information about android:configChanges can be found here.

dumganhar commented 8 years ago

@ermanhaskan , try this:

android:configChanges="orientation|screenSize"
minggo commented 8 years ago

yep, @dumganhar 's version is right

ermanhaskan commented 8 years ago

I was using

android:configChanges="orientation|screenLayout|smallestScreenSize|screenSize|keyboardHidden"

Somehow I can't cause the crash even using old configChanges in my devices right now. I will use your version of configChanges in the last update and post the result here. Thanks.

ermanhaskan commented 8 years ago

Unfortunately we are still experiencing the crash using: android:configChanges="orientation|screenSize"

ermanhaskan commented 8 years ago

Just received this error on cocos2dx 3.13

backtrace:

00 pc 00a41ca8 /data/app-lib/com.test.test-63/libcocos2dcpp.so (cocos2d::RenderState::StateBlock::setBlend(bool))

01 pc 00a4df14 /data/app-lib/com.test.test-63/libcocos2dcpp.so

02 pc 00a0929c /data/app-lib/com.test.test-63/libcocos2dcpp.so (cocos2d::Director::setGLDefaultValues()+12)

03 pc 00a0932c /data/app-lib/com.test.test-63/libcocos2dcpp.so (cocos2d::Director::setOpenGLView(cocos2d::GLView_)+112)

04 pc 009647b1 /data/app-lib/com.test.test-63/libcocos2dcpp.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit+96)

05 pc 0001e80c /system/lib/libdvm.so (dvmPlatformInvoke+112)

06 pc 0004f24b /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const, JValue, Method const, Thread)+398)

07 pc 00050ed9 /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const, JValue, Method const, Thread)+256)

08 pc 00027c20 /system/lib/libdvm.so

09 pc 0002ec5c /system/lib/libdvm.so (dvmMterpStd(Thread_)+76)

10 pc 0002c2c0 /system/lib/libdvm.so (dvmInterpret(Thread, Method const, JValue_)+184)

11 pc 00061759 /system/lib/libdvm.so (dvmCallMethodV(Thread, Method const, Object, bool, JValue, std::__va_list)+336)

12 pc 0006177d /system/lib/libdvm.so (dvmCallMethod(Thread, Method const, Object_, JValue*, ...)+20)

13 pc 0005646b /system/lib/libdvm.so

14 pc 0000d280 /system/lib/libc.so (__thread_entry+72)

15 pc 0000d418 /system/lib/libc.so (pthread_create+240)

dhuang11 commented 8 years ago

We're also seeing the exact same crash in CC2DX 3.11, 3.13 and 3.13.1

minggo commented 8 years ago

@dhuang11 do you have a test case to reproduce it easily? And what's your environments:

more detail information is better.

dhuang11 commented 8 years ago

We are seeing this crash on a number of Android devices. There doesn't appear to be a clear pattern.

We build using NDKr10e and with API version 23.

In house, we are able to reproduce this fairly easily on an Amazon Kindle Fire HDX. If we launch the app and close it a few times.

minggo commented 8 years ago

@dhuang11 did it also crash at cocos2d::RenderState::StateBlock::setBlend()?

dhuang11 commented 8 years ago

Yes exact same stack trace - cocos2d::RenderState::StateBlock::setBlend() crash with the same call stack prior to that crash

dhuang11 commented 8 years ago

Our game is linked to Crashlytics - here is a shared link to this crash: http://crashes.to/s/5d886e5ff64

It is our #1 crash according to Crashlytics and it is happening a larger proportion on Amazon kindle devices

minggo commented 8 years ago

Will you please use stand NDK toolchain to have a try?

dhuang11 commented 8 years ago

I/DEBUG ( 259):
I/DEBUG ( 259): Build fingerprint: 'Amazon/thor/thor:4.4.3/KTU84M/13.4.5.5_user_455004220:user/release-keys' I/DEBUG ( 259): Revision: '0' I/DEBUG ( 259): pid: 24581, tid: 24650, name: Thread-407 >>> com.boqugames.poker <<< I/DEBUG ( 259): signal 11 (SIGSEGV), code 1 (SEGVMAPERR), fault addr 00000024 I/DEBUG ( 259): r0 00000000 r1 00000001 r2 00000001 r3 00110e31 I/DEBUG ( 259): r4 64186600 r5 00000303 r6 00000001 r7 62b47f30 I/DEBUG ( 259): r8 64588ad8 r9 62b47f28 sl 6261ca78 fp 64588aec I/DEBUG ( 259): ip 00000080 sp 64588a58 lr 63e0cfd3 pc 63e06a5c cpsr 200d0030 I/DEBUG ( 259): d0 0000000000000000 d1 0000000000000000 I/DEBUG ( 259): d2 645f64656b636170 d3 6574735f68747065 I/DEBUG ( 259): d4 4037000000000000 d5 4026000000000000 I/DEBUG ( 259): d6 4037000000000000 d7 0000001700000000 I/DEBUG ( 259): d8 00000780000004b0 d9 0000000000000000 I/DEBUG ( 259): d10 0000000000000000 d11 0000000000000000 I/DEBUG ( 259): d12 0000000000000000 d13 0000000000000000 I/DEBUG ( 259): d14 0000000000000000 d15 0000000000000000 I/DEBUG ( 259): d16 705f53454f5f4c47 d17 65645f64656b6361 I/DEBUG ( 259): d18 5f726f6c6f635f54 d19 665f726566667562 I/DEBUG ( 259): d20 5f4c472074616f6c d21 6f6c6f635f545845 I/DEBUG ( 259): d22 7265666675625f72 d23 6c665f666c61685f I/DEBUG ( 259): d24 ff0082f014000000 d25 ff007bf013960000 I/DEBUG ( 259): d26 ff00821f154a0000 d27 ff007ce413000000 I/DEBUG ( 259): d28 ff0080a015e00000 d29 ff007fc013000000 I/DEBUG ( 259): d30 0000000000000000 d31 0000000000000000 I/DEBUG ( 259): scr 60000012 I/DEBUG ( 259): I/DEBUG ( 259): backtrace: I/DEBUG ( 259): #00 pc 005b0a5c /data/app-lib/com.boqugames.poker-1/libpoker.so (cocos2d::RenderState::StateBlock::invalidate(long)+19) I/DEBUG ( 259): #01 pc 005b6fcf /data/app-lib/com.boqugames.poker-1/libpoker.so I/DEBUG ( 259): #02 pc 00598873 /data/app-lib/com.boqugames.poker-1/libpoker.so (cocos2d::Director::setGLDefaultValues()+6) I/DEBUG ( 259): #03 pc 005988d9 /data/app-lib/com.boqugames.poker-1/libpoker.so (cocos2d::Director::setOpenGLView(cocos2d::GLView)+76) I/DEBUG ( 259): #04 pc 0049a83b /data/app-lib/com.boqugames.poker-1/libpoker.so (Java_org_cocos2dx_lib_Cocos2dxRenderernativeInit+86) I/DEBUG ( 259): #05 pc 0002068c /system/lib/libdvm.so (dvmPlatformInvoke+112) I/DEBUG ( 259): #06 pc 000524d1 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const, JValue, Method const, Thread)+412) I/DEBUG ( 259): #07 pc 00054263 /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const, JValue, Method const, Thread)+226) I/DEBUG ( 259): #08 pc 00029b20 /system/lib/libdvm.so I/DEBUG ( 259): #09 pc 00030fb8 /system/lib/libdvm.so (dvmMterpStd(Thread)+76) I/DEBUG ( 259): #10 pc 0002e5fc /system/lib/libdvm.so (dvmInterpret(Thread, Method const, JValue_)+184) I/DEBUG ( 259): #11 pc 00065999 /system/lib/libdvm.so (dvmCallMethodV(Thread, Method const, Object, bool, JValue, std::__va_list)+336) I/DEBUG ( 259): #12 pc 000659bd /system/lib/libdvm.so (dvmCallMethod(Thread, Method const, Object, JValue, ...)+20) I/DEBUG ( 259): #13 pc 00059c8f /system/lib/libdvm.so I/DEBUG ( 259): #14 pc 0000d260 /system/lib/libc.so (__thread_entry+72) I/DEBUG ( 259): #15 pc 0000d3f8 /system/lib/libc.so (pthread_create+240) I/DEBUG ( 259): I/DEBUG ( 259): stack: I/DEBUG ( 259): 64588a18 00000001
I/DEBUG ( 259): 64588a1c 00000001
I/DEBUG ( 259): 64588a20 62b47f30
I/DEBUG ( 259): 64588a24 64588ad8 [stack:24650] I/DEBUG ( 259): 64588a28 62b47f28
I/DEBUG ( 259): 64588a2c 6261ca78
I/DEBUG ( 259): 64588a30 64588aec [stack:24650] I/DEBUG ( 259): 64588a34 5fdb93d7 /system/vendor/lib/egl/libGLESv2_adreno.so (core_glBlendFunc+10) I/DEBUG ( 259): 64588a38 00000007
I/DEBUG ( 259): 64588a3c 00000001
I/DEBUG ( 259): 64588a40 00000303
I/DEBUG ( 259): 64588a44 5fd98b83 /system/vendor/lib/egl/libGLESv2adreno.so (glBlendFunc+22) I/DEBUG ( 259): 64588a48 00110e31
I/DEBUG ( 259): 64588a4c 64186600
I/DEBUG ( 259): 64588a50 df0027ad
I/DEBUG ( 259): 64588a54 00000000
I/DEBUG ( 259): #00 64588a58 65a28cd0
I/DEBUG ( 259): ........ ........ I/DEBUG ( 259): #01 64588a58 65a28cd0
I/DEBUG ( 259): 64588a5c 65bdef70
I/DEBUG ( 259): 64588a60 65bdef70
I/DEBUG ( 259): 64588a64 63dee877 /data/app-lib/com.boqugames.poker-1/libpoker.so (cocos2d::Director::setGLDefaultValues()+10) I/DEBUG ( 259): #02 64588a68 65a28cd0
I/DEBUG ( 259): 64588a6c 63dee8dd /data/app-lib/com.boqugames.poker-1/libpoker.so (cocos2d::Director::setOpenGLView(cocos2d::GLView
)+80)

nbtthief commented 7 years ago

@dhuang11 @ermanhaskan hi there, did you solve this bug?? it look like i'm encoutering the same bug as you two

ermanhaskan commented 7 years ago

@nbtthief I found no solutions to this problem :/

hgwzyyx commented 7 years ago

also happen in 3.9

hgwzyyx commented 7 years ago

00 pc 00738c68 libcocos2dlua.so setBlend (F:\GameStudio\Client\frameworks\runtime-src\proj.android../../cocos2d-x/cocos//./renderer/CCRenderState.cpp:731-732) [armeabi-v5te]

2 #1 pc 007408f1 libcocos2dlua.so SetBlending (F:\GameStudio\Client\frameworks\runtime-src\proj.android../../cocos2d-x/cocos//./renderer/ccGLStateCache.cpp:120) [armeabi-v5te] 3 #2 pc 007409ab libcocos2dlua.so blendFunc (F:\GameStudio\Client\frameworks\runtime-src\proj.android../../cocos2d-x/cocos//./renderer/ccGLStateCache.cpp:133) [armeabi-v5te] 4 #3 pc 0071e0a7 libcocos2dlua.so setAlphaBlending (F:\GameStudio\Client\frameworks\runtime-src\proj.android../../cocos2d-x/cocos//./base/CCDirector.cpp:703) [armeabi-v5te] 5 #4 pc 0071ed07 libcocos2dlua.so setGLDefaultValues (F:\GameStudio\Client\frameworks\runtime-src\proj.android../../cocos2d-x/cocos//./base/CCDirector.cpp:256) [armeabi-v5te] 6 #5 pc 0071ed6f libcocos2dlua.so setOpenGLView (F:\GameStudio\Client\frameworks\runtime-src\proj.android../../cocos2d-x/cocos//./base/CCDirector.cpp:396) [armeabi-v5te] 7 #6 pc 004e8469 libcocos2dlua.so Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeInit (F:\GameStudio\Client\frameworks\runtime-src\proj.android../../cocos2d-x/cocos//platform/android/javaactivity-android.cpp:70) [armeabi-v5te] 8 #7 pc 000204cc /system/lib/libdvm.so (dvmPlatformInvoke+112) [armeabi-v7a] 9 #8 pc 00051157 /system/lib/libdvm.so (dvmCallJNIMethod(unsigned int const, JValue, Method const, Thread)+398) [armeabi-v7a] 10 #9 pc 00052b41 /system/lib/libdvm.so (dvmResolveNativeMethod(unsigned int const, JValue, Method const, Thread)+184) [armeabi-v7a] 11 #10 pc 00029960 /system/lib/libdvm.so [armeabi-v7a] 12 #11 pc 00030dec /system/lib/libdvm.so (dvmMterpStd(Thread)+76) [armeabi-v7a] 13 #12 pc 0002e484 /system/lib/libdvm.so (dvmInterpret(Thread, Method const, JValue)+184) [armeabi-v7a] 14 #13 pc 000635b9 /system/lib/libdvm.so (dvmCallMethodV(Thread, Method const, Object, bool, JValue, std::__va_list)+336) [armeabi-v7a] 15 #14 pc 000635dd /system/lib/libdvm.so (dvmCallMethod(Thread, Method const, Object, JValue, ...)+20) [armeabi-v7a] 16 #15 pc 000582bb /system/lib/libdvm.so [armeabi-v7a] 17 #16 pc 0000d2d0 /system/lib/libc.so (__thread_entry+72) [armeabi-v7a] 18 #17 pc 0000d468 /system/lib/libc.so (pthread_create+240) [armeabi-v7a] 19 java: 20 org.cocos2dx.lib.Cocos2dxRenderer.nativeInit(Native Method) 21 org.cocos2dx.lib.Cocos2dxRenderer.onSurfaceCreated(Cocos2dxRenderer.java:72) 22 android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1501) 23 android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1240)

Guy-kun commented 7 years ago

Has anyone had any more progress on this or has anyone found a cause? This issue is affecting an in-production app quite badly (1000 crashes+ per day) but no developer can reproduce it. The stack trace is the same as reported above

screen shot 2017-03-12 at 01 21 34

There seems to be no pattern to devices affected either except that they typically are in a low free-Ram state

screen shot 2017-03-12 at 01 22 49

I'll keep trying to hunt down a reproducible device but on a Google Pixel aggressively restarting/foregrounding the app does not cause any similar issues.

Guy-kun commented 7 years ago

Still looking for any further information on this or if anyone found a cause... Still #1 crash bug for an app in production together with variants of this and setBlend()

umair6 commented 6 years ago

I am also facing this issue in my game.

Obg1 commented 3 years ago

Any fix for this? Getting this on 3.16

bolso80 commented 2 years ago

@ermanhaskan @Guy-kun @hgwzyyx were you able to fix this problem?

Thanks