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
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index dd75868..e795ba1 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -2133,7 +2133,14 @@
}
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();