Commit 02902c21 authored by Frank Liberato's avatar Frank Liberato Committed by Commit Bot

Call release() on ImageReader's surface.

Previously, ImageReaderGLOwner created a ScopedJavaSurface that did
not call Surface.release() upon destruction.  Unfortunately, this
meant that nobody called release().

This was never noticed because we also leaked the Surface object,
so it was never finalized => no helpful diagnostics.  After

https://chromium-review.googlesource.com/c/chromium/src/+/2453270

the leak was fixed, but now the lack of release() caused strict-
mode violations.

This change switches ImageReader's ScopedJavaSurface to call release
properly. It's safe because CodecSurfaceBundle makes sure that the
surface outlives the MediaCodec instance that's using it.

This change also reverts

https://chromium-review.googlesource.com/c/chromium/src/+/2527563

which replaced the leak-the-surface behavior intentionally,
as part of the investigation.

Bug: 1146071
Change-Id: Ib8187530299ba7790e30e630250cc2a7fd4eebf9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2537782Reviewed-by: default avatarRichard Coles <torne@chromium.org>
Reviewed-by: default avatarvikas soni <vikassoni@chromium.org>
Commit-Queue: Frank Liberato <liberato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#827468}
parent b8a61317
......@@ -240,13 +240,12 @@ gl::ScopedJavaSurface ImageReaderGLOwner::CreateJavaSurface() const {
// Get the java surface object from the Android native window.
JNIEnv* env = base::android::AttachCurrentThread();
jobject j_surface = loader_.ANativeWindow_toSurface(env, window);
auto j_surface = base::android::ScopedJavaLocalRef<jobject>::Adopt(
env, loader_.ANativeWindow_toSurface(env, window));
DCHECK(j_surface);
// Get the scoped java surface that is owned externally.
// TODO(1146071): use of JavaParamRef temporary to try to debug crash.
return gl::ScopedJavaSurface::AcquireExternalSurface(
base::android::JavaParamRef<jobject>(env, j_surface));
// Get the scoped java surface that will call release() on destruction.
return gl::ScopedJavaSurface(j_surface);
}
void ImageReaderGLOwner::UpdateTexImage() {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment