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
diff --git a/services/surfaceflinger/TransactionCallbackInvoker.h b/services/surfaceflinger/TransactionCallbackInvoker.h
index 100dbfa..e203d41 100644
--- a/services/surfaceflinger/TransactionCallbackInvoker.h
+++ b/services/surfaceflinger/TransactionCallbackInvoker.h
@@ -76,7 +76,7 @@
void addPresentFence(const sp<Fence>& presentFence);
- void sendCallbacks();
+ void sendCallbacks(bool onCommitOnly);
void clearCompletedTransactions() {
mCompletedTransactions.clear();
}
@@ -86,11 +86,9 @@
private:
- status_t findTransactionStats(const sp<IBinder>& listener,
- const std::vector<CallbackId>& callbackIds,
- TransactionStats** outTransactionStats);
-
-
+ status_t findOrCreateTransactionStats(const sp<IBinder>& listener,
+ const std::vector<CallbackId>& callbackIds,
+ TransactionStats** outTransactionStats);
std::unordered_map<sp<IBinder>, std::deque<TransactionStats>, IListenerHash>
mCompletedTransactions;