"main" prio=5 tid=1 Waiting
| group="main" sCount=1 dsCount=0 obj=0x74bac9f0 self=0x7f9f495a00
| sysTid=7229 nice=-10 cgrp=default sched=0/0 handle=0x7fa3418a98
| state=S schedstat=( 50933440364 30495228271 158001 ) utm=3921 stm=1172 core=0 HZ=100
| stack=0x7fcdf93000-0x7fcdf95000 stackSize=8MB
| held mutexes=
at java.lang.Object.wait!(Native method)
- waiting on <0x08c9bc2d> (a android.opengl.GLSurfaceView$GLThreadManager)
at android.opengl.GLSurfaceView$GLThread.onWindowResize(GLSurfaceView.java:1760)
- locked <0x08c9bc2d> (a android.opengl.GLSurfaceView$GLThreadManager)
at android.opengl.GLSurfaceView.surfaceChanged(GLSurfaceView.java:541)
at android.view.SurfaceView.updateWindow(SurfaceView.java:644)
at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:251)
at android.view.View.dispatchWindowVisibilityChanged(View.java:10433)
at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290)
at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290)
at android.view.ViewGroup.dispatchWindowVisibilityChanged(ViewGroup.java:1290)
"GLThread 181" prio=5 tid=44 Native
| group="main" sCount=1 dsCount=0 obj=0x12c050e0 self=0x7f83d82c00
| sysTid=7314 nice=0 cgrp=default sched=0/0 handle=0x7f762d7450
| state=R schedstat=( 2440190265470 119960740831 1278433 ) utm=224211 stm=19808 core=1 HZ=100
| stack=0x7f761d5000-0x7f761d7000 stackSize=1037KB
| held mutexes=
kernel: __switch_to+0x70/0x7c
kernel: 0xffffffc0ad5e94fc
native: #00 pc 000000000018dbc4 /system/vendor/lib64/egl/libGLESv2_adreno.so (_ZN15EsxRenderBucket16EmptyBufDescListEP13EsxLinkedListi+100)
native: #01 pc 000000000018f660 /system/vendor/lib64/egl/libGLESv2_adreno.so (_ZN15EsxRenderBucket5ResetEv+352)
native: #02 pc 00000000001acdec /system/vendor/lib64/egl/libGLESv2_adreno.so (_ZN10EsxContext15ResetBucketInfoEv+108)
native: #03 pc 00000000001d82a4 /system/vendor/lib64/egl/libGLESv2_adreno.so (_ZN9EsxCmdMgr5FlushE14EsxFlushReason+612)
native: #04 pc 00000000001ad608 /system/vendor/lib64/egl/libGLESv2_adreno.so (_ZN10EsxContext21BucketProcessingSetupEv+488)
native: #05 pc 0000000000135ca8 /system/vendor/lib64/egl/libGLESv2_adreno.so (_ZN10EsxContext16ValidateGfxStateEPK17EsxDrawDescriptor+872)
native: #06 pc 00000000001286bc /system/vendor/lib64/egl/libGLESv2_adreno.so (_ZN10EsxContext21DrawElementsInstancedE11EsxPrimTypej10EsxPixTypePKvji+444)
native: #07 pc 00000000000fcea4 /system/vendor/lib64/egl/libGLESv2_adreno.so (glDrawElements+68)
native: #08 pc 0000000000ae3d58 /data/app/com.ihuman.imath-1/lib/arm64/libcocos2dlua.so (???)
native: #09 pc 0000000000ae3eb8 /data/app/com.ihuman.imath-1/lib/arm64/libcocos2dlua.so (???)
native: #10 pc 0000000000ae3f08 /data/app/com.ihuman.imath-1/lib/arm64/libcocos2dlua.so (???)
native: #11 pc 0000000000ae3f28 /data/app/com.ihuman.imath-1/lib/arm64/libcocos2dlua.so (???)
native: #12 pc 0000000000ae4184 /data/app/com.ihuman.imath-1/lib/arm64/libcocos2dlua.so (???)
native: #13 pc 0000000000ae44a4 /data/app/com.ihuman.imath-1/lib/arm64/libcocos2dlua.so (???)
native: #14 pc 0000000000ae44a4 /data/app/com.ihuman.imath-1/lib/arm64/libcocos2dlua.so (???)
native: #15 pc 0000000000ae6110 /data/app/com.ihuman.imath-1/lib/arm64/libcocos2dlua.so (???)
native: #16 pc 0000000000a6c03c /data/app/com.ihuman.imath-1/lib/arm64/libcocos2dlua.so (???)
native: #17 pc 0000000000ab2354 /data/app/com.ihuman.imath-1/lib/arm64/libcocos2dlua.so (???)
native: #18 pc 0000000000ab2478 /data/app/com.ihuman.imath-1/lib/arm64/libcocos2dlua.so (???)
native: #19 pc 000000000039009c /data/app/com.ihuman.imath-1/lib/arm64/libcocos2dlua.so (Java_org_cocos2dx_lib_Cocos2dxRenderer_nativeRender+20)
native: #20 pc 00000000000dbb10 /system/lib64/libart.so (art_quick_generic_jni_trampoline+144)
native: #21 pc 0000000000027778 /dev/ashmem/dalvik-jit-code-cache (deleted) (???)
at org.cocos2dx.lib.Cocos2dxRenderer.nativeRender(Native method)
at org.cocos2dx.lib.Cocos2dxRenderer.onDrawFrame(SourceFile:-1)
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1548)
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1259)
当应用从后台返回前台,GL线程正在调用glDrawElements进行渲染,此时主线程调用surfaceChanged通知窗口大小发生改变(旋转或者大小发生变动)。
//当窗口发生变化的时候,主线程回调surfaceChanged,进而调用onWindowResize方法,在onWindowResize方法中
//等待sGLThreadManager释放,也就是说sGLThreadManager如果此时没有释放的话,主线程会阻塞
public void surfaceChanged(SurfaceHolder holder, int format, int w, int h) {
mGLThread.onWindowResize(w, h);
}
public void onWindowResize(int w, int h) {
//阻塞式锁
synchronized (sGLThreadManager) {
...
}
}
而GL线程此时在执行glDrawElements,这个方法执行过程中可能在等待主线程执行某个操作
但是此时主线程正在阻塞无法执行任何代码
####主线程阻塞等待GL线程空闲,GL线程需要在主线程执行一些操作,但是主线程阻塞而无法执行导致无法进行下去。