title: Nexus 5 crash: FinalizerWatchdogDaemon - SurfaceTexture.finalize()
body: <p>We're seeing a peculiar issue when attempting to re-encode videos, and it only seems to happen on the Nexus 5. We use MediaCodec to compress and re-encode videos clientside, and sometimes when the task is running on a Nexus 5 we get the following crash:</p>
  
  <pre><code>05-15 16:25:15.023 E/AndroidRuntime( 4716): FATAL EXCEPTION: FinalizerWatchdogDaemon
  05-15 16:25:15.023 E/AndroidRuntime( 4716): java.util.concurrent.TimeoutException: android.graphics.SurfaceTexture.finalize() timed out after 10 seconds
  05-15 16:25:15.023 E/AndroidRuntime( 4716):     at android.graphics.SurfaceTexture.nativeFinalize(Native Method)
  05-15 16:25:15.023 E/AndroidRuntime( 4716):     at android.graphics.SurfaceTexture.finalize(SurfaceTexture.java:353)
  05-15 16:25:15.023 E/AndroidRuntime( 4716):     at java.lang.Daemons$FinalizerDaemon.doFinalize(Daemons.java:190)
  05-15 16:25:15.023 E/AndroidRuntime( 4716):     at java.lang.Daemons$FinalizerDaemon.run(Daemons.java:173)
  05-15 16:25:15.023 E/AndroidRuntime( 4716):     at java.lang.Thread.run(Thread.java:818)    
  </code></pre>
  
  <p>Our code is relatively similar to to bigflake's DecodeEditEncodeTest (<a href="https://android.googlesource.com/platform/cts/+/jb-mr2-release/tests/tests/media/src/android/media/cts/DecodeEditEncodeTest.java" rel="nofollow">https://android.googlesource.com/platform/cts/+/jb-mr2-release/tests/tests/media/src/android/media/cts/DecodeEditEncodeTest.java</a>), and we are also using their InputSurface, OutputSurface, and TextureRender classes (<a href="https://android.googlesource.com/platform/cts/+/jb-mr2-release/tests/tests/media/src/android/media/cts/" rel="nofollow">https://android.googlesource.com/platform/cts/+/jb-mr2-release/tests/tests/media/src/android/media/cts/</a>). I am guessing that the issue occurs somewhere in OutputSurface or TextureRender as they're the classes that actually manipulate a surface texture.</p>
  
  <p>The only reliable repro steps we can come up with is that it seems to happen somewhat randomly when several videos are queued to be re-encoded, even though the encoder only handles one video at a time.</p>
  
  <p>Any help would be much appreciated.</p>