From f384e05f26d78f95b28f30d4f83e72dad16dba10 Mon Sep 17 00:00:00 2001 From: Marissa Wall Date: Wed, 12 Jun 2019 13:25:07 -0700 Subject: TransactionCallbacks: don't send callbacks until applied If a transaction is in the middle of applying, the callback thread doesn't have all of the transaction's surface controls. If SF's main thread is in post composition, it can trigger send callbacks which sends the partially completed callback. This is not a long term solution. However the long term solution would touch much more code too late in the Q release. The long term solution should tell the transaction completed thread when a transaction starts applying and when it is finished. Callbacks for that transaction wouldn't be sent until the transaction is done applying. Bug: 134194071 Test: Run the testsurfacecontrol.apk that is linked to in the bug Change-Id: I2d5a6a5cc06f17b6b1b69900d28abc0563d4767b --- services/surfaceflinger/SurfaceFlinger.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) (limited to 'services/surfaceflinger/SurfaceFlinger.cpp') diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp index dd75868443..e795ba123a 100644 --- a/services/surfaceflinger/SurfaceFlinger.cpp +++ b/services/surfaceflinger/SurfaceFlinger.cpp @@ -2133,7 +2133,14 @@ void SurfaceFlinger::postComposition() } mTransactionCompletedThread.addPresentFence(mPreviousPresentFences[0]); - mTransactionCompletedThread.sendCallbacks(); + + // Lock the mStateLock in case SurfaceFlinger is in the middle of applying a transaction. + // If we do not lock here, a callback could be sent without all of its SurfaceControls and + // metrics. + { + Mutex::Autolock _l(mStateLock); + mTransactionCompletedThread.sendCallbacks(); + } if (mLumaSampling && mRegionSamplingThread) { mRegionSamplingThread->notifyNewContent(); -- cgit v1.2.3-59-g8ed1b