Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 109f3c00 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "SF: reduce timeout for unit tests"

parents 25de3349 e9ebce00
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -3913,7 +3913,8 @@ void SurfaceFlinger::queueTransaction(TransactionState& state) {
    // been applied by SF
    if (state.flags & eAnimation) {
        while (itr != mPendingTransactionQueues.end()) {
            status_t err = mTransactionQueueCV.waitRelative(mQueueLock, s2ns(5));
            status_t err =
                    mTransactionQueueCV.waitRelative(mQueueLock, mAnimationTransactionTimeout);
            if (CC_UNLIKELY(err != NO_ERROR)) {
                ALOGW_IF(err == TIMED_OUT,
                         "setTransactionState timed out "
@@ -3949,7 +3950,8 @@ void SurfaceFlinger::waitForSynchronousTransaction(
    // applyTransactionState is called on the main SF thread.  While a given process may wish
    // to wait on synchronous transactions, the main SF thread should apply the transaction and
    // set the value to notify this after committed.
    if (!transactionCommittedSignal.wait_until(std::chrono::seconds(5))) {
    if (!transactionCommittedSignal.wait_until(
                std::chrono::nanoseconds(mAnimationTransactionTimeout))) {
        ALOGE("setTransactionState timed out!");
    }
}
+2 −0
Original line number Diff line number Diff line
@@ -1372,6 +1372,8 @@ private:
        nsecs_t compositeStart;
        nsecs_t presentEnd;
    } mPowerHintSessionData GUARDED_BY(SF_MAIN_THREAD);

    nsecs_t mAnimationTransactionTimeout = s2ns(5);
};

} // namespace android
+1 −1
Original line number Diff line number Diff line
@@ -93,7 +93,7 @@ public:
    }

    // Return true if triggered.
    bool wait_until(const std::chrono::seconds& timeout) const {
    bool wait_until(const std::chrono::nanoseconds& timeout) const {
        std::unique_lock<std::mutex> lock(mMutex);
        const auto untilTime = std::chrono::system_clock::now() + timeout;
        while (mFlags != 0) {
+9 −0
Original line number Diff line number Diff line
@@ -177,6 +177,11 @@ class TestableSurfaceFlinger {
public:
    using HotplugEvent = SurfaceFlinger::HotplugEvent;

    TestableSurfaceFlinger()
          : mFlinger(sp<SurfaceFlinger>::make(mFactory, SurfaceFlinger::SkipInitialization)) {
        mFlinger->mAnimationTransactionTimeout = ms2ns(10);
    }

    SurfaceFlinger* flinger() { return mFlinger.get(); }
    scheduler::TestableScheduler* scheduler() { return mScheduler; }

@@ -466,6 +471,10 @@ public:
        return static_cast<mock::FrameTracer*>(mFlinger->mFrameTracer.get());
    }

    nsecs_t getAnimationTransactionTimeout() const {
        return mFlinger->mAnimationTransactionTimeout;
    }

    /* ------------------------------------------------------------------------
     * Read-write access to private data to set up preconditions and assert
     * post-conditions.
+11 −7
Original line number Diff line number Diff line
@@ -159,9 +159,9 @@ public:
        // completed.  If this is animation, it should not time out waiting.
        nsecs_t returnedTime = systemTime();
        if (flags & ISurfaceComposer::eSynchronous || syncInputWindows) {
            EXPECT_GE(returnedTime, applicationTime + s2ns(5));
            EXPECT_GE(returnedTime, applicationTime + mFlinger.getAnimationTransactionTimeout());
        } else {
            EXPECT_LE(returnedTime, applicationTime + s2ns(5));
            EXPECT_LE(returnedTime, applicationTime + mFlinger.getAnimationTransactionTimeout());
        }
        // Each transaction should have been placed on the transaction queue
        auto transactionQueue = mFlinger.getTransactionQueue();
@@ -188,9 +188,11 @@ public:

        nsecs_t returnedTime = systemTime();
        if ((flags & ISurfaceComposer::eSynchronous) || syncInputWindows) {
            EXPECT_GE(systemTime(), applicationSentTime + s2ns(5));
            EXPECT_GE(systemTime(),
                      applicationSentTime + mFlinger.getAnimationTransactionTimeout());
        } else {
            EXPECT_LE(returnedTime, applicationSentTime + s2ns(5));
            EXPECT_LE(returnedTime,
                      applicationSentTime + mFlinger.getAnimationTransactionTimeout());
        }
        // This transaction should have been placed on the transaction queue
        auto transactionQueue = mFlinger.getTransactionQueue();
@@ -228,7 +230,7 @@ public:
        // This thread should not have been blocked by the above transaction
        // (5s is the timeout period that applyTransactionState waits for SF to
        // commit the transaction)
        EXPECT_LE(systemTime(), applicationSentTime + s2ns(5));
        EXPECT_LE(systemTime(), applicationSentTime + mFlinger.getAnimationTransactionTimeout());
        // transaction that would goes to pending transaciton queue.
        mFlinger.flushTransactionQueues();

@@ -246,9 +248,11 @@ public:
        // the transaction should be placed on the pending queue
        if (flags & (ISurfaceComposer::eAnimation | ISurfaceComposer::eSynchronous) ||
            syncInputWindows) {
            EXPECT_GE(systemTime(), applicationSentTime + s2ns(5));
            EXPECT_GE(systemTime(),
                      applicationSentTime + mFlinger.getAnimationTransactionTimeout());
        } else {
            EXPECT_LE(systemTime(), applicationSentTime + s2ns(5));
            EXPECT_LE(systemTime(),
                      applicationSentTime + mFlinger.getAnimationTransactionTimeout());
        }

        // transaction that would goes to pending transaciton queue.