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

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

Merge "SF: explicitly mark surface frame without a composite as non janky" into main

parents d9593b23 14beed76
Loading
Loading
Loading
Loading
+24 −0
Original line number Diff line number Diff line
@@ -681,6 +681,15 @@ void SurfaceFrame::onPresent(nsecs_t presentTime, int32_t displayFrameJankType,
    }
}

void SurfaceFrame::onCommitNotComposited(Fps refreshRate, Fps displayFrameRenderRate) {
    std::scoped_lock lock(mMutex);

    mDisplayFrameRenderRate = displayFrameRenderRate;
    mActuals.presentTime = mPredictions.presentTime;
    nsecs_t deadlineDelta = 0;
    classifyJankLocked(JankType::None, refreshRate, displayFrameRenderRate, deadlineDelta);
}

void SurfaceFrame::tracePredictions(int64_t displayFrameToken, nsecs_t monoBootOffset) const {
    int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing();

@@ -912,6 +921,15 @@ void FrameTimeline::setSfPresent(nsecs_t sfPresentTime,
    finalizeCurrentDisplayFrame();
}

void FrameTimeline::onCommitNotComposited() {
    ATRACE_CALL();
    std::scoped_lock lock(mMutex);
    mCurrentDisplayFrame->onCommitNotComposited();
    mCurrentDisplayFrame.reset();
    mCurrentDisplayFrame = std::make_shared<DisplayFrame>(mTimeStats, mJankClassificationThresholds,
                                                          &mTraceCookieCounter);
}

void FrameTimeline::DisplayFrame::addSurfaceFrame(std::shared_ptr<SurfaceFrame> surfaceFrame) {
    mSurfaceFrames.push_back(surfaceFrame);
}
@@ -1094,6 +1112,12 @@ void FrameTimeline::DisplayFrame::onPresent(nsecs_t signalTime, nsecs_t previous
    }
}

void FrameTimeline::DisplayFrame::onCommitNotComposited() {
    for (auto& surfaceFrame : mSurfaceFrames) {
        surfaceFrame->onCommitNotComposited(mRefreshRate, mRenderRate);
    }
}

void FrameTimeline::DisplayFrame::tracePredictions(pid_t surfaceFlingerPid,
                                                   nsecs_t monoBootOffset) const {
    int64_t expectedTimelineCookie = mTraceCookieCounter.getCookieForTracing();
+9 −0
Original line number Diff line number Diff line
@@ -204,6 +204,8 @@ public:
    void onPresent(nsecs_t presentTime, int32_t displayFrameJankType, Fps refreshRate,
                   Fps displayFrameRenderRate, nsecs_t displayDeadlineDelta,
                   nsecs_t displayPresentDelta);
    // Sets the frame as none janky as there was no real display frame.
    void onCommitNotComposited(Fps refreshRate, Fps displayFrameRenderRate);
    // All the timestamps are dumped relative to the baseTime
    void dump(std::string& result, const std::string& indent, nsecs_t baseTime) const;
    // Dumps only the layer, token, is buffer, jank metadata, prediction and present states.
@@ -318,6 +320,10 @@ public:
    virtual void setSfPresent(nsecs_t sfPresentTime, const std::shared_ptr<FenceTime>& presentFence,
                              const std::shared_ptr<FenceTime>& gpuFence) = 0;

    // Tells FrameTimeline that a frame was committed but not composited. This is used to flush
    // all the associated surface frames.
    virtual void onCommitNotComposited() = 0;

    // Args:
    // -jank : Dumps only the Display Frames that are either janky themselves
    //         or contain janky Surface Frames.
@@ -390,6 +396,8 @@ public:
                        std::optional<TimelineItem> predictions, nsecs_t wakeUpTime);
        // Sets the appropriate metadata and classifies the jank.
        void onPresent(nsecs_t signalTime, nsecs_t previousPresentTime);
        // Flushes all the surface frames as those were not generating any actual display frames.
        void onCommitNotComposited();
        // Adds the provided SurfaceFrame to the current display frame.
        void addSurfaceFrame(std::shared_ptr<SurfaceFrame> surfaceFrame);

@@ -475,6 +483,7 @@ public:
    void setSfWakeUp(int64_t token, nsecs_t wakeupTime, Fps refreshRate, Fps renderRate) override;
    void setSfPresent(nsecs_t sfPresentTime, const std::shared_ptr<FenceTime>& presentFence,
                      const std::shared_ptr<FenceTime>& gpuFence = FenceTime::NO_FENCE) override;
    void onCommitNotComposited() override;
    void parseArgs(const Vector<String16>& args, std::string& result) override;
    void setMaxDisplayFrames(uint32_t size) override;
    float computeFps(const std::unordered_set<int32_t>& layerIds) override;
+1 −0
Original line number Diff line number Diff line
@@ -32,6 +32,7 @@ struct ISchedulerCallback {
    virtual void onChoreographerAttached() = 0;
    virtual void onExpectedPresentTimePosted(TimePoint, ftl::NonNull<DisplayModePtr>,
                                             Fps renderRate) = 0;
    virtual void onCommitNotComposited(PhysicalDisplayId pacesetterDisplayId) = 0;

protected:
    ~ISchedulerCallback() = default;
+1 −0
Original line number Diff line number Diff line
@@ -221,6 +221,7 @@ void Scheduler::onFrameSignal(ICompositor& compositor, VsyncId vsyncId,
            if (FlagManager::getInstance().vrr_config()) {
                compositor.sendNotifyExpectedPresentHint(pacesetterPtr->displayId);
            }
            mSchedulerCallback.onCommitNotComposited(pacesetterPtr->displayId);
            return;
        }
    }
+6 −0
Original line number Diff line number Diff line
@@ -4405,6 +4405,12 @@ void SurfaceFlinger::sendNotifyExpectedPresentHint(PhysicalDisplayId displayId)
    scheduleNotifyExpectedPresentHint(displayId);
}

void SurfaceFlinger::onCommitNotComposited(PhysicalDisplayId pacesetterDisplayId) {
    if (FlagManager::getInstance().commit_not_composited()) {
        mFrameTimeline->onCommitNotComposited();
    }
}

void SurfaceFlinger::initScheduler(const sp<const DisplayDevice>& display) {
    using namespace scheduler;

Loading