Loading services/surfaceflinger/SurfaceFlinger.cpp +17 −8 Original line number Diff line number Diff line Loading @@ -2270,9 +2270,17 @@ bool SurfaceFlinger::commit(TimePoint frameTime, VsyncId vsyncId, TimePoint expe bool needsTraversal = false; if (clearTransactionFlags(eTransactionFlushNeeded)) { // Locking: // 1. to prevent onHandleDestroyed from being called while the state lock is held, // we must keep a copy of the transactions (specifically the composer // states) around outside the scope of the lock. // 2. Transactions and created layers do not share a lock. To prevent applying // transactions with layers still in the createdLayer queue, flush the transactions // before committing the created layers. std::vector<TransactionState> transactions = mTransactionHandler.flushTransactions(); needsTraversal |= commitMirrorDisplays(vsyncId); needsTraversal |= commitCreatedLayers(vsyncId); needsTraversal |= flushTransactionQueues(vsyncId); needsTraversal |= applyTransactions(transactions, vsyncId); } const bool shouldCommit = Loading Loading @@ -3975,19 +3983,20 @@ void SurfaceFlinger::addTransactionReadyFilters() { std::bind(&SurfaceFlinger::transactionReadyBufferCheck, this, std::placeholders::_1)); } // For tests only bool SurfaceFlinger::flushTransactionQueues(VsyncId vsyncId) { // to prevent onHandleDestroyed from being called while the lock is held, // we must keep a copy of the transactions (specifically the composer // states) around outside the scope of the lock std::vector<TransactionState> transactions = mTransactionHandler.flushTransactions(); { Mutex::Autolock _l(mStateLock); return applyTransactions(transactions, vsyncId); } } bool SurfaceFlinger::applyTransactions(std::vector<TransactionState>& transactions, VsyncId vsyncId) { Mutex::Autolock _l(mStateLock); return applyTransactionsLocked(transactions, vsyncId); } bool SurfaceFlinger::applyTransactionsLocked(std::vector<TransactionState>& transactions, VsyncId vsyncId) { bool needsTraversal = false; // Now apply all transactions. for (auto& transaction : transactions) { Loading services/surfaceflinger/SurfaceFlinger.h +5 −1 Original line number Diff line number Diff line Loading @@ -715,7 +715,11 @@ private: const std::vector<ListenerCallbacks>& listenerCallbacks, int originPid, int originUid, uint64_t transactionId) REQUIRES(mStateLock); // Flush pending transactions that were presented after desiredPresentTime. // For test only bool flushTransactionQueues(VsyncId) REQUIRES(kMainThreadContext); bool applyTransactions(std::vector<TransactionState>&, VsyncId) REQUIRES(kMainThreadContext); // Returns true if there is at least one transaction that needs to be flushed bool transactionFlushNeeded(); void addTransactionReadyFilters(); Loading Loading @@ -746,7 +750,7 @@ private: static LatchUnsignaledConfig getLatchUnsignaledConfig(); bool shouldLatchUnsignaled(const sp<Layer>& layer, const layer_state_t&, size_t numStates, bool firstTransaction) const; bool applyTransactions(std::vector<TransactionState>& transactions, VsyncId) bool applyTransactionsLocked(std::vector<TransactionState>& transactions, VsyncId) REQUIRES(mStateLock); uint32_t setDisplayStateLocked(const DisplayState& s) REQUIRES(mStateLock); uint32_t addInputWindowCommands(const InputWindowCommands& inputWindowCommands) Loading Loading
services/surfaceflinger/SurfaceFlinger.cpp +17 −8 Original line number Diff line number Diff line Loading @@ -2270,9 +2270,17 @@ bool SurfaceFlinger::commit(TimePoint frameTime, VsyncId vsyncId, TimePoint expe bool needsTraversal = false; if (clearTransactionFlags(eTransactionFlushNeeded)) { // Locking: // 1. to prevent onHandleDestroyed from being called while the state lock is held, // we must keep a copy of the transactions (specifically the composer // states) around outside the scope of the lock. // 2. Transactions and created layers do not share a lock. To prevent applying // transactions with layers still in the createdLayer queue, flush the transactions // before committing the created layers. std::vector<TransactionState> transactions = mTransactionHandler.flushTransactions(); needsTraversal |= commitMirrorDisplays(vsyncId); needsTraversal |= commitCreatedLayers(vsyncId); needsTraversal |= flushTransactionQueues(vsyncId); needsTraversal |= applyTransactions(transactions, vsyncId); } const bool shouldCommit = Loading Loading @@ -3975,19 +3983,20 @@ void SurfaceFlinger::addTransactionReadyFilters() { std::bind(&SurfaceFlinger::transactionReadyBufferCheck, this, std::placeholders::_1)); } // For tests only bool SurfaceFlinger::flushTransactionQueues(VsyncId vsyncId) { // to prevent onHandleDestroyed from being called while the lock is held, // we must keep a copy of the transactions (specifically the composer // states) around outside the scope of the lock std::vector<TransactionState> transactions = mTransactionHandler.flushTransactions(); { Mutex::Autolock _l(mStateLock); return applyTransactions(transactions, vsyncId); } } bool SurfaceFlinger::applyTransactions(std::vector<TransactionState>& transactions, VsyncId vsyncId) { Mutex::Autolock _l(mStateLock); return applyTransactionsLocked(transactions, vsyncId); } bool SurfaceFlinger::applyTransactionsLocked(std::vector<TransactionState>& transactions, VsyncId vsyncId) { bool needsTraversal = false; // Now apply all transactions. for (auto& transaction : transactions) { Loading
services/surfaceflinger/SurfaceFlinger.h +5 −1 Original line number Diff line number Diff line Loading @@ -715,7 +715,11 @@ private: const std::vector<ListenerCallbacks>& listenerCallbacks, int originPid, int originUid, uint64_t transactionId) REQUIRES(mStateLock); // Flush pending transactions that were presented after desiredPresentTime. // For test only bool flushTransactionQueues(VsyncId) REQUIRES(kMainThreadContext); bool applyTransactions(std::vector<TransactionState>&, VsyncId) REQUIRES(kMainThreadContext); // Returns true if there is at least one transaction that needs to be flushed bool transactionFlushNeeded(); void addTransactionReadyFilters(); Loading Loading @@ -746,7 +750,7 @@ private: static LatchUnsignaledConfig getLatchUnsignaledConfig(); bool shouldLatchUnsignaled(const sp<Layer>& layer, const layer_state_t&, size_t numStates, bool firstTransaction) const; bool applyTransactions(std::vector<TransactionState>& transactions, VsyncId) bool applyTransactionsLocked(std::vector<TransactionState>& transactions, VsyncId) REQUIRES(mStateLock); uint32_t setDisplayStateLocked(const DisplayState& s) REQUIRES(mStateLock); uint32_t addInputWindowCommands(const InputWindowCommands& inputWindowCommands) Loading