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

Commit b5223cf1 authored by Rachel Lee's avatar Rachel Lee
Browse files

ResyncCallback in getLatestVsyncEventData.

Without resyncing, getLatestVsyncEventData might have wrong refresh rate
compared to hardware. `getLatestVsyncEventData` is an alternate way
to get vsync information, instead of posting callbacks to Choreographer.

Choreographer only needs to resync when the main thread is hogged by an
application for more than the threshold (currently 750ms), and simulated
vsync is no longer accurate.

Bug: 205721584
Test: atest libsurfaceflinger_unittest
Change-Id: I32c69b0368365c860fa0eb75f932e283e05a1302
parent 56becd9a
Loading
Loading
Loading
Loading
+6 −0
Original line number Diff line number Diff line
@@ -346,6 +346,12 @@ void EventThread::requestNextVsync(const sp<EventThreadConnection>& connection)

VsyncEventData EventThread::getLatestVsyncEventData(
        const sp<EventThreadConnection>& connection) 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).
    if (connection->resyncCallback) {
        connection->resyncCallback();
    }

    VsyncEventData vsyncEventData;
    nsecs_t frameInterval = mGetVsyncPeriodFunction(connection->mOwnerUid);
    vsyncEventData.frameInterval = frameInterval;
+4 −0
Original line number Diff line number Diff line
@@ -414,6 +414,10 @@ TEST_F(EventThreadTest, getLatestVsyncEventData) {
    EXPECT_CALL(*mVSyncSource, getLatestVSyncData()).WillOnce(Return(preferredData));

    VsyncEventData vsyncEventData = mThread->getLatestVsyncEventData(mConnection);

    // Check EventThread immediately requested a resync.
    EXPECT_TRUE(mResyncCallRecorder.waitForCall().has_value());

    EXPECT_GT(vsyncEventData.frameTimelines[0].deadlineTimestamp, now)
            << "Deadline timestamp should be greater than frame time";
    for (size_t i = 0; i < VsyncEventData::kFrameTimelinesLength; i++) {