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

Commit 418b3bec authored by Melody Hsu's avatar Melody Hsu Committed by Android (Google) Code Review
Browse files

Merge "Prune logic from buffer stuffing recovery using UIDs" into main

parents 969e7ea6 2e90a1eb
Loading
Loading
Loading
Loading
+0 −13
Original line number Diff line number Diff line
@@ -29,7 +29,6 @@
#include <cinttypes>
#include <numeric>
#include <unordered_set>
#include <vector>

#include "../Jank/JankTracker.h"

@@ -1005,11 +1004,6 @@ void FrameTimeline::setSfPresent(nsecs_t sfPresentTime,
    finalizeCurrentDisplayFrame();
}

const std::vector<std::shared_ptr<frametimeline::SurfaceFrame>>& FrameTimeline::getPresentFrames()
        const {
    return mPresentFrames;
}

void FrameTimeline::onCommitNotComposited() {
    SFTRACE_CALL();
    std::scoped_lock lock(mMutex);
@@ -1530,7 +1524,6 @@ void FrameTimeline::flushPendingPresentFences() {
        mPendingPresentFences.erase(mPendingPresentFences.begin());
    }

    mPresentFrames.clear();
    for (size_t i = 0; i < mPendingPresentFences.size(); i++) {
        const auto& pendingPresentFence = mPendingPresentFences[i];
        nsecs_t signalTime = Fence::SIGNAL_TIME_INVALID;
@@ -1544,12 +1537,6 @@ void FrameTimeline::flushPendingPresentFences() {
        auto& displayFrame = pendingPresentFence.second;
        displayFrame->onPresent(signalTime, mPreviousActualPresentTime);

        // Surface frames have been jank classified and can be provided to caller
        // to detect if buffer stuffing is occurring.
        for (const auto& frame : displayFrame->getSurfaceFrames()) {
            mPresentFrames.push_back(frame);
        }

        mPreviousPredictionPresentTime =
                displayFrame->trace(mSurfaceFlingerPid, monoBootOffset,
                                    mPreviousPredictionPresentTime, mFilterFramesBeforeTraceStarts);
+0 −10
Original line number Diff line number Diff line
@@ -331,11 +331,6 @@ public:
    virtual void setSfPresent(nsecs_t sfPresentTime, const std::shared_ptr<FenceTime>& presentFence,
                              const std::shared_ptr<FenceTime>& gpuFence) = 0;

    // Provides surface frames that have already been jank classified in the most recent
    // flush of pending present fences. This allows buffer stuffing detection from SF.
    virtual const std::vector<std::shared_ptr<frametimeline::SurfaceFrame>>& getPresentFrames()
            const = 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;
@@ -513,8 +508,6 @@ 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;
    const std::vector<std::shared_ptr<frametimeline::SurfaceFrame>>& getPresentFrames()
            const override;
    void onCommitNotComposited() override;
    void parseArgs(const Vector<String16>& args, std::string& result) override;
    void setMaxDisplayFrames(uint32_t size) override;
@@ -562,9 +555,6 @@ private:
    // display frame, this is a good starting size for the vector so that we can avoid the
    // internal vector resizing that happens with push_back.
    static constexpr uint32_t kNumSurfaceFramesInitial = 10;
    // Presented surface frames that have been jank classified and can
    // indicate of potential buffer stuffing.
    std::vector<std::shared_ptr<frametimeline::SurfaceFrame>> mPresentFrames;
};

} // namespace impl
+0 −25
Original line number Diff line number Diff line
@@ -512,14 +512,6 @@ void EventThread::onModeRejected(PhysicalDisplayId displayId, DisplayModeId mode
    mCondition.notify_all();
}

// Merge lists of buffer stuffed Uids
void EventThread::addBufferStuffedUids(BufferStuffingMap bufferStuffedUids) {
    std::lock_guard<std::mutex> lock(mMutex);
    for (auto& [uid, count] : bufferStuffedUids) {
        mBufferStuffedUids.emplace_or_replace(uid, count);
    }
}

void EventThread::threadMain(std::unique_lock<std::mutex>& lock) {
    DisplayEventConsumers consumers;

@@ -761,10 +753,6 @@ void EventThread::generateFrameTimeline(VsyncEventData& outVsyncEventData, nsecs

void EventThread::dispatchEvent(const DisplayEventReceiver::Event& event,
                                const DisplayEventConsumers& consumers) {
    // List of Uids that have been sent vsync data with queued buffer count.
    // Used to keep track of which Uids can be removed from the map of
    // buffer stuffed clients.
    ftl::SmallVector<uid_t, 10> uidsPostedQueuedBuffers;
    for (const auto& consumer : consumers) {
        DisplayEventReceiver::Event copy = event;
        if (event.header.type == DisplayEventType::DISPLAY_EVENT_VSYNC) {
@@ -774,13 +762,6 @@ void EventThread::dispatchEvent(const DisplayEventReceiver::Event& event,
                                  event.vsync.vsyncData.preferredExpectedPresentationTime(),
                                  event.vsync.vsyncData.preferredDeadlineTimestamp());
        }
        auto it = mBufferStuffedUids.find(consumer->mOwnerUid);
        if (it != mBufferStuffedUids.end()) {
            copy.vsync.vsyncData.numberQueuedBuffers = it->second;
            uidsPostedQueuedBuffers.emplace_back(consumer->mOwnerUid);
        } else {
            copy.vsync.vsyncData.numberQueuedBuffers = 0;
        }
        switch (consumer->postEvent(copy)) {
            case NO_ERROR:
                break;
@@ -796,12 +777,6 @@ void EventThread::dispatchEvent(const DisplayEventReceiver::Event& event,
                removeDisplayEventConnectionLocked(consumer);
        }
    }
    // The clients that have already received the queued buffer count
    // can be removed from the buffer stuffed Uid list to avoid
    // being sent duplicate messages.
    for (auto uid : uidsPostedQueuedBuffers) {
        mBufferStuffedUids.erase(uid);
    }
    if (event.header.type == DisplayEventType::DISPLAY_EVENT_VSYNC &&
        FlagManager::getInstance().vrr_config()) {
        mLastCommittedVsyncTime =
+0 −11
Original line number Diff line number Diff line
@@ -56,7 +56,6 @@ using gui::VsyncEventData;
// ---------------------------------------------------------------------------

using FrameRateOverride = DisplayEventReceiver::Event::FrameRateOverride;
using BufferStuffingMap = ftl::SmallMap<uid_t, uint32_t, 10>;

enum class VSyncRequest {
    None = -2,
@@ -141,10 +140,6 @@ public:

    virtual void onHdcpLevelsChanged(PhysicalDisplayId displayId, int32_t connectedLevel,
                                     int32_t maxLevel) = 0;

    // An elevated number of queued buffers in the server is detected. This propagates a
    // flag to Choreographer indicating that buffer stuffing recovery should begin.
    virtual void addBufferStuffedUids(BufferStuffingMap bufferStuffedUids) = 0;
};

struct IEventThreadCallback {
@@ -199,8 +194,6 @@ public:
    void onHdcpLevelsChanged(PhysicalDisplayId displayId, int32_t connectedLevel,
                             int32_t maxLevel) override;

    void addBufferStuffedUids(BufferStuffingMap bufferStuffedUids) override;

private:
    friend EventThreadTest;

@@ -241,10 +234,6 @@ private:
    scheduler::VSyncCallbackRegistration mVsyncRegistration GUARDED_BY(mMutex);
    frametimeline::TokenManager* const mTokenManager;

    // All consumers that need to recover from buffer stuffing and the number
    // of their queued buffers.
    BufferStuffingMap mBufferStuffedUids GUARDED_BY(mMutex);

    IEventThreadCallback& mCallback;

    std::thread mThread;
+0 −5
Original line number Diff line number Diff line
@@ -960,11 +960,6 @@ bool Scheduler::updateFrameRateOverridesLocked(GlobalSignals consideredSignals,
    return mFrameRateOverrideMappings.updateFrameRateOverridesByContent(frameRateOverrides);
}

void Scheduler::addBufferStuffedUids(BufferStuffingMap bufferStuffedUids) {
    if (!mRenderEventThread) return;
    mRenderEventThread->addBufferStuffedUids(std::move(bufferStuffedUids));
}

void Scheduler::promotePacesetterDisplay(PhysicalDisplayId pacesetterId, PromotionParams params) {
    std::shared_ptr<VsyncSchedule> pacesetterVsyncSchedule;
    {
Loading