Detect leaks of TextureBufferImpl objects.

The performance cost is not trivial but according to my profiling,
it is acceptable.

Bug: b/139745386
Change-Id: I0e63221ccf22e9f6fb32c630ff63a279e765994a
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/150539
Reviewed-by: Kári Helgason <kthelgason@webrtc.org>
Commit-Queue: Sami Kalliomäki <sakal@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#28973}
diff --git a/sdk/android/api/org/webrtc/TextureBufferImpl.java b/sdk/android/api/org/webrtc/TextureBufferImpl.java
index a24f284..bcb9478 100644
--- a/sdk/android/api/org/webrtc/TextureBufferImpl.java
+++ b/sdk/android/api/org/webrtc/TextureBufferImpl.java
@@ -19,6 +19,8 @@
  * release callback. ToI420() is implemented by providing a Handler and a YuvConverter.
  */
 public class TextureBufferImpl implements VideoFrame.TextureBuffer {
+  private static final int RELEASE_TIMEOUT_MS = 10000;
+
   // This is the full resolution the texture has in memory after applying the transformation matrix
   // that might include cropping. This resolution is useful to know when sampling the texture to
   // avoid downscaling artifacts.
@@ -60,7 +62,7 @@
     this.transformMatrix = transformMatrix;
     this.toI420Handler = toI420Handler;
     this.yuvConverter = yuvConverter;
-    this.refCountDelegate = new RefCountDelegate(releaseCallback);
+    this.refCountDelegate = new RefCountDelegate(releaseCallback, RELEASE_TIMEOUT_MS);
   }
 
   @Override