Skip to content

Commit 90cbbd1

Browse files
committed
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
1 parent 302afb9 commit 90cbbd1

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

include/gui/SurfaceTextureClient.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ class SurfaceTextureClient
4040

4141
protected:
4242
SurfaceTextureClient();
43+
virtual ~SurfaceTextureClient();
4344
void setISurfaceTexture(const sp<ISurfaceTexture>& surfaceTexture);
4445

4546
private:

libs/gui/SurfaceTextureClient.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ SurfaceTextureClient::SurfaceTextureClient() {
3636
SurfaceTextureClient::init();
3737
}
3838

39+
SurfaceTextureClient::~SurfaceTextureClient() {
40+
if (mConnectedToCpu) {
41+
SurfaceTextureClient::disconnect(NATIVE_WINDOW_API_CPU);
42+
}
43+
}
44+
3945
void SurfaceTextureClient::init() {
4046
// Initialize the ANativeWindow function pointers.
4147
ANativeWindow::setSwapInterval = hook_setSwapInterval;

0 commit comments

Comments
 (0)