2012-04-01 12 views
5

Tengo una actividad que contiene un GLSurfaceView. Cuando presiono el botón Atrás para ir a la Actividad anterior, logra mostrar esa Actividad, pero la pantalla no responde y finalmente ANR.GLSurfaceView que causa ANR después de que se destruye la actividad

Aquí es el onSurfaceCreated() Código:

operación -Editar-

Si muevo el mSurfaceView.onPause(); al propietario fragmento de onPause() entonces la aplicación no se congela después de dar marcha atrás en el fragmento, pero generalmente se bloquea silenciosamente (sin forzar el cierre) unos segundos después de retroceder el fragmento.

@Override 
public void onSurfaceCreated(GL10 gl, EGLConfig config) { 
    if (mOpenGlesVersion == OPENGLES_VERSION_10) mOpenGles = new OpenGles10(); 
    else if (mOpenGlesVersion == OPENGLES_VERSION_11) mOpenGles = new OpenGles11(); 
    else if (mOpenGlesVersion == OPENGLES_VERSION_20) mOpenGles = new OpenGles20(); 

    // Let the caller know the surface has been created. 
    if (mListener != null) mListener.onGLSurfaceViewCreated(); 
    // No intention of drawing anything, just gathering info. 
    mSurfaceView.onPause(); 
} 

Esta es la información de registro tomado de /data/anr/traces.txt: (Hay dos líneas que quedó arruinaron debido --More--)

DALVIK THREADS: 
(mutexes: tll=0 tsl=0 tscl=0 ghl=0 hwl=0 hwll=0) 
"main" prio=5 tid=1 WAIT 
| group="main" sCount=1 dsCount=0 obj=0x4001f188 self=0xce60 
| sysTid=22603 nice=0 sched=0/0 cgrp=default handle=-1345006528 
| schedstat=(9586303756 3122772189 8867) 
at java.lang.Object.wait(Native Method) 
- waiting on <0x405b3a70> (a android.opengl.GLSurfaceView$GLThreadManager) 
at java.lang.Object.wait(Object.java:358) 
at android.opengl.GLSurfaceView$GLThread.surfaceDestroyed(GLSurfaceView.java:1446) 
at android.opengl.GLSurfaceView.surfaceDestroyed(GLSurfaceView.java:483) 
at android.view.SurfaceView.reportSurfaceDestroyed(SurfaceView.java:587) 
at android.view.SurfaceView.updateWindow(SurfaceView.java:481) 
at android.view.SurfaceView.onWindowVisibilityChanged(SurfaceView.java:213) 
at android.view.View.dispatchDetachedFromWindow(View.java:6186) 
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1162) 
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1162) 
at android.view.ViewGroup.dispatchDetachedFromWindow(ViewGroup.java:1162) 
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:2201) 
at android.view.ViewGroup.removeViewInternal(ViewGroup.java:2187) 
at android.view.ViewGroup.removeView(ViewGroup.java:2135) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:998) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1080) 
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1062) 
at android.support.v4.app.FragmentManagerImpl.dispatchDestroy(FragmentManager.java:1843) 
at android.support.v4.app.FragmentActivity.onDestroy(FragmentActivity.java:314) 
at android.app.ActivityThread.performDestroyActivity(ActivityThread.java:2780) 
at android.app.ActivityThread.handleDestroyActivity(ActivityThread.java:2811) 
at android.app.ActivityThread.handleRelaunchActivity(ActivityThread.java:2927) 
at android.app.ActivityThread.access$1600(ActivityThread.java:123) 
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943) 
at android.os.Handler.dispatchMessage(Handler.java:99) 
at android.os.Looper.loop(Looper.java:130) 
at android.app.ActivityThread.main(ActivityThread.java:3835) 
at java.lang.reflect.Method.invokeNative(Native Method) 
at java.lang.reflect.Method.invoke(Method.java:507) 
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:847) 
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:605) 
at dalvik.system.NativeStart.main(Native Method) 

"GLThread 15" prio=5 tid=14 WAIT 
| group="main" sCount=1 dsCount=0 obj=0x405634c0 self=0x200700 
| sysTid=22637 nice=0 sched=0/0 cgrp=default handle=2099256 
| schedstat=(52276621 103881831 88) 
at java.lang.Object.wait(Native Method) 
- waiting on <0x405b3a70> (a android.opengl.GLSurfaceView$GLThreadManager) 
at java.lang.Object.wait(Object.java:358) 
at android.opengl.GLSurfaceView$GLThread.onPause(GLSurfaceView.java:1466) 
at android.opengl.GLSurfaceView.onPause(GLSurfaceView.java:501) 
at com.jphilli85.deviceinfo.unit.Graphics.onSurfaceCreated(Graphics.java:237) 
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1348) 
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118) 

"ModernAsyncTask #3" prio=5 tid=13 WAIT 
| group="main" sCount=1 dsCount=0 obj=0x40542210 self=0x1dc970 
| sysTid=22620 nice=10 sched=0/0 cgrp=bg_non_interactive handle=2201640 
| schedstat=(6530762 28076172 5) 
at java.lang.Object.wait(Native Method) 
- waiting on <0x4050bba8> (a java.lang.VMThread) 
at java.lang.Thread.parkFor(Thread.java:1424) 
at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48) 
at sun.misc.Unsafe.park(Unsafe.java:337) 
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157) 
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2016) 
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:411) 
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1021) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581) 
at java.lang.Thread.run(Thread.java:1019) 

"java.lang.ProcessManager" daemon prio=5 tid=12 WAIT 
| group="main" sCount=1 dsCount=0 obj=0x40542680 self=0x17a100 
| sysTid=22614 nice=0 sched=0/0 cgrp=default handle=1968864 
| schedstat=(1342773 5157472 8) 
at java.lang.Object.wait(Native Method) 
- waiting on <0x405424e8> (a java.util.HashMap) 
at java.lang.Object.wait(Object.java:358) 
at java.lang.ProcessManager.onExit(ProcessManager.java:139) 
at java.lang.ProcessManager.watchChildren(Native Method) 
at java.lang.ProcessManager$1.run(ProcessManager.java:85) 

"ModernAsyncTask #2" prio=5 tid=11 WAIT 
| group="main" sCount=1 dsCount=0 obj=0x4050d3d0 self=0x1dc030 
| sysTid=22613 nice=10 sched=0/0 cgrp=bg_non_interactive handle=1948768 
| schedstat=(4455566 78338624 12) 
at java.lang.Object.wait(Native Method) 
- waiting on <0x4050dea8> (a java.lang.VMThread) 
at java.lang.Thread.parkFor(Thread.java:1424) 
at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48) 
at sun.misc.Unsafe.park(Unsafe.java:337) 
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157) 
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2016) 
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:411) 
at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1021) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081) 
581)  .util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java: 
at java.lang.Thread.run(Thread.java:1019) 

"Binder Thread #3" prio=5 tid=10 NATIVE 
| group="main" sCount=1 dsCount=0 obj=0x40539b60 self=0x16cf48 
| sysTid=22612 nice=0 sched=0/0 cgrp=default handle=1494488 
| schedstat=(15869140 35827635 53) 
at dalvik.system.NativeStart.run(Native Method) 

"ModernAsyncTask #1" prio=5 tid=9 WAIT 
| group="main" sCount=1 dsCount=0 obj=0x40529180 self=0x169830 
| sysTid=22611 nice=10 sched=0/0 cgrp=bg_non_interactive handle=1481064 
| schedstat=(10253907 86822509 28) 
at java.lang.Object.wait(Native Method) 
- waiting on <0x40521600> (a java.lang.VMThread) 
at java.lang.Thread.parkFor(Thread.java:1424) 
at java.lang.LangAccessImpl.parkFor(LangAccessImpl.java:48) 
at sun.misc.Unsafe.park(Unsafe.java:337) 
at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157) 
at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2016) 
at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:411) 
1)  .util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:102 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1081) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:581) 
at java.lang.Thread.run(Thread.java:1019) 

