From 30da367c6c0781d9783459567ec57d9d10c77c92 Mon Sep 17 00:00:00 2001 From: Patrick Williams Date: Tue, 25 Jul 2023 16:52:01 -0500 Subject: Ensure transaction commit callbacks are called at most once. Bug: 288781573 Bug: 292443283 Test: atest LayerTransactionTest Change-Id: Ide66601b8a892b4bf5a331d83d38b4bd50919751 --- libs/gui/SurfaceComposerClient.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'libs/gui/SurfaceComposerClient.cpp') diff --git a/libs/gui/SurfaceComposerClient.cpp b/libs/gui/SurfaceComposerClient.cpp index 5bc05ef0d8..db99726739 100644 --- a/libs/gui/SurfaceComposerClient.cpp +++ b/libs/gui/SurfaceComposerClient.cpp @@ -377,7 +377,6 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener } auto& [callbackFunction, callbackSurfaceControls] = callbacksMap[callbackId]; if (!callbackFunction) { - ALOGE("cannot call null callback function, skipping"); continue; } std::vector surfaceControlStats; @@ -394,6 +393,11 @@ void TransactionCompletedListener::onTransactionCompleted(ListenerStats listener callbackFunction(transactionStats.latchTime, transactionStats.presentFence, surfaceControlStats); + + // More than one transaction may contain the same callback id. Erase the callback from + // the map to ensure that it is only called once. This can happen if transactions are + // parcelled out of process and applied in both processes. + callbacksMap.erase(callbackId); } // handle on complete callbacks -- cgit v1.2.3-59-g8ed1b