diff options
author | Jamie Gennis <jgennis@google.com> | 2013-04-05 16:41:27 -0700 |
---|---|---|
committer | Jamie Gennis <jgennis@google.com> | 2013-04-08 14:42:22 -0700 |
commit | ad669b04f4633957eea55b8ad2d8253adcefe39b (patch) | |
tree | 280e1d04fdc8ef6483574379114175ae4bf98232 /libs | |
parent | 83a3ad4d579b514dfeff43008254d05922e5e324 (diff) | |
download | frameworks_native-ad669b04f4633957eea55b8ad2d8253adcefe39b.zip frameworks_native-ad669b04f4633957eea55b8ad2d8253adcefe39b.tar.gz frameworks_native-ad669b04f4633957eea55b8ad2d8253adcefe39b.tar.bz2 |
libgui: fix an EGLImage leak
This moves the call to ConsumerBase::abandon from the ConsumerBase dtor to
ConsumerBase::onLastStrongRef. The abandon call relies on virtual methods to
perform the clean-up, so calling it from the ConsumerBase dtor after the
derived classes dtors ran was skipping some of the clean-up. The
onLastStrongRef method should get called just before the most derived class's
dtor gets called.
Bug: 8349135
Change-Id: I836946826927cc1ed69c049049f525f92b17a269
Diffstat (limited to 'libs')
-rw-r--r-- | libs/gui/ConsumerBase.cpp | 13 | ||||
-rw-r--r-- | libs/gui/tests/SurfaceTextureClient_test.cpp | 8 |
2 files changed, 16 insertions, 5 deletions
diff --git a/libs/gui/ConsumerBase.cpp b/libs/gui/ConsumerBase.cpp index 8694d21..4937b17 100644 --- a/libs/gui/ConsumerBase.cpp +++ b/libs/gui/ConsumerBase.cpp @@ -76,7 +76,18 @@ ConsumerBase::ConsumerBase(const sp<BufferQueue>& bufferQueue) : } ConsumerBase::~ConsumerBase() { - CB_LOGV("~ConsumerBase"); + CB_LOGV("~ConsumerBase"); + Mutex::Autolock lock(mMutex); + + // Verify that abandon() has been called before we get here. This should + // be done by ConsumerBase::onLastStrongRef(), but it's possible for a + // derived class to override that method and not call + // ConsumerBase::onLastStrongRef(). + LOG_ALWAYS_FATAL_IF(!mAbandoned, "[%s] ~ConsumerBase was called, but the " + "consumer is not abandoned!", mName.string()); +} + +void ConsumerBase::onLastStrongRef(const void* id) { abandon(); } diff --git a/libs/gui/tests/SurfaceTextureClient_test.cpp b/libs/gui/tests/SurfaceTextureClient_test.cpp index ce96036..7376b4c 100644 --- a/libs/gui/tests/SurfaceTextureClient_test.cpp +++ b/libs/gui/tests/SurfaceTextureClient_test.cpp @@ -178,21 +178,21 @@ TEST_F(SurfaceTextureClientTest, EglSwapBuffersAbandonErrorIsEglBadSurface) { EXPECT_EQ(EGL_SUCCESS, eglGetError()); EGLBoolean success = eglMakeCurrent(mEglDisplay, eglSurface, eglSurface, mEglContext); - EXPECT_EQ(EGL_TRUE, success); + EXPECT_TRUE(success); glClear(GL_COLOR_BUFFER_BIT); success = eglSwapBuffers(mEglDisplay, eglSurface); - EXPECT_EQ(EGL_TRUE, success); + EXPECT_TRUE(success); mST->abandon(); glClear(GL_COLOR_BUFFER_BIT); success = eglSwapBuffers(mEglDisplay, eglSurface); - EXPECT_EQ(EGL_FALSE, success); + EXPECT_FALSE(success); EXPECT_EQ(EGL_BAD_SURFACE, eglGetError()); success = eglMakeCurrent(mEglDisplay, mEglSurface, mEglSurface, mEglContext); - ASSERT_EQ(EGL_TRUE, success); + ASSERT_TRUE(success); if (eglSurface != EGL_NO_SURFACE) { eglDestroySurface(mEglDisplay, eglSurface); |