title: ANR TextureView on Galaxy S2 (GPU driver issue?)
body: <p>I have multiple TextureView inside a ListView that plays an opengl video stream. The code works fine on Nexus 4 (4.2), Galaxy S3 (4.1), and HTC One (4.0.3). However, ANR happens when I try to scroll the listview on S2 (SPH-D710VMUB, Virgin Mobile, 4.0.4) when opengl threads are running (deadlock). The ANR trace is provided below (isHardwareAccelerated() = true on listview).</p>
  
  <p>Also note that if GLSurfaceView is used to handle the same openGL code, it works fine, but the Z-order messes up with multiple SurfaceViews in the same window for ICS devices. The GLTextureView is converted via instructions <a href="https://stackoverflow.com/questions/12061419/converting-from-glsurfaceview-to-textureview-via-gltextureview">Converting from GLSurfaceView to TextureView (via GLTextureView)</a> </p>
  
  <p>EDIT 1: Tried another implementation of GLTextureView, was able to locate the exact line.
  "eglSwapBuffers(EGLDisplay display, EGLSurface surface);" will block on S2 for some reason.</p>
  
  <p>Someone noticed: <a href="http://vec.io/posts/a-workaround-to-fix-opengl-eglswapbuffers-freezing" rel="nofollow noreferrer">http://vec.io/posts/a-workaround-to-fix-opengl-eglswapbuffers-freezing</a> 
  glFinish(); is needed. Any idea? </p>
  
  <p>EDIT 2: Adding glFinish() or eglWaitGL() does not help. :( Suspect that they return immediately regardless....</p>
  
  <p>EDIT 3: To reproduce it using <a href="https://github.com/eaglesakura/gltextureview" rel="nofollow noreferrer">https://github.com/eaglesakura/gltextureview</a>: 
  See <a href="https://github.com/eaglesakura/gltextureview/issues/1" rel="nofollow noreferrer">https://github.com/eaglesakura/gltextureview/issues/1</a></p>
  
  <p>EDIT 4: In case anyone is wondering, this is my implementation of the GLTextureView (<a href="https://github.com/edisonw/jjmpeg/tree/jjmpeg-1.0-dev/jjmpeg-android/src/com/edisonwang/android/player" rel="nofollow noreferrer">https://github.com/edisonw/jjmpeg/tree/jjmpeg-1.0-dev/jjmpeg-android/src/com/edisonwang/android/player</a>) It also includes FFMpeg playback stuff.  </p>
  
  <p>EDIT 5: It turns out to be a possible Qualcomm Adreno 200 series bug: <a href="https://developer.qualcomm.com/forum/qdevnet-forums/mobile-gaming-graphics-optimization-adreno/11525" rel="nofollow noreferrer">https://developer.qualcomm.com/forum/qdevnet-forums/mobile-gaming-graphics-optimization-adreno/11525</a> </p>
  
  <pre><code>        DALVIK THREADS:
          (mutexes: tll=0 tsl=0 tscl=0 ghl=0)
          "main" prio=5 tid=1 NATIVE
            | group="main" sCount=1 dsCount=0 obj=0x40c30460 self=0x129c0
            | sysTid=21854 nice=0 sched=0/0 cgrp=default handle=1074746664
            | schedstat=( 434522015 268952863 603 ) utm=34 stm=9 core=0
            at android.view.GLES20Canvas.nUpdateTextureLayer(Native Method)
            at android.view.GLES20TextureLayer.update(GLES20TextureLayer.java:77)
            at android.view.TextureView.applyUpdate(TextureView.java:388)
            at android.view.TextureView.draw(TextureView.java:276)
            at android.view.View.getDisplayList(View.java:10586)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2597)
            at android.view.View.getDisplayList(View.java:10549)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2597)
            at android.view.View.getDisplayList(View.java:10549)
            at android.view.ViewGroup.drawChild(ViewGroup.java:2850)
            at android.widget.ListView.drawChild(ListView.java:3225)
            at android.view.ViewGroup.dispatchDraw(ViewGroup.java:2489)
            at android.widget.AbsListView.dispatchDraw(AbsListView.java:2271)
            at android.widget.ListView.dispatchDraw(ListView.java:3220)
            at android.view.View.draw(View.java:11150)
            at android.widget.AbsListView.draw(AbsListView.java:3728)
            at android.view.View.getDisplayList(View.java:10586)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2597)
            at android.view.View.getDisplayList(View.java:10549)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2597)
            at android.view.View.getDisplayList(View.java:10549)
            at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:2597)
            at android.view.View.getDisplayList(View.java:10549)
            at android.view.HardwareRenderer$GlRenderer.draw(HardwareRenderer.java:842)
            at android.view.ViewRootImpl.draw(ViewRootImpl.java:2011)
            at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1735)
            at android.view.ViewRootImpl.handleMessage(ViewRootImpl.java:2547)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:4507)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:511)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:978)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:745)
            at dalvik.system.NativeStart.main(Native Method)
  
  
      "AsyncTask #2" prio=5 tid=19 WAIT
        | group="main" sCount=1 dsCount=0 obj=0x415cdf00 self=0x3aa178
        | sysTid=8059 nice=10 sched=0/0 cgrp=bg_non_interactive handle=4722816
        | schedstat=( 369083 125724959 3 ) utm=0 stm=0 core=0
        at java.lang.Object.wait(Native Method)
        - waiting on &lt;0x415ce020&gt; (a java.lang.VMThread) held by tid=19 (AsyncTask #2)
        at java.lang.Thread.parkFor(Thread.java:1231)
        at sun.misc.Unsafe.park(Unsafe.java:323)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
        at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
        at java.lang.Thread.run(Thread.java:856)
  
  
      "AsyncTask #1" prio=5 tid=13 WAIT
        | group="main" sCount=1 dsCount=0 obj=0x415ca7d8 self=0x30c370
        | sysTid=8050 nice=10 sched=0/0 cgrp=bg_non_interactive handle=3105360
        | schedstat=( 448085 5989790 7 ) utm=0 stm=0 core=1
        at java.lang.Object.wait(Native Method)
        - waiting on &lt;0x415ca970&gt; (a java.lang.VMThread) held by tid=13 (AsyncTask #1)
        at java.lang.Thread.parkFor(Thread.java:1231)
        at sun.misc.Unsafe.park(Unsafe.java:323)
        at java.util.concurrent.locks.LockSupport.park(LockSupport.java:157)
        at java.util.concurrent.locks.AbstractQueuedSynchronizer$ConditionObject.await(AbstractQueuedSynchronizer.java:2022)
        at java.util.concurrent.LinkedBlockingQueue.take(LinkedBlockingQueue.java:413)
        at java.util.concurrent.ThreadPoolExecutor.getTask(ThreadPoolExecutor.java:1009)
        at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1069)
        at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569)
        at java.lang.Thread.run(Thread.java:856)
  
      "GLThread 320" prio=5 tid=12 NATIVE
        | group="main" sCount=1 dsCount=0 obj=0x41535368 self=0x2f7308
        | sysTid=8049 nice=0 sched=0/0 cgrp=default handle=2690528
        | schedstat=( 1744387397 1741438396 2048 ) utm=169 stm=5 core=1
        at com.google.android.gles_jni.EGLImpl.eglSwapBuffers(Native Method)
  ndroid.player.GLTextureView$GLThread.run(GLTextureView.java:1261)
  
  "Binder Thread #2" prio=5 tid=10 NATIVE
    | group="main" sCount=1 dsCount=0 obj=0x4150bfd8 self=0x217e08
    | sysTid=8038 nice=0 sched=0/0 cgrp=default handle=2155984
    | schedstat=( 1496167 16950375 10 ) utm=0 stm=0 core=0
    at dalvik.system.NativeStart.run(Native Method)
  
  "Binder Thread #1" prio=5 tid=9 NATIVE
    | group="main" sCount=1 dsCount=0 obj=0x414fb130 self=0x1bd740
    | sysTid=8037 nice=0 sched=0/0 cgrp=default handle=1595520
    | schedstat=( 2633041 25123960 10 ) utm=0 stm=0 core=0
    at dalvik.system.NativeStart.run(Native Method)
  
  "FinalizerWatchdogDaemon" daemon prio=5 tid=8 TIMED_WAIT
    | group="main" sCount=1 dsCount=0 obj=0x414f7490 self=0x182a50
    | sysTid=8036 nice=0 sched=0/0 cgrp=default handle=1433120
    | schedstat=( 288708 6619500 5 ) utm=0 stm=0 core=0
    at java.lang.VMThread.sleep(Native Method)
    at java.lang.Thread.sleep(Thread.java:1031)
    at java.lang.Thread.sleep(Thread.java:1013)
    at java.lang.Daemons$FinalizerWatchdogDaemon.run(Daemons.java:213)
    at java.lang.Thread.run(Thread.java:856)
  
  "FinalizerDaemon" daemon prio=5 tid=7 WAIT
    | group="main" sCount=1 dsCount=0 obj=0x414f7338 self=0x105230
    | sysTid=8035 nice=0 sched=0/0 cgrp=default handle=1662112
    | schedstat=( 3763081 5489124 25 ) utm=0 stm=0 core=1
    at java.lang.Object.wait(Native Method)
    - waiting on &lt;0x40c265d0&gt; (a java.lang.ref.ReferenceQueue)
    at java.lang.Object.wait(Object.java:401)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:102)
    at java.lang.ref.ReferenceQueue.remove(ReferenceQueue.java:73)
    at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:168)
    at java.lang.Thread.run(Thread.java:856)
  
  "ReferenceQueueDaemon" daemon prio=5 tid=6 WAIT
    | group="main" sCount=1 dsCount=0 obj=0x414f71d0 self=0xfa1f0
    | sysTid=8034 nice=0 sched=0/0 cgrp=default handle=1662016
    | schedstat=( 1831625 1206249 33 ) utm=0 stm=0 core=1
    at java.lang.Object.wait(Native Method)
    - waiting on &lt;0x40c264f8&gt; 
    at java.lang.Object.wait(Object.java:364)
    at java.lang.Daemons$ReferenceQueueDaemon.run(Daemons.java:128)
    at java.lang.Thread.run(Thread.java:856)
  
  "Compiler" daemon prio=5 tid=5 VMWAIT
    | group="system" sCount=1 dsCount=0 obj=0x414f70e0 self=0x1b8688
    | sysTid=8033 nice=0 sched=0/0 cgrp=default handle=747976
    | schedstat=( 182108462 246633083 1197 ) utm=11 stm=7 core=1
    at dalvik.system.NativeStart.run(Native Method)
  
  "JDWP" daemon prio=5 tid=4 VMWAIT
    | group="system" sCount=1 dsCount=0 obj=0x414f6ff8 self=0x206680
    | sysTid=8032 nice=0 sched=0/0 cgrp=default handle=1450968
    | schedstat=( 1964583 1505832 16 ) utm=0 stm=0 core=1
    at dalvik.system.NativeStart.run(Native Method)
  
  "Signal Catcher" daemon prio=5 tid=3 RUNNABLE
    | group="system" sCount=0 dsCount=0 obj=0x414f6f00 self=0x1b7dd8
    | sysTid=8031 nice=0 sched=0/0 cgrp=default handle=1660128
    | schedstat=( 4634792 2711334 6 ) utm=0 stm=0 core=0
    at dalvik.system.NativeStart.run(Native Method)
  
  "GC" daemon prio=5 tid=2 VMWAIT
    | group="system" sCount=1 dsCount=0 obj=0x414f6e20 self=0x20adb8
    | sysTid=8028 nice=0 sched=0/0 cgrp=default handle=1365944
    | schedstat=( 132084797 114875290 96 ) utm=10 stm=2 core=1
    at dalvik.system.NativeStart.run(Native Method)
  </code></pre>
  
  <p>Any ideas for how to debug this or why it happens? </p>