diff options
| author | 2019-07-11 13:10:44 -0700 | |
|---|---|---|
| committer | 2019-07-11 13:10:44 -0700 | |
| commit | 0decf3038b992bd3a2758c8dba3d0a16d09247ff (patch) | |
| tree | 75ceb06336d3e2251177f3c674e756d03db82257 | |
| parent | 621a6ca15ad9448a71f941252e6ec10228e2f4e8 (diff) | |
| parent | 6990af63ff06297ffa0373daa32a196c29d99b95 (diff) | |
Merge "blast: fix leak on BufferStateLayer death" into qt-dev
am: 6990af63ff
Change-Id: I46fa4328214c20c5c907df83378dc93466178e19
| -rw-r--r-- | services/surfaceflinger/TransactionCompletedThread.cpp | 10 | ||||
| -rw-r--r-- | services/surfaceflinger/TransactionCompletedThread.h | 2 |
2 files changed, 9 insertions, 3 deletions
diff --git a/services/surfaceflinger/TransactionCompletedThread.cpp b/services/surfaceflinger/TransactionCompletedThread.cpp index 5cf8eb1a1d..fd466dedff 100644 --- a/services/surfaceflinger/TransactionCompletedThread.cpp +++ b/services/surfaceflinger/TransactionCompletedThread.cpp @@ -197,8 +197,14 @@ status_t TransactionCompletedThread::addCallbackHandle(const sp<CallbackHandle>& } transactionStats->latchTime = handle->latchTime; - transactionStats->surfaceStats.emplace_back(handle->surfaceControl, handle->acquireTime, - handle->previousReleaseFence); + // If the layer has already been destroyed, don't add the SurfaceControl to the callback. + // The client side keeps a sp<> to the SurfaceControl so if the SurfaceControl has been + // destroyed the client side is dead and there won't be anyone to send the callback to. + sp<IBinder> surfaceControl = handle->surfaceControl.promote(); + if (surfaceControl) { + transactionStats->surfaceStats.emplace_back(surfaceControl, handle->acquireTime, + handle->previousReleaseFence); + } return NO_ERROR; } diff --git a/services/surfaceflinger/TransactionCompletedThread.h b/services/surfaceflinger/TransactionCompletedThread.h index 21e2678701..e849f714d0 100644 --- a/services/surfaceflinger/TransactionCompletedThread.h +++ b/services/surfaceflinger/TransactionCompletedThread.h @@ -49,7 +49,7 @@ public: sp<ITransactionCompletedListener> listener; std::vector<CallbackId> callbackIds; - sp<IBinder> surfaceControl; + wp<IBinder> surfaceControl; bool releasePreviousBuffer = false; sp<Fence> previousReleaseFence; |