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

Commit f710e24b authored by Ady Abraham's avatar Ady Abraham Committed by Android (Google) Code Review
Browse files

Merge "SF: deflake getLatestVsyncEventData" into main

parents 338b474d 40ec5841
Loading
Loading
Loading
Loading
+6 −6
Original line number Diff line number Diff line
@@ -235,7 +235,8 @@ binder::Status EventThreadConnection::getLatestVsyncEventData(
        ParcelableVsyncEventData* outVsyncEventData) {
    ATRACE_CALL();
    outVsyncEventData->vsync =
            mEventThread->getLatestVsyncEventData(sp<EventThreadConnection>::fromExisting(this));
            mEventThread->getLatestVsyncEventData(sp<EventThreadConnection>::fromExisting(this),
                                                  systemTime());
    return binder::Status::ok();
}

@@ -387,8 +388,8 @@ void EventThread::requestNextVsync(const sp<EventThreadConnection>& connection)
    }
}

VsyncEventData EventThread::getLatestVsyncEventData(
        const sp<EventThreadConnection>& connection) const {
VsyncEventData EventThread::getLatestVsyncEventData(const sp<EventThreadConnection>& connection,
                                                    nsecs_t now) const {
    // Resync so that the vsync is accurate with hardware. getLatestVsyncEventData is an alternate
    // way to get vsync data (instead of posting callbacks to Choreographer).
    mCallback.resync();
@@ -399,11 +400,10 @@ VsyncEventData EventThread::getLatestVsyncEventData(
    const auto [presentTime, deadline] = [&]() -> std::pair<nsecs_t, nsecs_t> {
        std::lock_guard<std::mutex> lock(mMutex);
        const auto vsyncTime = mVsyncSchedule->getTracker().nextAnticipatedVSyncTimeFrom(
                systemTime() + mWorkDuration.get().count() + mReadyDuration.count());
                now + mWorkDuration.get().count() + mReadyDuration.count());
        return {vsyncTime, vsyncTime - mReadyDuration.count()};
    }();
    generateFrameTimeline(vsyncEventData, frameInterval.ns(), systemTime(SYSTEM_TIME_MONOTONIC),
                          presentTime, deadline);
    generateFrameTimeline(vsyncEventData, frameInterval.ns(), now, presentTime, deadline);
    if (FlagManager::getInstance().vrr_config()) {
        mCallback.onExpectedPresentTimePosted(TimePoint::fromNs(presentTime));
    }
+4 −4
Original line number Diff line number Diff line
@@ -127,8 +127,8 @@ public:
    virtual void setVsyncRate(uint32_t rate, const sp<EventThreadConnection>& connection) = 0;
    // Requests the next vsync. If resetIdleTimer is set to true, it resets the idle timer.
    virtual void requestNextVsync(const sp<EventThreadConnection>& connection) = 0;
    virtual VsyncEventData getLatestVsyncEventData(
            const sp<EventThreadConnection>& connection) const = 0;
    virtual VsyncEventData getLatestVsyncEventData(const sp<EventThreadConnection>& connection,
                                                   nsecs_t now) const = 0;

    virtual void onNewVsyncSchedule(std::shared_ptr<scheduler::VsyncSchedule>) = 0;

@@ -160,8 +160,8 @@ public:
    status_t registerDisplayEventConnection(const sp<EventThreadConnection>& connection) override;
    void setVsyncRate(uint32_t rate, const sp<EventThreadConnection>& connection) override;
    void requestNextVsync(const sp<EventThreadConnection>& connection) override;
    VsyncEventData getLatestVsyncEventData(
            const sp<EventThreadConnection>& connection) const override;
    VsyncEventData getLatestVsyncEventData(const sp<EventThreadConnection>& connection,
                                           nsecs_t now) const override;

    void enableSyntheticVsync(bool) override;

+1 −1
Original line number Diff line number Diff line
@@ -493,7 +493,7 @@ TEST_F(EventThreadTest, getLatestVsyncEventData) {
    EXPECT_CALL(mockTracker, nextAnticipatedVSyncTimeFrom(_, _))
            .WillOnce(Return(preferredExpectedPresentationTime));

    VsyncEventData vsyncEventData = mThread->getLatestVsyncEventData(mConnection);
    VsyncEventData vsyncEventData = mThread->getLatestVsyncEventData(mConnection, now);

    // Check EventThread immediately requested a resync.
    EXPECT_TRUE(mResyncCallRecorder.waitForCall().has_value());
+1 −1
Original line number Diff line number Diff line
@@ -55,7 +55,7 @@ public:
                (override));
    MOCK_METHOD(void, requestNextVsync, (const sp<android::EventThreadConnection>&), (override));
    MOCK_METHOD(VsyncEventData, getLatestVsyncEventData,
                (const sp<android::EventThreadConnection>&), (const, override));
                (const sp<android::EventThreadConnection>&, nsecs_t), (const, override));
    MOCK_METHOD(void, requestLatestConfig, (const sp<android::EventThreadConnection>&));
    MOCK_METHOD(void, pauseVsyncCallback, (bool));
    MOCK_METHOD(void, onNewVsyncSchedule, (std::shared_ptr<scheduler::VsyncSchedule>), (override));