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

Commit 7e3aa764 authored by Alec Mouri's avatar Alec Mouri
Browse files

Fix early firing when adding event listeners

Prior to this, if e.g. SF was not registered at time T, and is registered at
time T+8, with 16ms vsyncs and 0ms phase offsets, then it will wakeup
immediately and skip the event at T+16 to prevent a double-rate event.
With this change, the event will now correctly fire at T+16 instead of
at T+8.

Bug: 130251791
Test: atest
google/perf/jank/UIBench/UIBench:com.android.uibench.janktests.UiBenchJankTests#testSlowNestedRecyclerViewInitialFling
Change-Id: Icd72e87c43a54ef712622303ee0be4deabf6e176
parent ea17f777
Loading
Loading
Loading
Loading
+5 −2
Original line number Diff line number Diff line
@@ -213,11 +213,14 @@ public:
            const nsecs_t phaseCorrection = mPhase + listener.mPhase;
            listener.mLastEventTime = predictedReference + phaseCorrection;
            // If we're very close in time to the predicted last event time,
            // and we're not very close to the next predicted last event time
            // then we need to back up the last event time so that we can
            // attempt to fire an event immediately.
            //
            // Otherwise, keep the last event time that we predicted.
            if (isShorterThanPeriod(now - listener.mLastEventTime)) {
            // Otherwise, keep the last event time that we predicted so that
            // we don't wake up early.
            if (isShorterThanPeriod(now - listener.mLastEventTime) &&
                !isShorterThanPeriod(listener.mLastEventTime + mPeriod - now)) {
                listener.mLastEventTime -= mPeriod;
            }
        } else {