SF: check isVsyncValid based on the transaction submitter
isVsyncValid is used to throttle applications to a lower frame rate than
the display refresh rate. With the current implementation of BlastSync
we may get a single transaction that contains layers from different
applications, we may cause to throttle unindended applications
(such as SystemUI). Instead, we are checking the transaction submitter
for whether we should throttle the transaction or not.
Bug: 182587984
Test: atest FrameRateOverrideHostTest
Change-Id: I7dd0c4c1ac945d6142afcdc8ba62c5a48a6dbb00
diff --git a/services/surfaceflinger/SurfaceFlinger.cpp b/services/surfaceflinger/SurfaceFlinger.cpp
index 7706ad5..7a65735 100644
--- a/services/surfaceflinger/SurfaceFlinger.cpp
+++ b/services/surfaceflinger/SurfaceFlinger.cpp
@@ -3316,7 +3316,8 @@
if (!transactionIsReadyToBeApplied(transaction.frameTimelineInfo,
transaction.isAutoTimestamp,
transaction.desiredPresentTime,
- transaction.states, pendingBuffers)) {
+ transaction.originUid, transaction.states,
+ pendingBuffers)) {
setTransactionFlags(eTransactionFlushNeeded);
break;
}
@@ -3343,7 +3344,8 @@
if (!transactionIsReadyToBeApplied(transaction.frameTimelineInfo,
transaction.isAutoTimestamp,
transaction.desiredPresentTime,
- transaction.states, pendingBuffers) ||
+ transaction.originUid, transaction.states,
+ pendingBuffers) ||
pendingTransactions) {
mPendingTransactionQueues[transaction.applyToken].push(transaction);
} else {
@@ -3374,7 +3376,7 @@
bool SurfaceFlinger::transactionIsReadyToBeApplied(
const FrameTimelineInfo& info, bool isAutoTimestamp, int64_t desiredPresentTime,
- const Vector<ComposerState>& states,
+ uid_t originUid, const Vector<ComposerState>& states,
std::unordered_set<sp<IBinder>, ISurfaceComposer::SpHash<IBinder>>& pendingBuffers) {
ATRACE_CALL();
const nsecs_t expectedPresentTime = mExpectedPresentTime.load();
@@ -3387,6 +3389,11 @@
ready = false;
}
+ if (!mScheduler->isVsyncValid(expectedPresentTime, originUid)) {
+ ATRACE_NAME("!isVsyncValid");
+ ready = false;
+ }
+
for (const ComposerState& state : states) {
const layer_state_t& s = state.state;
const bool acquireFenceChanged = (s.what & layer_state_t::eAcquireFenceChanged);
@@ -3415,11 +3422,6 @@
ready = false;
}
- if (!mScheduler->isVsyncValid(expectedPresentTime, layer->getOwnerUid())) {
- ATRACE_NAME("!isVsyncValidForUid");
- ready = false;
- }
-
if (acquireFenceChanged) {
// If backpressure is enabled and we already have a buffer to commit, keep the
// transaction in the queue.