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

Commit 621f9d47 authored by Yiwei Zhang's avatar Yiwei Zhang
Browse files

SF TimeStats: fix missed frame logic

The current missed frames count is correct, but the decrement on the
total frames when mPropagateBackpressure is enabled is not right since
the missed frame won't count twice on SurfaceFlinger side. This change
fixed this logic error.

Test: dumpsys SurfaceFlinger --timestats <see go/sf-timestats for args>
Bug: b/70388650
Change-Id: I3bab221ad4b9f44da965084fd52da6c82523d1f4
parent 7dbedde3
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -1471,13 +1471,12 @@ void SurfaceFlinger::onMessageReceived(int32_t what) {
                    (mPreviousPresentFence->getSignalTime() ==
                            Fence::SIGNAL_TIME_PENDING);
            ATRACE_INT("FrameMissed", static_cast<int>(frameMissed));
            if (mPropagateBackpressure && frameMissed) {
                mTimeStats.incrementMissedFrames(true);
            if (frameMissed) {
                mTimeStats.incrementMissedFrames();
                if (mPropagateBackpressure) {
                    signalLayerUpdate();
                    break;
                }
            if (frameMissed) {
                mTimeStats.incrementMissedFrames(false);
            }

            // Now that we're going to make it to the handleMessageTransaction()
+1 −4
Original line number Diff line number Diff line
@@ -87,15 +87,12 @@ void TimeStats::incrementTotalFrames() {
    timeStats.totalFrames++;
}

void TimeStats::incrementMissedFrames(bool propagateBackpressure) {
void TimeStats::incrementMissedFrames() {
    if (!mEnabled.load()) return;

    ATRACE_CALL();

    std::lock_guard<std::mutex> lock(mMutex);
    if (propagateBackpressure) {
        timeStats.totalFrames--;
    }
    timeStats.missedFrames++;
}

+1 −1
Original line number Diff line number Diff line
@@ -64,7 +64,7 @@ public:
    static TimeStats& getInstance();
    void parseArgs(bool asProto, const Vector<String16>& args, size_t& index, String8& result);
    void incrementTotalFrames();
    void incrementMissedFrames(bool propagateBackpressure);
    void incrementMissedFrames();
    void incrementClientCompositionFrames();

    void setPostTime(const std::string& layerName, uint64_t frameNumber, nsecs_t postTime);