Loading services/surfaceflinger/SurfaceFlinger.cpp +23 −4 Original line number Diff line number Diff line Loading @@ -2138,8 +2138,16 @@ bool SurfaceFlinger::commit(nsecs_t frameTime, int64_t vsyncId, nsecs_t expected 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 = flushTransactions(); needsTraversal |= commitCreatedLayers(); needsTraversal |= flushTransactionQueues(vsyncId); needsTraversal |= applyTransactions(transactions, vsyncId); } const bool shouldCommit = Loading Loading @@ -3798,7 +3806,7 @@ int SurfaceFlinger::flushPendingTransactionQueues( return transactionsPendingBarrier; } bool SurfaceFlinger::flushTransactionQueues(int64_t vsyncId) { std::vector<TransactionState> SurfaceFlinger::flushTransactions() { // 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 Loading Loading @@ -3892,14 +3900,25 @@ bool SurfaceFlinger::flushTransactionQueues(int64_t vsyncId) { flushUnsignaledPendingTransactionQueues(transactions, bufferLayersReadyToPresent, applyTokensWithUnsignaledTransactions); } return applyTransactions(transactions, vsyncId); } } return transactions; } // for test only bool SurfaceFlinger::flushTransactionQueues(int64_t vsyncId) { std::vector<TransactionState> transactions = flushTransactions(); return applyTransactions(transactions, vsyncId); } bool SurfaceFlinger::applyTransactions(std::vector<TransactionState>& transactions, int64_t vsyncId) { Mutex::Autolock _l(mStateLock); return applyTransactionsLocked(transactions, vsyncId); } bool SurfaceFlinger::applyTransactionsLocked(std::vector<TransactionState>& transactions, int64_t 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 @@ -770,6 +770,9 @@ private: REQUIRES(mStateLock); // flush pending transaction that was presented after desiredPresentTime. bool flushTransactionQueues(int64_t vsyncId); std::vector<TransactionState> flushTransactions(); // Returns true if there is at least one transaction that needs to be flushed bool transactionFlushNeeded(); Loading Loading @@ -818,7 +821,8 @@ private: size_t totalTXapplied) const; bool stopTransactionProcessing(const std::unordered_set<sp<IBinder>, SpHash<IBinder>>& applyTokensWithUnsignaledTransactions) const; bool applyTransactions(std::vector<TransactionState>& transactions, int64_t vsyncId) bool applyTransactions(std::vector<TransactionState>& transactions, int64_t vsyncId); bool applyTransactionsLocked(std::vector<TransactionState>& transactions, int64_t vsyncId) REQUIRES(mStateLock); uint32_t setDisplayStateLocked(const DisplayState& s) REQUIRES(mStateLock); uint32_t addInputWindowCommands(const InputWindowCommands& inputWindowCommands) Loading Loading
services/surfaceflinger/SurfaceFlinger.cpp +23 −4 Original line number Diff line number Diff line Loading @@ -2138,8 +2138,16 @@ bool SurfaceFlinger::commit(nsecs_t frameTime, int64_t vsyncId, nsecs_t expected 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 = flushTransactions(); needsTraversal |= commitCreatedLayers(); needsTraversal |= flushTransactionQueues(vsyncId); needsTraversal |= applyTransactions(transactions, vsyncId); } const bool shouldCommit = Loading Loading @@ -3798,7 +3806,7 @@ int SurfaceFlinger::flushPendingTransactionQueues( return transactionsPendingBarrier; } bool SurfaceFlinger::flushTransactionQueues(int64_t vsyncId) { std::vector<TransactionState> SurfaceFlinger::flushTransactions() { // 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 Loading Loading @@ -3892,14 +3900,25 @@ bool SurfaceFlinger::flushTransactionQueues(int64_t vsyncId) { flushUnsignaledPendingTransactionQueues(transactions, bufferLayersReadyToPresent, applyTokensWithUnsignaledTransactions); } return applyTransactions(transactions, vsyncId); } } return transactions; } // for test only bool SurfaceFlinger::flushTransactionQueues(int64_t vsyncId) { std::vector<TransactionState> transactions = flushTransactions(); return applyTransactions(transactions, vsyncId); } bool SurfaceFlinger::applyTransactions(std::vector<TransactionState>& transactions, int64_t vsyncId) { Mutex::Autolock _l(mStateLock); return applyTransactionsLocked(transactions, vsyncId); } bool SurfaceFlinger::applyTransactionsLocked(std::vector<TransactionState>& transactions, int64_t 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 @@ -770,6 +770,9 @@ private: REQUIRES(mStateLock); // flush pending transaction that was presented after desiredPresentTime. bool flushTransactionQueues(int64_t vsyncId); std::vector<TransactionState> flushTransactions(); // Returns true if there is at least one transaction that needs to be flushed bool transactionFlushNeeded(); Loading Loading @@ -818,7 +821,8 @@ private: size_t totalTXapplied) const; bool stopTransactionProcessing(const std::unordered_set<sp<IBinder>, SpHash<IBinder>>& applyTokensWithUnsignaledTransactions) const; bool applyTransactions(std::vector<TransactionState>& transactions, int64_t vsyncId) bool applyTransactions(std::vector<TransactionState>& transactions, int64_t vsyncId); bool applyTransactionsLocked(std::vector<TransactionState>& transactions, int64_t vsyncId) REQUIRES(mStateLock); uint32_t setDisplayStateLocked(const DisplayState& s) REQUIRES(mStateLock); uint32_t addInputWindowCommands(const InputWindowCommands& inputWindowCommands) Loading