From 90cbbd1f7f510e7c173f706919492a95e91a87e7 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Thu, 17 Nov 2011 18:46:09 -0800 Subject: attempt to fix bug 5313580 the working theory here is that a Surface object has become non-promotable because it lost its last reference; later Surface::readFromParcel is called the previous surface is found in the cache, but can't be promoted. this causes a new Surface object to be created which will promptly try to connect to the CPU_API -- this in turn will fail because the previous (now dead) surface is still connected. To fix this, we make sure to disconnect from the SurfaceTexture when Surface[TextureClient] is destroyed. Change-Id: I422234868a05d7b7d283e9d5a85f7ab79e65d8a9 --- include/gui/SurfaceTextureClient.h | 1 + libs/gui/SurfaceTextureClient.cpp | 6 ++++++ 2 files changed, 7 insertions(+) diff --git a/include/gui/SurfaceTextureClient.h b/include/gui/SurfaceTextureClient.h index 57f9e15..971a1b8 100644 --- a/include/gui/SurfaceTextureClient.h +++ b/include/gui/SurfaceTextureClient.h @@ -40,6 +40,7 @@ public: protected: SurfaceTextureClient(); + virtual ~SurfaceTextureClient(); void setISurfaceTexture(const sp& surfaceTexture); private: diff --git a/libs/gui/SurfaceTextureClient.cpp b/libs/gui/SurfaceTextureClient.cpp index 98fa171..48070d6 100644 --- a/libs/gui/SurfaceTextureClient.cpp +++ b/libs/gui/SurfaceTextureClient.cpp @@ -36,6 +36,12 @@ SurfaceTextureClient::SurfaceTextureClient() { SurfaceTextureClient::init(); } +SurfaceTextureClient::~SurfaceTextureClient() { + if (mConnectedToCpu) { + SurfaceTextureClient::disconnect(NATIVE_WINDOW_API_CPU); + } +} + void SurfaceTextureClient::init() { // Initialize the ANativeWindow function pointers. ANativeWindow::setSwapInterval = hook_setSwapInterval; -- cgit v1.1