"Binder Thread #2" prio=5 tid=8 NATIVE 
| group="main" sCount=1 dsCount=0 obj=0x40514410 self=0x95298 
| sysTid=22610 nice=0 sched=0/0 cgrp=default handle=609832 
| schedstat=(15533441 34057622 53) 
at dalvik.system.NativeStart.run(Native Method) 

"Binder Thread #1" prio=5 tid=7 NATIVE 
| group="main" sCount=1 dsCount=0 obj=0x405129d0 self=0x93c40 
| sysTid=22609 nice=0 sched=0/0 cgrp=default handle=971896 
| schedstat=(16906736 43731688 68) 
at dalvik.system.NativeStart.run(Native Method) 

"Compiler" daemon prio=5 tid=6 VMWAIT 
| group="system" sCount=1 dsCount=0 obj=0x4050e240 self=0x93240 
| sysTid=22608 nice=0 sched=0/0 cgrp=default handle=972152 
| schedstat=(354705825 99243166 2500) 
at dalvik.system.NativeStart.run(Native Method) 

"JDWP" daemon prio=5 tid=5 VMWAIT 
| group="system" sCount=1 dsCount=0 obj=0x4050e190 self=0x92900 
| sysTid=22607 nice=0 sched=0/0 cgrp=default handle=974088 
| schedstat=(3662110 8544920 16) 
at dalvik.system.NativeStart.run(Native Method) 

"Signal Catcher" daemon prio=5 tid=4 RUNNABLE 
| group="system" sCount=0 dsCount=0 obj=0x4050e0d0 self=0xedb78 
| sysTid=22606 nice=0 sched=0/0 cgrp=default handle=972784 
| schedstat=(2044677 305177 6) 
at dalvik.system.NativeStart.run(Native Method) 

"GC" daemon prio=5 tid=3 VMWAIT 
| group="system" sCount=1 dsCount=0 obj=0x4050e028 self=0xed9e0 
| sysTid=22605 nice=0 sched=0/0 cgrp=default handle=526152 
| schedstat=(59478766 61553948 32) 
at dalvik.system.NativeStart.run(Native Method) 

"HeapWorker" daemon prio=5 tid=2 VMWAIT 
| group="system" sCount=1 dsCount=0 obj=0x4050df70 self=0xed878 
| sysTid=22604 nice=0 sched=0/0 cgrp=default handle=965360 
| schedstat=(38177485 36834717 39) 
at dalvik.system.NativeStart.run(Native Method) 

Respuesta

0
"GLThread 15" prio=5 tid=14 WAIT 
| group="main" sCount=1 dsCount=0 obj=0x405634c0 self=0x200700 
| sysTid=22637 nice=0 sched=0/0 cgrp=default handle=2099256 
| schedstat=(52276621 103881831 88) 
at java.lang.Object.wait(Native Method) 
- waiting on <0x405b3a70> (a android.opengl.GLSurfaceView$GLThreadManager) 
at java.lang.Object.wait(Object.java:358) 
at android.opengl.GLSurfaceView$GLThread.onPause(GLSurfaceView.java:1466) 
at android.opengl.GLSurfaceView.onPause(GLSurfaceView.java:501) 
at com.jphilli85.deviceinfo.unit.Graphics.onSurfaceCreated(Graphics.java:237) 
at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1348) 
at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1118) 

Su Graphics.onSurfaceCreated() invocado GLSurfaceView.onPause(). No debe invocar o se encuentra con un bloqueo muerto. onPause() invocará wait() y su surfaceDestroyed() invocará wait().

0

Esto es known bug en GLSurfaceView. Esto se debe a que tiene más de un Live GLSurfaceView en su aplicación. Probé la solución sugerida (consulte el enlace anterior), pero tuve que rediseñar mi aplicación para eliminar manualmente las instancias GLSurfaceView.

Mi truco fue llamar al removeView() en el padre de GLSurfaceView, provocando que se desencadene su evento םnDetachedAFromView().

Esto es menos que óptimo, pero así es la vida.

(B.T.W. una referencia para futuros Googlers: en mi aplicación el culpable era ArcGIS 's MapView).

Cuestiones relacionadas