diff options
author | 2021-10-18 08:42:46 -0700 | |
---|---|---|
committer | 2021-10-18 08:44:33 -0700 | |
commit | cd52e2db6c57326c1380cd53e9520adc7faf5ec9 (patch) | |
tree | 00af6e96bb97ca397dac732d895ef789f4375847 /services/surfaceflinger/TransactionCallbackInvoker.cpp | |
parent | 6e461bf82436a0abb59da69c391aab77c72af028 (diff) |
SurfaceFlinger: Fix duplicate callbacks
Transaction callbacks are emitted early, for empty transactions,
after latch for on commit callbacks and on post composition for
transaction complete callbacks. Pending callbacks are stored
together. If a transaction contains a layer that is presented
and a layer that is not presented, the transaction callback will
get added to the pending list after the transaction is committed
and it will get emitted after buffers are latched and then again
at the end of composition. To fix this we make sure to only emit
on commit callbacks after a buffer is latched.
Test: atest SurfaceFlinger_test
Bug: 202394221
Change-Id: I356fbf221812060c17765c53cc3df24cb3cd139a
Diffstat (limited to 'services/surfaceflinger/TransactionCallbackInvoker.cpp')
-rw-r--r-- | services/surfaceflinger/TransactionCallbackInvoker.cpp | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/services/surfaceflinger/TransactionCallbackInvoker.cpp b/services/surfaceflinger/TransactionCallbackInvoker.cpp index 8fbf0b4d07..f3d46ea061 100644 --- a/services/surfaceflinger/TransactionCallbackInvoker.cpp +++ b/services/surfaceflinger/TransactionCallbackInvoker.cpp @@ -121,7 +121,7 @@ status_t TransactionCallbackInvoker::registerUnpresentedCallbackHandle( return addCallbackHandle(handle, std::vector<JankData>()); } -status_t TransactionCallbackInvoker::findTransactionStats( +status_t TransactionCallbackInvoker::findOrCreateTransactionStats( const sp<IBinder>& listener, const std::vector<CallbackId>& callbackIds, TransactionStats** outTransactionStats) { auto& transactionStatsDeque = mCompletedTransactions[listener]; @@ -143,7 +143,8 @@ status_t TransactionCallbackInvoker::addCallbackHandle(const sp<CallbackHandle>& // If we can't find the transaction stats something has gone wrong. The client should call // startRegistration before trying to add a callback handle. TransactionStats* transactionStats; - status_t err = findTransactionStats(handle->listener, handle->callbackIds, &transactionStats); + status_t err = + findOrCreateTransactionStats(handle->listener, handle->callbackIds, &transactionStats); if (err != NO_ERROR) { return err; } @@ -204,7 +205,7 @@ void TransactionCallbackInvoker::addPresentFence(const sp<Fence>& presentFence) mPresentFence = presentFence; } -void TransactionCallbackInvoker::sendCallbacks() { +void TransactionCallbackInvoker::sendCallbacks(bool onCommitOnly) { // For each listener auto completedTransactionsItr = mCompletedTransactions.begin(); while (completedTransactionsItr != mCompletedTransactions.end()) { @@ -216,6 +217,10 @@ void TransactionCallbackInvoker::sendCallbacks() { auto transactionStatsItr = transactionStatsDeque.begin(); while (transactionStatsItr != transactionStatsDeque.end()) { auto& transactionStats = *transactionStatsItr; + if (onCommitOnly && !containsOnCommitCallbacks(transactionStats.callbackIds)) { + transactionStatsItr++; + continue; + } // If the transaction has been latched if (transactionStats.latchTime >= 0 && |